diff --git a/openid-connect-server/src/main/webapp/resources/js/admin.js b/openid-connect-server/src/main/webapp/resources/js/admin.js index 2fef08a50..9932db658 100644 --- a/openid-connect-server/src/main/webapp/resources/js/admin.js +++ b/openid-connect-server/src/main/webapp/resources/js/admin.js @@ -672,7 +672,7 @@ var AppRouter = Backbone.Router.extend({ this.breadCrumbView.collection.add([ {text:"Home", href:""}, {text:"Client Registration", href:"manage/#dev/dynreg"}, - {text:"New", href:"manage/#dev/dynreg/new"} + {text:"Edit", href:"manage/#dev/dynreg/new"} ]); setPageTitle("Edit a New Client"); diff --git a/openid-connect-server/src/main/webapp/resources/js/dynreg.js b/openid-connect-server/src/main/webapp/resources/js/dynreg.js index 91df34f4f..b3317ee6e 100644 --- a/openid-connect-server/src/main/webapp/resources/js/dynreg.js +++ b/openid-connect-server/src/main/webapp/resources/js/dynreg.js @@ -92,22 +92,22 @@ var DynRegRootView = Backbone.View.extend({ var clientId = $('#clientId').val(); var token = $('#regtoken').val(); - var client = new DynRegClient(); - client.set({ + var client = new DynRegClient({ client_id: clientId, registration_access_token: token - }, { silent: true }); + }); console.log(client.get('registration_access_token')); - client.fetch(); - console.log(client); - - var dynRegEditView = new DynRegEditView({model: client}); - - this.remove(); - $('#content').html(dynRegEditView.render().el); + client.fetch({success: function() { + console.log(client); + + var dynRegEditView = new DynRegEditView({model: client}); + + $('#content').html(dynRegEditView.render().el); + }}); app.navigate('dev/dynreg/edit', {trigger: true}); + this.remove(); } }); @@ -128,10 +128,138 @@ var DynRegEditView = Backbone.View.extend({ this.requestUrisCollection = new Backbone.Collection(); }, - render:function() { - $(this.el).html(this.template(this.model.toJSON())); + previewLogo:function(event) { + if ($('#logoUri input', this.el).val()) { + $('#logoPreview', this.el).empty(); + $('#logoPreview', this.el).attr('src', $('#logoUri input').val()); + } else { + $('#logoBlock', this.el).hide(); + } + }, + + disableUnsupportedJOSEItems:function(serverSupported, query) { + var supported = ['default']; + if (serverSupported) { + supported = _.union(supported, serverSupported); + } + $(query, this.$el).each(function(idx) { + if(_.contains(supported, $(this).val())) { + $(this).prop('disabled', false); + } else { + $(this).prop('disabled', true); + } + }); + + }, + + // returns "null" if given the value "default" as a string, otherwise returns input value. useful for parsing the JOSE algorithm dropdowns + defaultToNull:function(value) { + if (value == 'default') { + return null; + } else { + return value; + } + }, + + // maps from a form-friendly name to the real grant parameter name + grantMap:{ + 'authorization_code': 'authorization_code', + 'password': 'password', + 'implicit': 'implicit', + 'client_credentials': 'client_credentials', + 'redelegate': 'urn:ietf:params:oauth:grant_type:redelegate', + 'refresh_token': 'refresh_token' + }, + + // maps from a form-friendly name to the real response type parameter name + responseMap:{ + 'code': 'code', + 'token': 'token', + 'idtoken': 'id_token', + 'token-idtoken': 'token id_token', + 'code-idtoken': 'code id_token', + 'code-token': 'code token', + 'code-token-idtoken': 'code token id_token' + }, + + render:function() { + console.log(this.model.toJSON()); + $(this.el).html(this.template({client: this.model.toJSON()})); - return this; + var _self = this; + + // build and bind registered redirect URI collection and view + _.each(this.model.get("redirectUris"), function (redirectUri) { + _self.redirectUrisCollection.add(new URIModel({item:redirectUri})); + }); + + $("#redirectUris .controls",this.el).html(new ListWidgetView({ + type:'uri', + placeholder: 'http://', + collection: this.redirectUrisCollection}).render().el); + + // build and bind scopes + var scopeSet = this.model.get("scope").split(" "); + _.each(scopeSet, function (scope) { + _self.scopeCollection.add(new Backbone.Model({item:scope})); + }); + + $("#scope .controls",this.el).html(new ListWidgetView({ + placeholder: 'new scope', + autocomplete: _.uniq(_.flatten(app.systemScopeList.pluck("value"))), + collection: this.scopeCollection}).render().el); + + // build and bind contacts + _.each(this.model.get('contacts'), function (contact) { + _self.contactsCollection.add(new Backbone.Model({item:contact})); + }); + + $("#contacts .controls", this.el).html(new ListWidgetView({ + placeholder: 'new contact', + collection: this.contactsCollection}).render().el); + + + // build and bind request URIs + _.each(this.model.get('requestUris'), function (requestUri) { + _self.requestUrisCollection.add(new URIModel({item:requestUri})); + }); + + $('#requestUris .controls', this.el).html(new ListWidgetView({ + type: 'uri', + placeholder: 'http://', + collection: this.requestUrisCollection}).render().el); + + // build and bind default ACR values + _.each(this.model.get('defaultAcrValues'), function (defaultAcrValue) { + _self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue})); + }); + + $('#defaultAcrValues .controls', this.el).html(new ListWidgetView({ + placeholder: 'new ACR value', + // TODO: autocomplete from spec + collection: this.defaultAcrValuesCollection}).render().el); + + this.previewLogo(); + + // disable unsupported JOSE algorithms + this.disableUnsupportedJOSEItems(app.serverConfiguration.request_object_signing_alg_values_supported, '#requestObjectSigningAlg option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.userinfo_signing_alg_values_supported, '#userInfoSignedResponseAlg option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.userinfo_encryption_alg_values_supported, '#userInfoEncryptedResponseAlg option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.userinfo_encryption_enc_values_supported, '#userInfoEncryptedResponseEnc option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.id_token_signing_alg_values_supported, '#idTokenSignedResponseAlg option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.id_token_encryption_alg_values_supported, '#idTokenEncryptedResponseAlg option'); + this.disableUnsupportedJOSEItems(app.serverConfiguration.id_token_encryption_enc_values_supported, '#idTokenEncryptedResponseEnc option'); + + this.$('.nyi').clickover({ + placement: 'right', + title: 'Not Yet Implemented', + content: 'The value of this field will be saved with the client, ' + +'but the server does not currently process anything with it. ' + +'Future versions of the server library will make use of this.' + }); + + + return this; } }); \ No newline at end of file diff --git a/openid-connect-server/src/main/webapp/resources/template/dynreg.html b/openid-connect-server/src/main/webapp/resources/template/dynreg.html index 2677cd428..36c57f22b 100644 --- a/openid-connect-server/src/main/webapp/resources/template/dynreg.html +++ b/openid-connect-server/src/main/webapp/resources/template/dynreg.html @@ -38,7 +38,7 @@