Support confidential clients
Change-Id: I907592587ae296bef592c2f731a0302c6e9e8c8b
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 97bb173..00f8242 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -8,7 +8,7 @@
use List::Util 'none';
# Minor version - may be patched from package.json
-our $VERSION = '0.44';
+our $VERSION = '0.45';
# Supported version of Backend API
our $API_VERSION = '1.0';
diff --git a/lib/Kalamar/Plugin/Auth.pm b/lib/Kalamar/Plugin/Auth.pm
index 011dae1..963300a 100644
--- a/lib/Kalamar/Plugin/Auth.pm
+++ b/lib/Kalamar/Plugin/Auth.pm
@@ -873,6 +873,14 @@
my $result = $tx->result;
if ($result->is_error) {
+ my $json = $result->json;
+ if ($json && $json->{error}) {
+ $c->notify(
+ error => $json->{error} .
+ ($json->{error_description} ? ': ' . $json->{error_description} : '')
+ )
+ };
+
return Mojo::Promise->reject;
};
@@ -898,10 +906,7 @@
}
)->catch(
sub {
- # Server may be irresponsible
- my $err = shift;
$c->notify('error' => $c->loc('Auth_en_registerFail'));
- return Mojo::Promise->reject($err);
}
)->finally(
sub {
@@ -1018,7 +1023,7 @@
$c->stash(client_name => $item->{client_name});
$c->stash(client_desc => $item->{client_description});
$c->stash(client_url => $item->{client_url});
- $c->stash(client_type => 'PUBLIC');
+ $c->stash(client_type => ($item->{client_type} // 'PUBLIC'));
$c->auth->token_list_p($c->stash('client_id'));
}
diff --git a/lib/Kalamar/Plugin/Auth/templates/auth/client.html.ep b/lib/Kalamar/Plugin/Auth/templates/auth/client.html.ep
index 28074ea..de9e3a6 100644
--- a/lib/Kalamar/Plugin/Auth/templates/auth/client.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/auth/client.html.ep
@@ -9,19 +9,23 @@
<li class="client">
<span class="client-name"><%= stash 'client_name' %></span>
% if (stash('client_desc')) {
- <span class="client-desc"><%= stash 'client_desc' %></span>
+ <p class="client-desc"><%= stash 'client_desc' %></p>
% };
% if (stash('client_url')) {
- <span class="client-url"><a href="<%= stash('client_url') %>"><%= stash('client_url') %></a></span>
+ <p class="client-url"><a href="<%= stash('client_url') %>"><%= stash('client_url') %></a></p>
+ % };
+
+ % if (stash('client_redirect_uri')) {
+ <p class="client-redirect-uri"><%= loc 'Auth_redirectUri' %>: <tt><%= stash('client_redirect_uri') %></tt></p>
% };
- <p><%= loc 'Auth_clientType' %>: <tt><%= stash 'client_type' %></tt></p>
+ <p class="client-type"><%= loc 'Auth_clientType' %>: <tt><%= stash 'client_type' %></tt></p>
%= label_for 'client_id' => loc('Auth_clientID')
%= text_field 'client_id', stash('client_id'), readonly => 'readonly', class => 'copy-to-clipboard'
- % if (stash('client_type') && stash('client_type') ne 'PUBLIC') {
+ % if (stash('client_type') && stash('client_type') ne 'PUBLIC' && stash('client_secret')) {
<div>
%= label_for 'client_secret' => loc('Auth_clientSecret')
- %= password_field 'client_secret', value => stash('client_secret'), readonly => 'readonly'
+ %= password_field 'client_secret', value => stash('client_secret'), readonly => 'readonly', class => 'show-pwd copy-to-clipboard'
</div>
% };
@@ -29,7 +33,9 @@
<span class="button-group button-panel">
%= link_to loc('Auth_oauthUnregister_short') => url_for('oauth-unregister', client_id => stash('client_id'))->query('name' => stash('client_name')) => {} => ( class => 'client-unregister' )
- %= link_to loc('Auth_oauthIssueToken_short') => url_for('oauth-issue-token', client_id => stash('client_id'))->query('name' => stash('client_name')) => {} => ( class => 'client-issue-token' )
+ % if (stash('client_type') && stash('client_type') eq 'PUBLIC') {
+ %= link_to loc('Auth_oauthIssueToken_short') => url_for('oauth-issue-token', client_id => stash('client_id'))->query('name' => stash('client_name')) => {} => ( class => 'client-issue-token' )
+ % };
</span>
</li>
</ul>
diff --git a/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep b/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
index 928e4c7..cee1abd 100644
--- a/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
@@ -8,10 +8,12 @@
% foreach (@$list) {
<li class="client">
<span class="client-name"><%= link_to $_->{client_name} => url_for('oauth-tokens', client_id => $_->{client_id}) %></span>
- <span class="client-desc"><%= $_->{client_description} %></span>
-% if ($_->{client_url}) {
- <span class="client-url"><a href="<%= $_->{client_url} %>"><%= $_->{client_url} %></a></span>
-% }
+ % if ($_->{client_description}) {
+ <p class="client-desc"><%= $_->{client_description} %></p>
+ % };
+ % if ($_->{client_url}) {
+ <p class="client-url"><a href="<%= $_->{client_url} %>"><%= $_->{client_url} %></a></p>
+ % }
</li>
% };
</ul>
@@ -32,9 +34,9 @@
%= label_for type => loc('Auth_clientType'), class => 'field-required'
<%= radio_button type => 'PUBLIC', checked => 'checked' %>
<label>Public</label>
-%# <br />
-%# <%= radio_button type => 'CONFIDENTIAL' %>
-%# <label>Confidential</label>
+ <br />
+ <%= radio_button type => 'CONFIDENTIAL' %>
+ <label>Confidential</label>
</div>
<div>
@@ -47,10 +49,10 @@
%= url_field 'url', placeholder => 'https://...'
</div>
-%# <div>
-%# %= label_for name => loc('Auth_redirectUri')
-%# %= url_field 'redirect_uri', placeholder => 'https://...'
-%# </div>
+ <div>
+ %= label_for name => loc('Auth_redirectUri')
+ %= url_field 'redirect_uri', placeholder => 'https://...'
+ </div>
%= submit_button loc('Auth_clientRegister')
</fieldset>