Update OAuth2 management parameters to follow the new scheme of Kustvakt
Change-Id: I96da49571c941348f13d6cafa6784edb31f0cda3
diff --git a/lib/Kalamar/Plugin/Auth.pm b/lib/Kalamar/Plugin/Auth.pm
index 380593d..a56634a 100644
--- a/lib/Kalamar/Plugin/Auth.pm
+++ b/lib/Kalamar/Plugin/Auth.pm
@@ -75,9 +75,9 @@
registerSuccess => 'Registrierung erfolgreich',
registerFail => 'Registrierung fehlgeschlagen',
oauthSettings => 'OAuth',
- oauthUnregister => 'Möchten sie <span class="client-name"><%= $clientName %></span> wirklich löschen?',
+ oauthUnregister => 'Möchten sie <span class="client-name"><%= $client_name %></span> wirklich löschen?',
loginHint => 'Möglicherweise müssen sie sich zunächst einloggen.',
- oauthIssueToken => 'Erzeuge einen neuen Token für <span class="client-name"><%= $clientName %></span>',
+ oauthIssueToken => 'Erzeuge einen neuen Token für <span class="client-name"><%= $client_name %></span>',
},
-en => {
loginSuccess => 'Login successful',
@@ -103,9 +103,9 @@
registerSuccess => 'Registration successful',
registerFail => 'Registration denied',
oauthSettings => 'OAuth',
- oauthUnregister => 'Do you really want to unregister <span class="client-name"><%= $clientName %></span>?',
+ oauthUnregister => 'Do you really want to unregister <span class="client-name"><%= $client_name %></span>?',
loginHint => 'Maybe you need to log in first?',
- oauthIssueToken => 'Erzeuge einen neuen Token für <span class="client-name"><%= $clientName %></span>',
+ oauthIssueToken => 'Erzeuge einen neuen Token für <span class="client-name"><%= $client_name %></span>',
}
}
}
@@ -724,7 +724,7 @@
$v->required('type')->in('PUBLIC', 'CONFIDENTIAL');
$v->required('desc', 'trim')->size(3, 255);
$v->optional('url', 'trim')->like(qr/^(http|$)/i);
- $v->optional('redirectUri', 'trim')->like(qr/^(http|$)/i);
+ $v->optional('redirect_uri', 'trim')->like(qr/^(http|$)/i);
# Render with error
if ($v->has_error) {
@@ -748,7 +748,7 @@
type => $v->param('type'),
description => $v->param('desc'),
url => $v->param('url'),
- redirectURI => $v->param('redirectURI')
+ redirect_uri => $v->param('redirect_uri')
})->then(
sub {
my $tx = shift;
@@ -767,7 +767,7 @@
$c->stash('client_desc' => $v->param('desc'));
$c->stash('client_type' => $v->param('type'));
$c->stash('client_url' => $v->param('url'));
- $c->stash('client_redirect_uri' => $v->param('redirectURI'));
+ $c->stash('client_redirect_uri' => $v->param('redirect_uri'));
$c->stash('client_id' => $client_id);
if ($client_secret) {
@@ -887,14 +887,14 @@
my $json = shift;
my ($item) = grep {
- $c->stash('client_id') eq $_->{clientId}
+ $c->stash('client_id') eq $_->{client_id}
} @$json;
unless ($item) {
return Mojo::Promise->reject;
};
- $c->stash(client_name => $item->{clientName});
+ $c->stash(client_name => $item->{client_name});
$c->stash(client_desc => $item->{description});
$c->stash(client_url => $item->{url});
$c->stash(client_type => 'PUBLIC');
diff --git a/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep b/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
index d646c89..17be73e 100644
--- a/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
@@ -9,7 +9,7 @@
<ul class="client-list">
% foreach (@$list) {
<li class="client">
- <span class="client-name"><%= link_to $_->{clientName} => url_for('oauth-tokens', client_id => $_->{clientId}) %></span>
+ <span class="client-name"><%= link_to $_->{client_name} => url_for('oauth-tokens', client_id => $_->{client_id}) %></span>
<span class="client-desc"><%= $_->{description} %></span>
% if ($_->{url}) {
<span class="client-url"><a href="<%= $_->{url} %>"><%= $_->{url} %></a></span>
@@ -51,7 +51,7 @@
%# <div>
%# %= label_for name => loc('Auth_redirectUri')
-%# %= url_field 'redirectURI', placeholder => 'https://...'
+%# %= url_field 'redirect_uri', placeholder => 'https://...'
%# </div>
%= submit_button loc('Auth_clientRegister')
diff --git a/lib/Kalamar/Plugin/Auth/templates/auth/issue-token.html.ep b/lib/Kalamar/Plugin/Auth/templates/auth/issue-token.html.ep
index ea1e66c..90371a7 100644
--- a/lib/Kalamar/Plugin/Auth/templates/auth/issue-token.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/auth/issue-token.html.ep
@@ -2,7 +2,7 @@
%= page_title
-<p><%== loc('Auth_oauthIssueToken', clientName => param('name')) %></p>
+<p><%== loc('Auth_oauthIssueToken', client_name => param('name')) %></p>
%= form_for 'oauth-issue-token-post', id => 'issue-token', class => 'form-table', begin
%= csrf_field
diff --git a/lib/Kalamar/Plugin/Auth/templates/auth/unregister.html.ep b/lib/Kalamar/Plugin/Auth/templates/auth/unregister.html.ep
index b04f1e2..508d23f 100644
--- a/lib/Kalamar/Plugin/Auth/templates/auth/unregister.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/auth/unregister.html.ep
@@ -2,7 +2,7 @@
%= page_title
-<p><%== loc('Auth_oauthUnregister', clientName => param('name')) %></p>
+<p><%== loc('Auth_oauthUnregister', client_name => param('name')) %></p>
%= form_for 'oauth-unregister-post', class => 'form-table', begin
%= csrf_field
diff --git a/t/server/mock.pl b/t/server/mock.pl
index 21b938f..43f4f5f 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -519,17 +519,31 @@
my $c = shift;
my $json = $c->req->json;
+ if ($json->{redirectURI}) {
+ return $c->render(
+ status => 400,
+ json => {
+ errors => [
+ [
+ 201,
+ "Unrecognized field \"redirectURI\" (class de.ids_mannheim.korap.web.input.OAuth2ClientJson), not marked as ignorable (5 known properties: \"redirect_uri\", \"type\", \"name\", \"description\", \"url\"])\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 94] (through reference chain: de.ids_mannheim.korap.web.input.OAuth2ClientJson[\"redirectURI\"])"
+ ]
+ ]
+ }
+ );
+ };
+
my $name = $json->{name};
my $desc = $json->{description};
my $type = $json->{type};
my $url = $json->{url};
- my $redirect_url = $json->{redirectURI};
+ my $redirect_url = $json->{redirect_uri};
my $list = $c->app->defaults('oauth.client_list');
push @$list, {
- "clientId" => $tokens{new_client_id},
- "clientName" => $name,
+ "client_id" => $tokens{new_client_id},
+ "client_name" => $name,
"description" => $desc,
"url" => $url
};
@@ -571,7 +585,7 @@
my $break = -1;
for (my $i = 0; $i < @$list; $i++) {
- if ($list->[$i]->{clientId} eq $client_id) {
+ if ($list->[$i]->{client_id} eq $client_id) {
$break = $i;
last;
};