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? 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) { public SystemScope(String value) {
this.value = value; this.value = value;

View File

@ -20,9 +20,12 @@ package org.mitre.oauth2.web;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.mitre.oauth2.exception.ClientNotFoundException; import org.mitre.oauth2.exception.ClientNotFoundException;
import org.mitre.oauth2.model.SystemScope;
import org.mitre.oauth2.service.ClientDetailsEntityService; import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.mitre.oauth2.service.SystemScopeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.oauth2.provider.AuthorizationRequest; import org.springframework.security.oauth2.provider.AuthorizationRequest;
@ -44,6 +47,9 @@ public class OAuthConfirmationController {
@Autowired @Autowired
private ClientDetailsEntityService clientService; private ClientDetailsEntityService clientService;
@Autowired
private SystemScopeService scopeService;
public OAuthConfirmationController() { public OAuthConfirmationController() {
} }
@ -71,12 +77,17 @@ public class OAuthConfirmationController {
String redirect_uri = clientAuth.getAuthorizationParameters().get("redirect_uri"); String redirect_uri = clientAuth.getAuthorizationParameters().get("redirect_uri");
model.put("redirect_uri", redirect_uri); model.put("redirect_uri", redirect_uri);
/*
Map<String, Boolean> scopes = new HashMap<String, Boolean>(); Map<String, Boolean> scopes = new HashMap<String, Boolean>();
for (String scope : clientAuth.getScope()) { for (String scope : clientAuth.getScope()) {
scopes.put(scope, Boolean.TRUE); scopes.put(scope, Boolean.TRUE);
} }
*/
Set<SystemScope> scopes = scopeService.fromStrings(client.getScope());
model.put("scopes", scopes); model.put("scopes", scopes);
return new ModelAndView("oauth/approve", model); 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/clients">Manage Clients</a></li>
<li><a href="manage/#admin/whitelists">Whitelisted 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/blacklist">Blacklisted Clients</a></li>
<li><a href="manage/#admin/scope">System Scopes</a></li>
</security:authorize> </security:authorize>
<li class="nav-header">Personal</li> <li class="nav-header">Personal</li>
<li><a href="manage/#user/approved">Manage Sites</a></li> <li><a href="manage/#user/approved">Manage Sites</a></li>

View File

@ -24,7 +24,7 @@
<div class="well" style="text-align:center"> <div class="well" style="text-align:center">
<h1>Approve New Site</h1> <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="row">
<div class="span4 offset2 well-small" style="text-align:left"> <div class="span4 offset2 well-small" style="text-align:left">
@ -38,17 +38,13 @@
</div> </div>
</c:if> </c:if>
<c:choose> <c:if test="${ not empty client.logoUrl }">
<c:when test="${empty client.logoUrl }"> <ul class="thumbnails">
</c:when> <li class="span4">
<c:otherwise> <div class="thumbnail"><img src="${client.logoUrl }"/></div>
<ul class="thumbnails"> </li>
<li class="span4"> </ul>
<div class="thumbnail"><img src="${client.logoUrl }"/></div> </c:if>
</li>
</ul>
</c:otherwise>
</c:choose>
Do you authorize Do you authorize
"<c:choose> "<c:choose>
<c:when test="${empty client.clientName}"> <c:when test="${empty client.clientName}">
@ -85,6 +81,27 @@
<fieldset style="text-align:left" class="well"> <fieldset style="text-align:left" class="well">
<legend style="margin-bottom: 0;">Access to:</legend> <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"/> <input type="hidden" name="scope_openid" id="scope_openid" value="openid"/>
<c:if test="${not empty scopes['profile']}"> <c:if test="${not empty scopes['profile']}">
@ -122,6 +139,8 @@
</label> </label>
</c:if> </c:if>
-->
</fieldset> </fieldset>
<fieldset style="text-align:left" class="well"> <fieldset style="text-align:left" class="well">