From e5312b4c9936b61f7d86d26a57f8b95f135222a9 Mon Sep 17 00:00:00 2001 From: Michael Jett Date: Tue, 22 May 2012 14:36:40 -0400 Subject: [PATCH] Client secret now editable and dynamically generated if not present --- .../impl/DefaultOAuth2ClientDetailsEntityService.java | 6 +++++- .../src/main/webapp/resources/js/app.js | 2 ++ .../src/main/webapp/resources/template/client.html | 11 +++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java index 4fbf664c0..6e6fd33f5 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java @@ -157,9 +157,13 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt @Override public ClientDetailsEntity saveClient(ClientDetailsEntity client) { + if (client.getClientSecret().equals("")) { + client.setClientSecret(UUID.randomUUID().toString()); + } + // this must be a new client if we don't have a clientID // assign it a new ID - if (client.getClientId() == null || this.loadClientByClientId(client.getClientId()) == null) { + if (client.getClientId() == null || client.getClientId().equals("") || this.loadClientByClientId(client.getClientId()) == null) { client.setClientId(UUID.randomUUID().toString()); return this.createClient(client); } else { diff --git a/openid-connect-server/src/main/webapp/resources/js/app.js b/openid-connect-server/src/main/webapp/resources/js/app.js index 5fc5578ce..f6dbc5d85 100644 --- a/openid-connect-server/src/main/webapp/resources/js/app.js +++ b/openid-connect-server/src/main/webapp/resources/js/app.js @@ -59,6 +59,7 @@ // We can pass it default values. defaults:{ clientName:"", + clientSecret:"", registeredRedirectUri:[""], authorizedGrantTypes:[], scope:["openid"], @@ -190,6 +191,7 @@ this.model.set({ clientName:$('#clientName input').val(), + clientSecret:$('#clientSecret input').val(), registeredRedirectUri:$.trim($('#registeredRedirectUri textarea').val()).replace(/ /g,'').split("\n"), clientDescription:$('#clientDescription textarea').val(), allowRefresh:$('#allowRefresh').is(':checked'), diff --git a/openid-connect-server/src/main/webapp/resources/template/client.html b/openid-connect-server/src/main/webapp/resources/template/client.html index 997db1b7c..ede77db30 100644 --- a/openid-connect-server/src/main/webapp/resources/template/client.html +++ b/openid-connect-server/src/main/webapp/resources/template/client.html @@ -30,9 +30,7 @@ <% } %> - - <%=authorities[0]%> - + <%=clientDescription%> @@ -61,7 +59,6 @@ Redirect URI(s) Grant Types Scope - Authority Description Refresh Tokens @@ -108,6 +105,12 @@ + + + + If you leave this blank a client secret will be generated for you automatically. +