Add login and logout paths to config

This commit is contained in:
Dave Syer
2014-08-29 12:03:34 +01:00
parent 7f80f76168
commit 934e4033bb
2 changed files with 18 additions and 9 deletions

View File

@@ -165,16 +165,16 @@ public class CloudfoundrySsoConfiguration {
requests.anyRequest().authenticated();
}
http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
http.logout().logoutRequestMatcher(new AntPathRequestMatcher(sso.getLogoutPath()))
.addLogoutHandler(logoutHandler());
http.exceptionHandling().authenticationEntryPoint(
new LoginUrlAuthenticationEntryPoint("/login"));
new LoginUrlAuthenticationEntryPoint(sso.getLoginPath()));
}
protected OAuth2ClientAuthenticationProcessingFilter cloudfoundrySsoFilter() {
OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
"/login");
sso.getLoginPath());
filter.setRestTemplate(restTemplate);
filter.setTokenServices(tokenServices());
return filter;
@@ -195,7 +195,7 @@ public class CloudfoundrySsoConfiguration {
HttpServletResponse response, Authentication authentication) {
restTemplate.getOAuth2ClientContext().setAccessToken(null);
String redirect = request.getRequestURL().toString()
.replace("/logout", sso.getHome().getPath());
.replace(sso.getLogoutPath(), sso.getHome().getPath());
try {
response.sendRedirect(sso.getLogoutUri(redirect));
}

View File

@@ -31,19 +31,28 @@ import org.springframework.validation.Validator;
@Data
public class CloudfoundrySsoProperties implements Validator {
@Value("${vcap.services.sso.credentials.tokenUri:}")
private String serviceId = "sso";
private String logoutPath = "/logout";
private String loginPath = "/login";
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.tokenUri:}")
private String tokenUri;
@Value("${vcap.services.sso.credentials.tokenInfoUri:}")
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.userInfoUri:}")
private String userInfoUri;
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.tokenInfoUri:}")
private String tokenInfoUri;
@Value("${vcap.services.sso.credentials.authorizationUri:}")
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.authorizationUri:}")
private String authorizationUri;
@Value("${vcap.services.sso.credentials.clientId:}")
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.clientId:}")
private String clientId;
@Value("${vcap.services.sso.credentials.clientSecret:}")
@Value("${vcap.services.${cloudfoundry.sso.serviceId:sso}.credentials.clientSecret:}")
private String clientSecret;
private Home home = new Home();