diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/rsreg.js b/openid-connect-server-webapp/src/main/webapp/resources/js/rsreg.js index f01a21df2..4382c3347 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/rsreg.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/rsreg.js @@ -28,7 +28,10 @@ var ResRegClient = Backbone.Model.extend({ token_endpoint_auth_method:null, scope:null, policy_uri:null, + jwks_uri:null, + jwks:null, + jwksType:'URI', application_type:null, registration_access_token:null, @@ -105,6 +108,16 @@ var ResRegRootView = Backbone.View.extend({ client.fetch({success: function() { + if (client.get("jwks")) { + client.set({ + jwksType: "VAL" + }, { silent: true }); + } else { + client.set({ + jwksType: "URI" + }, { silent: true }); + } + var view = new ResRegEditView({model: client, systemScopeList: app.systemScopeList}); view.load(function() { @@ -168,7 +181,8 @@ var ResRegEditView = 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) { @@ -237,6 +251,25 @@ var ResRegEditView = 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) { @@ -282,6 +315,38 @@ var ResRegEditView = Backbone.View.extend({ } } + // 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(), logo_uri:$('#logoUri input').val(), @@ -291,7 +356,8 @@ var ResRegEditView = 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, token_endpoint_auth_method: $('#tokenEndpointAuthMethod input').filter(':checked').val(), contacts: contacts, token_endpoint_auth_signing_alg: this.defaultToNull($('#tokenEndpointAuthSigningAlg select').val()) @@ -310,6 +376,17 @@ var ResRegEditView = Backbone.View.extend({ // switch to an "edit" view app.navigate('dev/resource/edit', {trigger: true}); _self.remove(); + + if (_self.model.get("jwks")) { + _self.model.set({ + jwksType: "VAL" + }, { silent: true }); + } else { + _self.model.set({ + jwksType: "URI" + }, { silent: true }); + } + var view = new ResRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList}); view.load(function() { @@ -376,6 +453,7 @@ var ResRegEditView = Backbone.View.extend({ this.toggleClientCredentials(); this.previewLogo(); + this.toggleJWKSetType(); // disable unsupported JOSE algorithms this.disableUnsupportedJOSEItems(app.serverConfiguration.token_endpoint_auth_signing_alg_values_supported, '#tokenEndpointAuthSigningAlg option'); diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/rsreg.html b/openid-connect-server-webapp/src/main/webapp/resources/template/rsreg.html index ea0ed35ab..d2842a322 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/template/rsreg.html +++ b/openid-connect-server-webapp/src/main/webapp/resources/template/rsreg.html @@ -259,12 +259,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
+