Search in sources :

Example 1 with DefaultRedirectResolver

use of org.springframework.security.oauth2.provider.endpoint.DefaultRedirectResolver in project powerauth-webflow by wultra.

the class OAuth2AuthorizationServerConfiguration method configureAuthorizationEndpoint.

/**
 * Configures authorization endpoint.
 * @param authorizationEndpoint Authorization endpoint.
 */
@Autowired
public void configureAuthorizationEndpoint(AuthorizationEndpoint authorizationEndpoint) {
    // WORKAROUND: Cancel the session just before the redirect
    DefaultRedirectResolver redirectResolver = new DefaultRedirectResolver() {

        @Override
        public String resolveRedirect(String requestedRedirect, ClientDetails client) throws OAuth2Exception {
            SecurityContextHolder.clearContext();
            return super.resolveRedirect(requestedRedirect, client);
        }
    };
    redirectResolver.setMatchPorts(false);
    authorizationEndpoint.setRedirectResolver(redirectResolver);
}
Also used : DefaultRedirectResolver(org.springframework.security.oauth2.provider.endpoint.DefaultRedirectResolver) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 2 with DefaultRedirectResolver

use of org.springframework.security.oauth2.provider.endpoint.DefaultRedirectResolver in project spring-security-oauth by spring-projects.

the class DefaultRedirectResolverTests method setup.

@Before
public void setup() {
    client = new BaseClientDetails();
    client.setAuthorizedGrantTypes(Collections.singleton("authorization_code"));
    resolver = new DefaultRedirectResolver();
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Before(org.junit.Before)

Example 3 with DefaultRedirectResolver

use of org.springframework.security.oauth2.provider.endpoint.DefaultRedirectResolver in project spring-security-oauth by spring-projects.

the class AuthorizationEndpointTests method init.

@Before
public void init() throws Exception {
    client = new BaseClientDetails();
    client.setRegisteredRedirectUri(Collections.singleton("https://anywhere.com"));
    client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "implicit"));
    endpoint.setClientDetailsService(new ClientDetailsService() {

        public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
            return client;
        }
    });
    endpoint.setTokenGranter(new TokenGranter() {

        public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
            return null;
        }
    });
    endpoint.setRedirectResolver(new DefaultRedirectResolver());
    endpoint.afterPropertiesSet();
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) TokenGranter(org.springframework.security.oauth2.provider.TokenGranter) DefaultOAuth2AccessToken(org.springframework.security.oauth2.common.DefaultOAuth2AccessToken) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) TokenRequest(org.springframework.security.oauth2.provider.TokenRequest) ClientDetailsService(org.springframework.security.oauth2.provider.ClientDetailsService) OAuth2Exception(org.springframework.security.oauth2.common.exceptions.OAuth2Exception) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 ClientDetails (org.springframework.security.oauth2.provider.ClientDetails)2 BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)2 Autowired (org.springframework.beans.factory.annotation.Autowired)1 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)1 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)1 OAuth2Exception (org.springframework.security.oauth2.common.exceptions.OAuth2Exception)1 ClientDetailsService (org.springframework.security.oauth2.provider.ClientDetailsService)1 TokenGranter (org.springframework.security.oauth2.provider.TokenGranter)1 TokenRequest (org.springframework.security.oauth2.provider.TokenRequest)1 DefaultRedirectResolver (org.springframework.security.oauth2.provider.endpoint.DefaultRedirectResolver)1