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 d1f766c79..c17e3e465 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 @@ -31,7 +31,10 @@ var DynRegClient = Backbone.Model.extend({ grant_types:[], response_types:[], policy_uri:null, + jwks_uri:null, + jwks:null, + jwksType:'URI', application_type:null, sector_identifier_uri:null, @@ -138,6 +141,16 @@ var DynRegRootView = Backbone.View.extend({ client.set({ contacts: contacts }, { silent: true }); + + if (client.get("jwks")) { + client.set({ + jwksType: "VAL" + }, { silent: true }); + } else { + client.set({ + jwksType: "URI" + }, { silent: true }); + } var view = new DynRegEditView({model: client, systemScopeList: app.systemScopeList}); @@ -203,7 +216,8 @@ var DynRegEditView = Backbone.View.extend({ "click .btn-cancel":"cancel", "click .btn-delete":"deleteClient", "change #logoUri input":"previewLogo", - "change #tokenEndpointAuthMethod input:radio":"toggleClientCredentials" + "change #tokenEndpointAuthMethod input:radio":"toggleClientCredentials", + "change #jwkSelector input:radio":"toggleJWKSetType" }, cancel:function(e) { @@ -272,6 +286,25 @@ var DynRegEditView = Backbone.View.extend({ } }, + /** + * Set up the form based on the JWK Set selector + */ + toggleJWKSetType:function() { + var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val(); + + if (jwkSelector == 'URI') { + $('#jwksUri', this.el).show(); + $('#jwks', this.el).hide(); + } else if (jwkSelector == 'VAL') { + $('#jwksUri', this.el).hide(); + $('#jwks', this.el).show(); + } else { + $('#jwksUri', this.el).hide(); + $('#jwks', this.el).hide(); + } + + }, + disableUnsupportedJOSEItems:function(serverSupported, query) { var supported = ['default']; if (serverSupported) { @@ -354,7 +387,39 @@ var DynRegEditView = Backbone.View.extend({ } } - var attrs = { + // process the JWKS + var jwksUri = null; + var jwks = null; + var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val(); + + if (jwkSelector == 'URI') { + jwksUri = $('#jwksUri input').val(); + jwks = null; + } else if (jwkSelector == 'VAL') { + jwksUri = null; + try { + jwks = JSON.parse($('#jwks textarea').val()); + } catch (e) { + console.log("An error occurred when parsing the JWK Set"); + + //Display an alert with an error message + $('#modalAlert div.modal-header').html("JWK Set Error"); + $('#modalAlert div.modal-body').html("There was an error parsing the public key from the JSON Web Key set. Check the value and try again."); + + $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog + "backdrop" : "static", + "keyboard" : true, + "show" : true // ensure the modal is shown immediately + }); + + return false; + } + } else { + jwksUri = null; + jwks = null; + } + + var attrs = { client_name:$('#clientName input').val(), redirect_uris: this.redirectUrisCollection.pluck("item"), logo_uri:$('#logoUri input').val(), @@ -365,7 +430,8 @@ var DynRegEditView = Backbone.View.extend({ policy_uri: $('#policyUri input').val(), client_uri: $('#clientUri input').val(), application_type: $('#applicationType input').filter(':checked').val(), - jwks_uri: $('#jwksUri input').val(), + jwks_uri: jwksUri, + jwks: jwks, subject_type: $('#subjectType input').filter(':checked').val(), token_endpoint_auth_method: $('#tokenEndpointAuthMethod input').filter(':checked').val(), response_types: responseTypes, @@ -410,6 +476,16 @@ var DynRegEditView = Backbone.View.extend({ contacts: contacts }, { silent: true }); + if (_self.model.get("jwks")) { + _self.model.set({ + jwksType: "VAL" + }, { silent: true }); + } else { + _self.model.set({ + jwksType: "URI" + }, { silent: true }); + } + var view = new DynRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList}); view.load(function() { @@ -527,6 +603,7 @@ var DynRegEditView = Backbone.View.extend({ this.toggleClientCredentials(); this.previewLogo(); + this.toggleJWKSetType(); // disable unsupported JOSE algorithms this.disableUnsupportedJOSEItems(app.serverConfiguration.request_object_signing_alg_values_supported, '#requestObjectSigningAlg option'); 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 bd520e282..19fab16b8 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 @@ -355,12 +355,24 @@ -
URL for the client's JSON Web Key set
-URL for the client's JSON Web Key set (must be reachable by the server)
+JSON Web Key set
+