From 112154a2d8f977411c0cd66f788fb67bba84037c Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Thu, 26 Jun 2014 13:10:19 -0400 Subject: [PATCH] cleaned up contacts handling across all classes of client, added text to address #626 --- .../src/main/webapp/resources/js/admin.js | 25 +++++++++++++++-- .../src/main/webapp/resources/js/dynreg.js | 27 ++++++++++++++++--- .../src/main/webapp/resources/js/rsreg.js | 4 +-- .../webapp/resources/template/dynreg.html | 2 ++ .../main/webapp/resources/template/rsreg.html | 2 ++ 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js index 5ae728a26..549597c97 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js @@ -530,6 +530,12 @@ var AppRouter = Backbone.Router.extend({ var view = new ClientFormView({model:client, systemScopeList: this.systemScopeList}); view.load(function() { // set up this new client to require a secret and have us autogenerate one + var userInfo = getUserInfo(); + var contacts = []; + if (userInfo != null && userInfo.email != null) { + contacts.push(userInfo.email); + } + client.set({ tokenEndpointAuthMethod: "SECRET_BASIC", generateClientSecret:true, @@ -541,7 +547,8 @@ var AppRouter = Backbone.Router.extend({ idTokenValiditySeconds:600, grantTypes: ["authorization_code"], responseTypes: ["code"], - subjectType: "PUBLIC" + subjectType: "PUBLIC", + contacts: contacts }, { silent: true }); @@ -903,6 +910,12 @@ var AppRouter = Backbone.Router.extend({ view.load(function() { + var userInfo = getUserInfo(); + var contacts = []; + if (userInfo != null && userInfo.email != null) { + contacts.push(userInfo.email); + } + client.set({ require_auth_time:true, default_max_age:60000, @@ -910,7 +923,8 @@ var AppRouter = Backbone.Router.extend({ token_endpoint_auth_method: 'client_secret_basic', grant_types: ["authorization_code"], response_types: ["code"], - subject_type: "public" + subject_type: "public", + contacts: contacts }, { silent: true }); $('#content').html(view.render().el); @@ -968,9 +982,16 @@ var AppRouter = Backbone.Router.extend({ view.load(function() { + var userInfo = getUserInfo(); + var contacts = []; + if (userInfo != null && userInfo.email != null) { + contacts.push(userInfo.email); + } + client.set({ scope: _.uniq(_.flatten(app.systemScopeList.defaultDynRegScopes().pluck("value"))).join(" "), token_endpoint_auth_method: 'client_secret_basic', + contacts: contacts }, { silent: true }); $('#content').html(view.render().el); 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 2345a4be7..ef0cf477a 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 @@ -128,13 +128,22 @@ var DynRegRootView = Backbone.View.extend({ var self = this; client.fetch({success: function() { + + var userInfo = getUserInfo(); + var contacts = client.get("contacts"); + if (userInfo != null && userInfo.email != null && ! _.contains(contacts, userInfo.email)) { + contacts.push(userInfo.email); + } + client.set({ + contacts: contacts + }, { silent: true }); var view = new DynRegEditView({model: client, systemScopeList: app.systemScopeList}); view.load(function() { $('#content').html(view.render().el); view.delegateEvents(); - setPageTitle("Dynamically Register a New Client"); + setPageTitle("Edit a Dynamically Registered Client"); app.navigate('dev/dynreg/edit', {trigger: true}); self.remove(); }); @@ -383,7 +392,17 @@ var DynRegEditView = Backbone.View.extend({ // switch to an "edit" view app.navigate('dev/dynreg/edit', {trigger: true}); _self.remove(); - var view = new DynRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList}); + + var userInfo = getUserInfo(); + var contacts = _self.model.get("contacts"); + if (userInfo != null && userInfo.email != null && ! _.contains(contacts, userInfo.email)) { + contacts.push(userInfo.email); + } + _self.model.set({ + contacts: contacts + }, { silent: true }); + + var view = new DynRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList}); view.load(function() { // reload @@ -413,7 +432,7 @@ var DynRegEditView = Backbone.View.extend({ }, render:function() { - $(this.el).html(this.template({client: this.model.toJSON()})); + $(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()})); var _self = this; @@ -444,7 +463,7 @@ var DynRegEditView = Backbone.View.extend({ _self.contactsCollection.add(new Backbone.Model({item:contact})); }); - $("#contacts .controls", this.el).html(new ListWidgetView({ + $("#contacts .controls div", this.el).html(new ListWidgetView({ placeholder: 'new contact', collection: this.contactsCollection}).render().el); 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 a36717a01..3b99609e8 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 @@ -332,7 +332,7 @@ var ResRegEditView = Backbone.View.extend({ }, render:function() { - $(this.el).html(this.template({client: this.model.toJSON()})); + $(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()})); var _self = this; @@ -363,7 +363,7 @@ var ResRegEditView = Backbone.View.extend({ _self.contactsCollection.add(new Backbone.Model({item:contact})); }); - $("#contacts .controls", this.el).html(new ListWidgetView({ + $("#contacts .controls div", this.el).html(new ListWidgetView({ placeholder: 'new contact', collection: this.contactsCollection}).render().el); 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 633b9ac36..92e2c7d70 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 @@ -225,6 +225,8 @@
+

List of contacts for adminstrators of this client. Your email address (<%= userInfo.email %>) will be automatically added to this list on save.

+
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 3aa65b7cf..0738f3943 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 @@ -217,6 +217,8 @@
+ List of contacts for adminstrators of this client. Your email address (<%= userInfo.email %>) will be automatically added to this list on save. +