Skip to content

Commit

Permalink
Factor out @bean FrameworkEndpointHandlerMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Syer committed Apr 15, 2014
1 parent e634d1d commit 06d140c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected void configure(HttpSecurity http) throws Exception {
}
configure(configurer);
http.apply(configurer);
String tokenEndpointPath = oauth2EndpointHandlerMapping().getPath("/oauth/token");
String tokenEndpointPath = configurer.getFrameworkEndpointHandlerMapping().getPath("/oauth/token");
// @formatter:off
http
.authorizeRequests()
Expand Down Expand Up @@ -237,7 +237,7 @@ public TokenGranter tokenGranter() throws Exception {
return authorizationServerConfigurer().getTokenGranter();
}

private AuthorizationServerSecurityConfigurer authorizationServerConfigurer() throws Exception {
protected AuthorizationServerSecurityConfigurer authorizationServerConfigurer() throws Exception {
return getHttp().getConfigurer(AuthorizationServerSecurityConfigurer.class);
}

Expand All @@ -246,11 +246,12 @@ protected static class EndpointsConfiguration {

@Autowired
private AuthorizationServerConfiguration configuration;

@PostConstruct
public void init() throws Exception {
AuthorizationEndpoint authorizationEndpoint = configuration.authorizationEndpoint();
FrameworkEndpointHandlerMapping mapping = configuration.authorizationServerConfigurer().getFrameworkEndpointHandlerMapping();
authorizationEndpoint .setUserApprovalPage(extractPath(mapping , "/oauth/confirm_access"));
authorizationEndpoint.setUserApprovalPage(extractPath(mapping , "/oauth/confirm_access"));
authorizationEndpoint.setErrorPage(extractPath(mapping, "/oauth/error"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ResourceServerConfiguration extends WebSecurityConfigurerAdapter {
private TokenStore tokenStore;

@Autowired(required = false)
private FrameworkEndpointHandlerMapping frameworkEndpointHandlerMapping;
private AuthorizationServerConfiguration authorizationServerConfiguration;

private List<ResourceServerConfigurer> configurers = Collections.emptyList();

Expand Down Expand Up @@ -94,9 +94,10 @@ private String getRequestPath(HttpServletRequest request) {
@Override
protected void configure(HttpSecurity http) throws Exception {
RequestMatcherConfigurer requests = http.requestMatchers();
if (frameworkEndpointHandlerMapping != null) {
if (authorizationServerConfiguration != null) {
// Assume we are in an Authorization Server
requests.requestMatchers(new NotOAuthRequestMatcher(frameworkEndpointHandlerMapping));
requests.requestMatchers(new NotOAuthRequestMatcher(authorizationServerConfiguration
.authorizationServerConfigurer().getFrameworkEndpointHandlerMapping()));
}
// @formatter:off
http
Expand Down

0 comments on commit 06d140c

Please sign in to comment.