added policy editing overview page
parent
5698393d31
commit
3e931c68b4
|
@ -14,6 +14,7 @@
|
|||
<li><a href="manage/#user/approved" data-toggle="collapse" data-target=".nav-collapse"><spring:message code="sidebar.personal.approved_sites"/></a></li>
|
||||
<li><a href="manage/#user/tokens" data-toggle="collapse" data-target=".nav-collapse"><spring:message code="sidebar.personal.active_tokens"/></a></li>
|
||||
<li><a href="manage/#user/profile" data-toggle="collapse" data-target=".nav-collapse"><spring:message code="sidebar.personal.profile_information"/></a></li>
|
||||
<li><a href="manage/#user/policy" data-toggle="collapse" data-target=".nav-collapse"><spring:message code="sidebar.personal.resource_policies"/></a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="nav-header"><spring:message code="sidebar.developer.title"/></li>
|
||||
<li><a href="manage/#dev/dynreg" data-toggle="collapse" data-target=".nav-collapse"><spring:message code="sidebar.developer.client_registration"/></a><li>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<script type="text/javascript" src="resources/js/dynreg.js"></script>
|
||||
<script type="text/javascript" src="resources/js/rsreg.js"></script>
|
||||
<script type="text/javascript" src="resources/js/token.js"></script>
|
||||
<script type="text/javascript" src="resources/js/policy.js"></script>
|
||||
<script type="text/javascript" src="resources/js/admin.js"></script>
|
||||
</c:if>
|
||||
<script type="text/javascript" src="resources/js/lib/retina.js"></script>
|
||||
|
|
|
@ -503,6 +503,7 @@ var AppRouter = Backbone.Router.extend({
|
|||
"user/approved":"approvedSites",
|
||||
"user/tokens":"tokens",
|
||||
"user/profile":"profile",
|
||||
"user/policy":"policy",
|
||||
|
||||
"dev/dynreg":"dynReg",
|
||||
"dev/dynreg/new":"newDynReg",
|
||||
|
@ -534,6 +535,7 @@ var AppRouter = Backbone.Router.extend({
|
|||
this.clientStats = new StatsModel();
|
||||
this.accessTokensList = new AccessTokenCollection();
|
||||
this.refreshTokensList = new RefreshTokenCollection();
|
||||
this.resourceSetList = new ResourceSetCollection();
|
||||
|
||||
this.breadCrumbView = new BreadCrumbView({
|
||||
collection:new Backbone.Collection()
|
||||
|
@ -1068,13 +1070,31 @@ var AppRouter = Backbone.Router.extend({
|
|||
|
||||
this.updateSidebar('user/profile');
|
||||
|
||||
this.userProfileView = new UserProfileView({model: getUserInfo()});
|
||||
$('#content').html(this.userProfileView.render().el);
|
||||
var view = new UserProfileView({model: getUserInfo()});
|
||||
$('#content').html(view.render().el);
|
||||
|
||||
setPageTitle($.t('admin.user-profile.show'));
|
||||
|
||||
},
|
||||
|
||||
policy:function() {
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('policy.resource-sets'), href:"manage/#user/profile"}
|
||||
]);
|
||||
|
||||
this.updateSidebar('user/policy');
|
||||
|
||||
var view = new ResourceSetListView({model: this.resourceSetList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('policy.resource-sets'));
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
updateSidebar:function(item) {
|
||||
$('.sidebar-nav li.active').removeClass('active');
|
||||
|
||||
|
@ -1102,7 +1122,8 @@ $(function () {
|
|||
$.get('resources/template/whitelist.html', _load),
|
||||
$.get('resources/template/dynreg.html', _load),
|
||||
$.get('resources/template/rsreg.html', _load),
|
||||
$.get('resources/template/token.html', _load)
|
||||
$.get('resources/template/token.html', _load),
|
||||
$.get('resources/template/policy.html', _load)
|
||||
).done(function() {
|
||||
$.ajaxSetup({cache:false});
|
||||
app = new AppRouter();
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
"show": "View User Profile",
|
||||
"text": "Your user profile has the following information:",
|
||||
"value": "Claim value:"
|
||||
}
|
||||
},
|
||||
"policies": "Manage Protected Resource Policies"
|
||||
},
|
||||
"client": {
|
||||
"client-form": {
|
||||
|
@ -337,6 +338,13 @@
|
|||
"whitelist-table": {
|
||||
"no-sites": "There are no whitelisted sites. Use the <strong>whitelist</strong> button on the client management page to create one."
|
||||
}
|
||||
},
|
||||
"policy" : {
|
||||
"resource-sets": "Resource sets",
|
||||
"policy-table": {
|
||||
"edit": "Edit Policies",
|
||||
"no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some."
|
||||
}
|
||||
},
|
||||
"copyright": "Powered by <a href=\"https://github.com/mitreid-connect/\">MITREid Connect <span class=\"label\">{0}</span></a> <span class=\"pull-right\">© 2015 The MITRE Corporation and MIT KIT.</span>.",
|
||||
"about": {
|
||||
|
@ -396,7 +404,8 @@
|
|||
"title": "Personal",
|
||||
"approved_sites": "Manage Approved Sites",
|
||||
"active_tokens": "Manage Active Tokens",
|
||||
"profile_information": "View Profile Information"
|
||||
"profile_information": "View Profile Information",
|
||||
"resource_policies": "Manage Protected Resource Policies"
|
||||
},
|
||||
"developer": {
|
||||
"title": "Developer",
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2015 The MITRE Corporation
|
||||
* and the MIT Kerberos and Internet Trust Consortium
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
var ResourceSetModel = Backbone.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
var ResourceSetCollection = Backbone.Collection.extend({
|
||||
model: ResourceSetModel,
|
||||
url: 'api/claims'
|
||||
});
|
||||
|
||||
var ClaimModel = Backbone.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
var ClaimCollection = Backbone.Collection.extend({
|
||||
model: ClaimModel
|
||||
});
|
||||
|
||||
var ResourceSetListView = Backbone.View.extend({
|
||||
tagName: 'span',
|
||||
|
||||
initialize:function (options) {
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
load:function(callback) {
|
||||
if (this.model.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-resourcesets">' + $.t('policy.resource-sets') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-resourcesets').addClass('label-success');}}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
.done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
events: {
|
||||
"click .refresh-table":"refreshTable"
|
||||
},
|
||||
|
||||
render:function (eventName) {
|
||||
$(this.el).html($('#tmpl-resource-set-table').html());
|
||||
|
||||
var _self = this;
|
||||
|
||||
_.each(this.model.models, function (resourceSet) {
|
||||
|
||||
// look up client
|
||||
var client = this.options.clientList.getByClientId(resourceSet.get('clientId'));
|
||||
|
||||
// if there's no client ID, this is an error!
|
||||
if (client != null) {
|
||||
var view = new ResourceSetView({model: resourceSet, client: client, systemScopeList: _self.options.systemScopeList});
|
||||
view.parentView = _self;
|
||||
$('#resource-set-table', this.el).append(view.render().el);
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
this.togglePlaceholder();
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
},
|
||||
|
||||
togglePlaceholder:function() {
|
||||
if (this.model.length > 0) {
|
||||
$('#resource-set-table', this.el).show();
|
||||
$('#resource-set-table-empty', this.el).hide();
|
||||
} else {
|
||||
$('#resource-set-table', this.el).hide();
|
||||
$('#resource-set-table-empty', this.el).show();
|
||||
}
|
||||
},
|
||||
|
||||
refreshTable:function(e) {
|
||||
e.preventDefault();
|
||||
var _self = this;
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-resourcesets">' + $.t('policy.resource-sets') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
|
||||
$.when(this.model.fetch({success:function(e) {$('#loading-resourcesets').addClass('label-success');}}),
|
||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}}),
|
||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
.done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
_self.render();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
var ResourceSetView = Backbone.View.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
initialize:function(options) {
|
||||
this.options = options;
|
||||
if (!this.template) {
|
||||
this.template = _.template($('#tmpl-resource-set').html());
|
||||
}
|
||||
|
||||
if (!this.scopeTemplate) {
|
||||
this.scopeTemplate = _.template($('#tmpl-scope-list').html());
|
||||
}
|
||||
|
||||
if (!this.moreInfoTemplate) {
|
||||
this.moreInfoTemplate = _.template($('#tmpl-client-more-info-block').html());
|
||||
}
|
||||
|
||||
this.model.bind('change', this.render, this);
|
||||
},
|
||||
|
||||
render:function(eventName) {
|
||||
|
||||
var json = {rs: this.model.toJSON(), client: this.options.client.toJSON()};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scopes'), systemScopes: this.options.systemScopeList}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.options.client.toJSON()}));
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
},
|
||||
|
||||
events:{
|
||||
'click .btn-edit': 'editPolicies',
|
||||
'click .toggleMoreInformation': 'toggleMoreInformation'
|
||||
},
|
||||
|
||||
editPolicies:function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('user/policy/' + this.model.get('id'), {trigger: true});
|
||||
},
|
||||
|
||||
toggleMoreInformation:function(e) {
|
||||
e.preventDefault();
|
||||
if ($('.moreInformation', this.el).is(':visible')) {
|
||||
// hide it
|
||||
$('.moreInformation', this.el).hide('fast');
|
||||
$('.toggleMoreInformation i', this.el).attr('class', 'icon-chevron-right');
|
||||
$('.moreInformationContainer', this.el).removeClass('alert').removeClass('alert-info').addClass('muted');
|
||||
|
||||
} else {
|
||||
// show it
|
||||
$('.moreInformation', this.el).show('fast');
|
||||
$('.toggleMoreInformation i', this.el).attr('class', 'icon-chevron-down');
|
||||
$('.moreInformationContainer', this.el).addClass('alert').addClass('alert-info').removeClass('muted');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
|
@ -86,13 +86,13 @@ var WhiteListListView = Backbone.View.extend({
|
|||
_.each(this.model.models, function (whiteList) {
|
||||
|
||||
// look up client
|
||||
var client = this.options.clientList.getByClientId(whiteList.get('clientId'));
|
||||
var client = _self.options.clientList.getByClientId(whiteList.get('clientId'));
|
||||
|
||||
// if there's no client ID, this is an error!
|
||||
if (client != null) {
|
||||
var view = new WhiteListView({model: whiteList, client: client, systemScopeList: this.options.systemScopeList});
|
||||
var view = new WhiteListView({model: whiteList, client: client, systemScopeList: _self.options.systemScopeList});
|
||||
view.parentView = _self;
|
||||
$('#whitelist-table', this.el).append(view.render().el);
|
||||
$('#whitelist-table', _self.el).append(view.render().el);
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<!--
|
||||
Copyright 2015 The MITRE Corporation
|
||||
and the MIT Kerberos and Internet Trust Consortium
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- policy: resource sets and claims -->
|
||||
|
||||
<script type="text/html" id="tmpl-resource-set-table">
|
||||
<div class="well well-small">
|
||||
<button class="btn btn-small refresh-table"><i class="icon-refresh"></i> <span data-i18n="common.refresh">Refresh</span></button>
|
||||
</div>
|
||||
|
||||
<div id="resource-set-table-empty" class="alert alert-info" data-i18n="policy.policy-table.no-resource-sets">
|
||||
There are no resource sets registered. Introduce a protected to this authorization server to let it register some.
|
||||
</div>
|
||||
|
||||
<table id="resource-set-table" class="table table-hover table-striped">
|
||||
<thead>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="well well-small">
|
||||
<button class="btn btn-small refresh-table"><i class="icon-refresh"></i> <span data-i18n="common.refresh">Refresh</span></button>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="tmpl-resource-set">
|
||||
<td>
|
||||
<%- rs.name %>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span title="<%- client.clientId %>"><%- client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %></span>
|
||||
<div class="client-more-info-block"></div>
|
||||
<div class="scope-list"></div>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-edit"><i class="icon-edit"></i> <span data-i18n="policy.policy-table.edit">Edit Policies</span></button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</script>
|
||||
|
|
@ -86,7 +86,7 @@ public class ResourceSetEntityAbbreviatedView extends AbstractView {
|
|||
JsonObject o = new JsonObject();
|
||||
|
||||
o.addProperty("_id", rs.getId().toString()); // set the ID to a string
|
||||
o.addProperty("user_access_policy_uri", config.getIssuer() + "manage/policy/" + rs.getId());
|
||||
o.addProperty("user_access_policy_uri", config.getIssuer() + "manage/user/policy/" + rs.getId());
|
||||
|
||||
|
||||
gson.toJson(o, out);
|
||||
|
|
|
@ -127,14 +127,14 @@ public class ResourceSetRegistrationEndpoint {
|
|||
///////
|
||||
// TODO: REMOVE
|
||||
///////
|
||||
/*
|
||||
|
||||
Claim c = new Claim();
|
||||
c.setName("email");
|
||||
c.setValue("bob@bob.com");
|
||||
c.setIssuer(Sets.newHashSet("https://bob.com/"));
|
||||
saved.setClaimsRequired(Sets.newHashSet(c));
|
||||
saved = resourceSetService.update(saved, saved);
|
||||
*/
|
||||
|
||||
///////
|
||||
/// END: REMOVE
|
||||
///////
|
||||
|
|
Loading…
Reference in New Issue