Merge branch 'master' into userInfoEndpoint

pull/105/merge
Stephen Moore 2012-05-24 13:06:29 -04:00
commit c418ccabb1
7 changed files with 29 additions and 7 deletions

View File

@ -5,7 +5,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<dependent-module archiveName="openid-connect-common-0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/openid-connect-common/openid-connect-common">
<dependent-module archiveName="spring-security-oauth2-1.0.0.BUILD-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/spring-security-oauth2-MITRE/spring-security-oauth2-MITRE">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="openid-connect-common-0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/openid-connect-common-MITRE/openid-connect-common-MITRE">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/openid/target/classes"/>

View File

@ -22,6 +22,8 @@ import org.mitre.oauth2.exception.ClientNotFoundException;
import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.stereotype.Controller;

View File

@ -77,6 +77,7 @@ public class JSONUserInfoView extends AbstractView{
obj.addProperty("email", ui.getEmail());
obj.addProperty("profile", ui.getProfile());
obj.addProperty("picture", ui.getPicture());
obj.addProperty("email", ui.getEmail());
obj.addProperty("website", ui.getWebsite());
obj.addProperty("verified", ui.getVerified());
obj.addProperty("gender", ui.getGender());
@ -85,7 +86,8 @@ public class JSONUserInfoView extends AbstractView{
obj.addProperty("phone_number", ui.getPhoneNumber());
obj.addProperty("updated_time", ui.getUpdatedTime());
if(ui.getAddress() != null) {
if (ui.getAddress() != null) {
JsonObject addr = new JsonObject();
addr.addProperty("formatted", ui.getAddress().getFormatted());
addr.addProperty("street_address", ui.getAddress().getStreetAddress());
@ -96,7 +98,8 @@ public class JSONUserInfoView extends AbstractView{
obj.add("address", addr);
}
return obj;
}
}

View File

@ -25,6 +25,9 @@ import org.mitre.openid.connect.exception.InvalidJwtSignatureException;
import org.mitre.openid.connect.model.IdToken;
import org.mitre.util.Utility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -39,9 +42,12 @@ public class CheckIDEndpoint {
@Autowired
private ConfigurationPropertiesBean configBean;
@PreAuthorize("hasRole('ROLE_USER')")
@RequestMapping("/checkid")
public ModelAndView checkID(@RequestParam("access_token") String tokenString, ModelAndView mav, HttpServletRequest request) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!jwtSignerService.validateSignature(tokenString)) {
// can't validate
throw new InvalidJwtSignatureException(); // TODO: attach a view to this exception

View File

@ -30,6 +30,9 @@
<import resource="data-context.xml" />
<!-- Spring Security configuration -->
<oauth:resource-server id="resourceServerFilter" token-services-ref="defaultOAuth2ProviderTokenService" />
<security:http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="clientAuthenticationManager"
entry-point-ref="oauthAuthenticationEntryPoint">
<security:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
@ -75,7 +78,7 @@
<!-- user services -->
<import resource="user-context.xml" />
<!-- End Spring Security configuration -->
<!-- JPA -->

View File

@ -32,6 +32,7 @@
<security:http auto-config="true" disable-url-rewriting="true"> <!-- authentication-manager-ref="springSecurityAuthenticationManager" -->
<security:intercept-url pattern="/oauth/**" access="ROLE_USER" />
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
<security:anonymous />
</security:http>

View File

@ -1,4 +1,7 @@
<script type="text/html" id="tmpl-client">
<td>
<%=clientId%>
</td>
<td>
<%=clientName%>
@ -55,6 +58,7 @@
<table id="client-table" class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Redirect URI(s)</th>
<th>Grant Types</th>
@ -83,7 +87,7 @@
<div class="">
<form>
<fieldset>
<legend>Details</legend>
<legend>Details <%=(clientId != null ? 'for ' + clientId : '')%></legend>
<div class="well">
@ -158,7 +162,7 @@
<input type="text" class="" value="<%=accessTokenTimeout%>" id="access-token-timeout-seconds" size="16"><span
class="add-on">seconds</span>
</div>
<span class="help-inline">Here's more help text</span>
<span class="help-inline">Enter this time in seconds</span>
</div>
</span>
<span class="control-group" id="refreshTokenTimeout">
@ -170,7 +174,7 @@
<input type="text" class="" value="<%=refreshTokenTimeout%>" id="refresh-token-timeout-seconds" size="16"><span
class="add-on">seconds</span>
</div>
<span class="help-inline">Here's more help text</span>
<span class="help-inline">Enter this time in seconds</span>
</div>
</span>
</div>