From e57ea488b305e70d0b6d485a580ee815b52e2829 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Wed, 15 Mar 2017 17:30:26 -0400 Subject: [PATCH] fixed null handling on client admin pages, added software ID and version to UI --- .../src/main/webapp/resources/js/client.js | 55 ++++++++++------ .../src/main/webapp/resources/js/dynreg.js | 29 ++++++-- .../resources/js/locale/en/messages.json | 2 +- .../webapp/resources/template/client.html | 66 ++++++++++++------- .../webapp/resources/template/dynreg.html | 40 +++++++---- 5 files changed, 126 insertions(+), 66 deletions(-) diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js index cb963cd11..2ec5708d5 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js @@ -34,26 +34,26 @@ var ClientModel = Backbone.Model.extend({ defaults:{ id:null, - clientId:"", - clientSecret:"", + clientId:null, + clientSecret:null, redirectUris:[], clientName:null, - clientUri:"", - logoUri:"", + clientUri:null, + logoUri:null, contacts:[], - tosUri:"", + tosUri:null, tokenEndpointAuthMethod:null, scope:[], grantTypes:[], responseTypes:[], - policyUri:"", + policyUri:null, - jwksUri:"", + jwksUri:null, jwks:null, jwksType:"URI", applicationType:null, - sectorIdentifierUri:"", + sectorIdentifierUri:null, subjectType:null, requestObjectSigningAlg:null, @@ -72,11 +72,15 @@ var ClientModel = Backbone.Model.extend({ requireAuthTime:false, defaultACRvalues:null, - initiateLoginUri:"", + initiateLoginUri:null, postLogoutRedirectUris:[], requestUris:[], + softwareStatement:null, + softwareId:null, + softwareVersion:null, + codeChallengeMethod:null, authorities:[], @@ -87,7 +91,7 @@ var ClientModel = Backbone.Model.extend({ claimsRedirectUris:[], - clientDescription:"", + clientDescription:null, reuseRefreshToken:true, clearAccessTokensOnRefresh:true, dynamicallyRegistered:false, @@ -769,6 +773,15 @@ var ClientFormView = Backbone.View.extend({ } }, + // returns "null" if the given value is falsy + emptyToNull:function(value) { + if (value) { + return value; + } else { + return null; + } + }, + disableUnsupportedJOSEItems:function(serverSupported, query) { var supported = ['default']; if (serverSupported) { @@ -921,33 +934,35 @@ var ClientFormView = Backbone.View.extend({ var attrs = { - clientName:$('#clientName input').val(), - clientId:$('#clientId input').val(), + clientName:this.emptyToNull($('#clientName input').val()), + clientId:this.emptyToNull($('#clientId input').val()), clientSecret: clientSecret, generateClientSecret:generateClientSecret, redirectUris: redirectUris, - clientDescription:$('#clientDescription textarea').val(), - logoUri:$('#logoUri input').val(), + clientDescription:this.emptyToNull($('#clientDescription textarea').val()), + logoUri:this.emptyToNull($('#logoUri input').val()), grantTypes: grantTypes, accessTokenValiditySeconds: accessTokenValiditySeconds, refreshTokenValiditySeconds: refreshTokenValiditySeconds, idTokenValiditySeconds: idTokenValiditySeconds, deviceCodeValiditySeconds: deviceCodeValiditySeconds, allowRefresh: $('#allowRefresh').is(':checked'), - allowIntrospection: $('#allowIntrospection input').is(':checked'), // <-- And here? --^ + allowIntrospection: $('#allowIntrospection input').is(':checked'), scope: scopes, - tosUri: $('#tosUri input').val(), - policyUri: $('#policyUri input').val(), - clientUri: $('#clientUri input').val(), + tosUri: this.emptyToNull($('#tosUri input').val()), + policyUri: this.emptyToNull($('#policyUri input').val()), + clientUri: this.emptyToNull($('#clientUri input').val()), applicationType: $('#applicationType input').filter(':checked').val(), jwksUri: jwksUri, jwks: jwks, subjectType: subjectType, - softwareStatement: $('#softwareStatement textarea').val(), + softwareStatement: this.emptyToNull($('#softwareStatement textarea').val()), + softwareId: this.emptyToNull($('#softwareId input').val()), + softwareVersion: this.emptyToNull($('#softwareVersion input').val()), tokenEndpointAuthMethod: tokenEndpointAuthMethod, responseTypes: responseTypes, sectorIdentifierUri: sectorIdentifierUri, - initiateLoginUri: $('#initiateLoginUri input').val(), + initiateLoginUri: this.emptyToNull($('#initiateLoginUri input').val()), postLogoutRedirectUris: this.postLogoutRedirectUrisCollection.pluck('item'), claimsRedirectUris: this.claimsRedirectUrisCollection.pluck('item'), reuseRefreshToken: $('#reuseRefreshToken').is(':checked'), diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/dynreg.js b/openid-connect-server-webapp/src/main/webapp/resources/js/dynreg.js index 9760ef535..dca9fe2f2 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/dynreg.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/dynreg.js @@ -61,6 +61,10 @@ var DynRegClient = Backbone.Model.extend({ request_uris:[], + software_statement:null, + software_id:null, + software_version:null, + code_challenge_method:null, registration_access_token:null, @@ -313,6 +317,15 @@ var DynRegEditView = Backbone.View.extend({ } }, + // returns "null" if the given value is falsy + emptyToNull:function(value) { + if (value) { + return value; + } else { + return null; + } + }, + // maps from a form-friendly name to the real grant parameter name grantMap:{ 'authorization_code': 'authorization_code', @@ -405,24 +418,26 @@ var DynRegEditView = Backbone.View.extend({ } var attrs = { - client_name:$('#clientName input').val(), + client_name:this.emptyToNull($('#clientName input').val()), redirect_uris: redirectUris, - logo_uri:$('#logoUri input').val(), + logo_uri:this.emptyToNull($('#logoUri input').val()), grant_types: grantTypes, scope: scopes, client_secret: null, // never send a client secret - tos_uri: $('#tosUri input').val(), - policy_uri: $('#policyUri input').val(), - client_uri: $('#clientUri input').val(), + tos_uri: this.emptyToNull($('#tosUri input').val()), + policy_uri: this.emptyToNull($('#policyUri input').val()), + client_uri: this.emptyToNull($('#clientUri input').val()), application_type: $('#applicationType input').filter(':checked').val(), jwks_uri: jwksUri, jwks: jwks, subject_type: subjectType, - software_statement: $('#softwareStatement textarea').val(), + software_statement: this.emptyToNull($('#softwareStatement textarea').val()), + softwareId: this.emptyToNull($('#softwareId input').val()), + softwareVersion: this.emptyToNull($('#softwareVersion input').val()), token_endpoint_auth_method: $('#tokenEndpointAuthMethod input').filter(':checked').val(), response_types: responseTypes, sector_identifier_uri: sectorIdentifierUri, - initiate_login_uri: $('#initiateLoginUri input').val(), + initiate_login_uri: this.emptyToNull($('#initiateLoginUri input').val()), post_logout_redirect_uris: this.postLogoutRedirectUrisCollection.pluck('item'), claims_redirect_uris: this.claimsRedirectUrisCollection.pluck('item'), require_auth_time: $('#requireAuthTime input').is(':checked'), diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json b/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json index 6cc12771d..1277794e4 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json @@ -37,7 +37,7 @@ "client-description-placeholder": "Type a description", "client-id": "Client ID", "client-id-help": "Unique identifier. If you leave this blank it will be automatically generated.", - "client-id-placeholder": "Type something", + "client-id-placeholder": "Client ID will be automatically generated", "client-name": "Client name", "client-name-help": "Human-readable application name", "client-name-placeholder": "Type something", diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/client.html b/openid-connect-server-webapp/src/main/webapp/resources/template/client.html index 7a46786a6..b2de62da9 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/template/client.html +++ b/openid-connect-server-webapp/src/main/webapp/resources/template/client.html @@ -215,7 +215,7 @@
- +

Human-readable application name

@@ -223,7 +223,7 @@
- +

Unique identifier. If you leave this blank it will be automatically generated.

@@ -246,7 +246,7 @@
- +

URL that points to a logo image, will be displayed on approval page

@@ -260,7 +260,7 @@
- +

URL for the Terms of Service of this client, will be displayed to the user

@@ -268,7 +268,7 @@
- +

URL for the Policy Statement of this client, will be displayed to the user

@@ -276,23 +276,27 @@
- +

URL for the client's home page, will be displayed to the user

-
- -
-
- > - - > - -
-
-
- +
+ +
+ +

Identifier for the software in this client

+
+
+ +
+ +
+ +

Version of the software in this client

+
+
+
@@ -428,7 +432,7 @@
- +

Sector Identifier for JavaScript

@@ -490,7 +494,7 @@
- +
Generate on Save @@ -535,11 +539,11 @@
- +

URL for the client's JSON Web Key set (must be reachable by the server)

- +

Key set value (must be a valid JWK Set formatted key)

@@ -784,7 +788,7 @@
- +

URL to initiate login on the client

@@ -815,7 +819,7 @@
- +

Default maximum session age before re-prompting

@@ -832,7 +836,19 @@
- +
+ +
+
+ > + + > + +
+
+
+ + diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/dynreg.html b/openid-connect-server-webapp/src/main/webapp/resources/template/dynreg.html index ffed2638a..11696ba72 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/template/dynreg.html +++ b/openid-connect-server-webapp/src/main/webapp/resources/template/dynreg.html @@ -191,18 +191,22 @@ -
- -
- - -
-
- +
+ +
+ +

Identifier for the software in this client

+
+
+ +
+ +
+ +

Version of the software in this client

+
+
+
@@ -578,7 +582,17 @@
- +
+ +
+ + +
+