Committing latest code, testing Authorization SErver
parent
d71d76c54e
commit
3f15e99475
|
@ -46,6 +46,7 @@ public class ConnectAuthCodeTokenGranter implements TokenGranter {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ClientCredentialsChecker clientCredentialsChecker;
|
private ClientCredentialsChecker clientCredentialsChecker;
|
||||||
|
|
||||||
|
//TODO: Do we need to modify/update this?
|
||||||
@Autowired
|
@Autowired
|
||||||
private DefaultOAuth2ProviderTokenService tokenServices;
|
private DefaultOAuth2ProviderTokenService tokenServices;
|
||||||
|
|
||||||
|
@ -114,12 +115,11 @@ public class ConnectAuthCodeTokenGranter implements TokenGranter {
|
||||||
throw new InvalidClientException("Client ID mismatch");
|
throw new InvalidClientException("Client ID mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Secret is not required in the authorization request, so it won't be available
|
// From SECOAUTH: Secret is not required in the authorization request, so it won't be available
|
||||||
// in the unconfirmedAuthorizationCodeAuth. We do want to check that a secret is provided
|
// in the unconfirmedAuthorizationCodeAuth. We do want to check that a secret is provided
|
||||||
// in the new request, but that happens elsewhere.
|
// in the new request, but that happens elsewhere.
|
||||||
|
|
||||||
// Similarly scopes are not required in the authorization request, so we don't make a comparison here, just
|
//Validate credentials
|
||||||
// enforce validity through the ClientCredentialsChecker
|
|
||||||
AuthorizationRequest authorizationRequest = clientCredentialsChecker.validateCredentials(grantType, clientId,
|
AuthorizationRequest authorizationRequest = clientCredentialsChecker.validateCredentials(grantType, clientId,
|
||||||
unconfirmedAuthorizationRequest.getScope());
|
unconfirmedAuthorizationRequest.getScope());
|
||||||
if (authorizationRequest == null) {
|
if (authorizationRequest == null) {
|
||||||
|
@ -130,11 +130,20 @@ public class ConnectAuthCodeTokenGranter implements TokenGranter {
|
||||||
|
|
||||||
OAuth2AccessTokenEntity token = tokenServices.createAccessToken(new OAuth2Authentication(authorizationRequest, userAuth));
|
OAuth2AccessTokenEntity token = tokenServices.createAccessToken(new OAuth2Authentication(authorizationRequest, userAuth));
|
||||||
|
|
||||||
IdToken idToken = new IdToken();
|
/**
|
||||||
|
* Authorization request scope MUST include "openid", but access token request
|
||||||
//TODO: build IdToken
|
* may or may not include the scope parameter. As long as the AuthorizationRequest
|
||||||
|
* has the proper scope, we can consider this a valid OpenID Connect request.
|
||||||
//TODO: insert IdToken into OAuth2AccessTokenEntity
|
*/
|
||||||
|
if (authorizationRequest.getScope().contains("openid")) {
|
||||||
|
IdToken idToken = new IdToken();
|
||||||
|
|
||||||
|
//TODO: build IdToken
|
||||||
|
|
||||||
|
//Where does the data for the IdToken come from?
|
||||||
|
|
||||||
|
//TODO: insert IdToken into OAuth2AccessTokenEntity
|
||||||
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:security="http://www.springframework.org/schema/security"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||||
|
|
||||||
|
@ -12,6 +14,8 @@
|
||||||
<!-- Enables the Spring MVC @Controller programming model -->
|
<!-- Enables the Spring MVC @Controller programming model -->
|
||||||
<annotation-driven />
|
<annotation-driven />
|
||||||
|
|
||||||
|
<security:global-method-security pre-post-annotations="enabled" proxy-target-class="true"/>
|
||||||
|
|
||||||
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
|
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
|
||||||
<resources mapping="/resources/**" location="/resources/" />
|
<resources mapping="/resources/**" location="/resources/" />
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:security="http://www.springframework.org/schema/security"
|
xmlns:security="http://www.springframework.org/schema/security"
|
||||||
xmlns:task="http://www.springframework.org/schema/task"
|
xmlns:task="http://www.springframework.org/schema/task"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
|
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
|
||||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
xsi:schemaLocation=
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
"http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
<import resource="data-context.xml" />
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<import resource="data-context.xml" />
|
||||||
<import resource="security-context.xml" />
|
<import resource="security-context.xml" />
|
||||||
|
|
||||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||||
|
@ -35,6 +38,13 @@
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- SECOAUTH Authorization Server, with our custom token granter plugged in -->
|
||||||
|
<oauth:authorization-server client-details-service-ref="defaultOAuth2ClientDetailsEntityService"
|
||||||
|
token-services-ref="defaultOAuth2ProviderTokenService" token-granter-ref="connectAuthCodeTokenGranter"
|
||||||
|
authorization-endpoint-url="/openidconnect/auth*">
|
||||||
|
<!-- <oauth:authorization-code disabled="true"/> -->
|
||||||
|
</oauth:authorization-server>
|
||||||
|
|
||||||
<!-- Map our custom exception classes to named views -->
|
<!-- Map our custom exception classes to named views -->
|
||||||
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||||||
<property name="exceptionMappings">
|
<property name="exceptionMappings">
|
||||||
|
|
|
@ -14,6 +14,17 @@
|
||||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
|
<!-- filter through Spring Security -->
|
||||||
|
<filter>
|
||||||
|
<filter-name>springSecurityFilterChain</filter-name>
|
||||||
|
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>springSecurityFilterChain</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- Processes application requests -->
|
<!-- Processes application requests -->
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>appServlet</servlet-name>
|
<servlet-name>appServlet</servlet-name>
|
||||||
|
@ -30,4 +41,11 @@
|
||||||
<url-pattern>/</url-pattern>
|
<url-pattern>/</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<jsp-config>
|
||||||
|
<jsp-property-group>
|
||||||
|
<url-pattern>*.jsp</url-pattern>
|
||||||
|
<trim-directive-whitespaces>true</trim-directive-whitespaces>
|
||||||
|
</jsp-property-group>
|
||||||
|
</jsp-config>
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
Loading…
Reference in New Issue