system scope service applied to client creation UI
parent
cab36a2b80
commit
a3037a18a7
|
@ -7,6 +7,7 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.PersistenceUnit;
|
import javax.persistence.PersistenceUnit;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
|
||||||
@Repository("jpaSystemScopeRepository")
|
@Repository("jpaSystemScopeRepository")
|
||||||
public class JpaSystemScopeRepository implements SystemScopeRepository {
|
public class JpaSystemScopeRepository implements SystemScopeRepository {
|
||||||
|
|
||||||
@PersistenceUnit
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -160,7 +160,7 @@ CREATE TABLE IF NOT EXISTS token_scope (
|
||||||
scope VARCHAR(2048)
|
scope VARCHAR(2048)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS site_scope (
|
CREATE TABLE IF NOT EXISTS system_scope (
|
||||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||||
scope VARCHAR(1024),
|
scope VARCHAR(1024),
|
||||||
description VARCHAR(4096),
|
description VARCHAR(4096),
|
||||||
|
|
|
@ -190,6 +190,40 @@
|
||||||
url: 'api/approved'
|
url: 'api/approved'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var SystemScopeModel = Backbone.Model.extend({
|
||||||
|
idAttribute: 'id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
// fake the 'item' portion
|
||||||
|
get: function (attr) {
|
||||||
|
if (attr == 'item') {
|
||||||
|
attr = 'value';
|
||||||
|
}
|
||||||
|
|
||||||
|
return Backbone.Model.prototype.get.call(this, attr);
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
urlRoot: 'api/scopes'
|
||||||
|
});
|
||||||
|
|
||||||
|
var SystemScopeCollection = Backbone.Collection.extend({
|
||||||
|
idAttribute: 'id',
|
||||||
|
|
||||||
|
model: SystemScopeModel,
|
||||||
|
|
||||||
|
url: 'api/scopes',
|
||||||
|
|
||||||
|
defaultScopes: function() {
|
||||||
|
filtered = this.filter(function(scope) {
|
||||||
|
return scope.get("defaultScope") === true;
|
||||||
|
});
|
||||||
|
return new SystemScopeCollection(filtered);
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
var ClientModel = Backbone.Model.extend({
|
var ClientModel = Backbone.Model.extend({
|
||||||
|
|
||||||
idAttribute: "id",
|
idAttribute: "id",
|
||||||
|
@ -214,7 +248,7 @@
|
||||||
clientSecret:"",
|
clientSecret:"",
|
||||||
registeredRedirectUri:[],
|
registeredRedirectUri:[],
|
||||||
authorizedGrantTypes:["authorization_code"],
|
authorizedGrantTypes:["authorization_code"],
|
||||||
scope:["openid"],
|
scope:[],
|
||||||
authorities:[],
|
authorities:[],
|
||||||
clientDescription:"",
|
clientDescription:"",
|
||||||
logoUrl:"",
|
logoUrl:"",
|
||||||
|
@ -633,7 +667,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#scope .controls",this.el).html(new ListWidgetView({placeholder: 'new scope here'
|
$("#scope .controls",this.el).html(new ListWidgetView({placeholder: 'new scope here'
|
||||||
, autocomplete: _.uniq(_.flatten(app.clientList.pluck("scope")))
|
, autocomplete: _.uniq(_.flatten(app.systemScopes.defaultScopes.pluck("value"))) // TODO: load from default scopes
|
||||||
, collection: this.scopeCollection}).render().el);
|
, collection: this.scopeCollection}).render().el);
|
||||||
|
|
||||||
if (!this.model.get("allowRefresh")) {
|
if (!this.model.get("allowRefresh")) {
|
||||||
|
@ -1030,6 +1064,7 @@
|
||||||
this.whiteListList = new WhiteListCollection();
|
this.whiteListList = new WhiteListCollection();
|
||||||
this.blackListList = new BlackListCollection();
|
this.blackListList = new BlackListCollection();
|
||||||
this.approvedSiteList = new ApprovedSiteCollection();
|
this.approvedSiteList = new ApprovedSiteCollection();
|
||||||
|
this.systemScopes = new SystemScopeCollection();
|
||||||
|
|
||||||
this.clientListView = new ClientListView({model:this.clientList});
|
this.clientListView = new ClientListView({model:this.clientList});
|
||||||
this.whiteListListView = new WhiteListListView({model:this.whiteListList});
|
this.whiteListListView = new WhiteListListView({model:this.whiteListList});
|
||||||
|
@ -1048,12 +1083,16 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// load things in the right order:
|
// load things in the right order:
|
||||||
this.clientList.fetch({
|
this.systemScopes.fetch({
|
||||||
success: function(collection, response) {
|
success: function(collection, response) {
|
||||||
app.whiteListList.fetch({
|
this.clientList.fetch({
|
||||||
success: function(collection, response) {
|
success: function(collection, response) {
|
||||||
var baseUrl = $.url($('base').attr('href'));
|
app.whiteListList.fetch({
|
||||||
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
|
success: function(collection, response) {
|
||||||
|
var baseUrl = $.url($('base').attr('href'));
|
||||||
|
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1089,7 +1128,8 @@
|
||||||
client.set({
|
client.set({
|
||||||
requireClientSecret:true,
|
requireClientSecret:true,
|
||||||
generateClientSecret:true,
|
generateClientSecret:true,
|
||||||
displayClientSecret:false
|
displayClientSecret:false,
|
||||||
|
scope: _.uniq(_.flatten(this.systemScopes.defaultScopes.pluck("value"))),
|
||||||
}, { silent: true });
|
}, { silent: true });
|
||||||
|
|
||||||
this.clientFormView = new ClientFormView({model:client});
|
this.clientFormView = new ClientFormView({model:client});
|
||||||
|
|
Loading…
Reference in New Issue