beginning dynamic scopes on auth page

pull/306/merge
Justin Richer 2013-02-05 11:28:39 -05:00
parent c2b9fd4db1
commit eb4773ce46
4 changed files with 54 additions and 15 deletions

View File

@ -33,7 +33,15 @@ public class SystemScope {
private boolean defaultScope = false; // is this a default scope for newly-registered clients?
/**
* @param input
* Make a blank system scope with no value
*/
public SystemScope() {
}
/**
* Make a system scope with the given scope value
* @param value
*/
public SystemScope(String value) {
this.value = value;

View File

@ -20,9 +20,12 @@ package org.mitre.oauth2.web;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.mitre.oauth2.exception.ClientNotFoundException;
import org.mitre.oauth2.model.SystemScope;
import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.mitre.oauth2.service.SystemScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
@ -44,6 +47,9 @@ public class OAuthConfirmationController {
@Autowired
private ClientDetailsEntityService clientService;
@Autowired
private SystemScopeService scopeService;
public OAuthConfirmationController() {
}
@ -71,12 +77,17 @@ public class OAuthConfirmationController {
String redirect_uri = clientAuth.getAuthorizationParameters().get("redirect_uri");
model.put("redirect_uri", redirect_uri);
/*
Map<String, Boolean> scopes = new HashMap<String, Boolean>();
for (String scope : clientAuth.getScope()) {
scopes.put(scope, Boolean.TRUE);
}
*/
Set<SystemScope> scopes = scopeService.fromStrings(client.getScope());
model.put("scopes", scopes);
return new ModelAndView("oauth/approve", model);

View File

@ -10,6 +10,7 @@
<li><a href="manage/#admin/clients">Manage Clients</a></li>
<li><a href="manage/#admin/whitelists">Whitelisted Clients</a></li>
<li><a href="manage/#admin/blacklist">Blacklisted Clients</a></li>
<li><a href="manage/#admin/scope">System Scopes</a></li>
</security:authorize>
<li class="nav-header">Personal</li>
<li><a href="manage/#user/approved">Manage Sites</a></li>

View File

@ -24,7 +24,7 @@
<div class="well" style="text-align:center">
<h1>Approve New Site</h1>
<form name="confirmationForm" style="display:inline" action="<%=request.getContextPath()%>/authorize" method="post">
<form name="confirmationForm" action="<%=request.getContextPath()%>/authorize" method="post">
<div class="row">
<div class="span4 offset2 well-small" style="text-align:left">
@ -38,17 +38,13 @@
</div>
</c:if>
<c:choose>
<c:when test="${empty client.logoUrl }">
</c:when>
<c:otherwise>
<ul class="thumbnails">
<li class="span4">
<div class="thumbnail"><img src="${client.logoUrl }"/></div>
</li>
</ul>
</c:otherwise>
</c:choose>
<c:if test="${ not empty client.logoUrl }">
<ul class="thumbnails">
<li class="span4">
<div class="thumbnail"><img src="${client.logoUrl }"/></div>
</li>
</ul>
</c:if>
Do you authorize
"<c:choose>
<c:when test="${empty client.clientName}">
@ -85,6 +81,27 @@
<fieldset style="text-align:left" class="well">
<legend style="margin-bottom: 0;">Access to:</legend>
<c:forEach var="scope" items="${ scopes }">
<label for="scope_${ scope.value }" class="checkbox">
<input type="checkbox" name="scope_${ scope.value }" id="scope_${ scope.value }" value="${ scope.value }" checked="checked">
<c:if test="${ not empty scope.icon }">
<i class="icon-${ scope.icon }"></i>
</c:if>
<c:choose>
<c:when test="${ not empty scope.description }">
${ scope.description }
</c:when>
<c:otherwise>
${ scope.value }
</c:otherwise>
</c:choose>
</label>
</c:forEach>
<!--
<input type="hidden" name="scope_openid" id="scope_openid" value="openid"/>
<c:if test="${not empty scopes['profile']}">
@ -122,6 +139,8 @@
</label>
</c:if>
-->
</fieldset>
<fieldset style="text-align:left" class="well">