Search in sources :

Example 1 with OAuthClientAuthenticator

use of org.apereo.cas.support.oauth.authenticator.OAuthClientAuthenticator in project cas by apereo.

the class CasOAuthConfiguration method oauthSecConfig.

@RefreshScope
@Bean
public Config oauthSecConfig() {
    final CasConfiguration cfg = new CasConfiguration(casProperties.getServer().getLoginUrl());
    final CasClient oauthCasClient = new CasClient(cfg);
    oauthCasClient.setRedirectActionBuilder(webContext -> oauthCasClientRedirectActionBuilder().build(oauthCasClient, webContext));
    oauthCasClient.setName(Authenticators.CAS_OAUTH_CLIENT);
    oauthCasClient.setUrlResolver(casCallbackUrlResolver());
    final Authenticator authenticator = oAuthClientAuthenticator();
    final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(authenticator);
    basicAuthClient.setName(Authenticators.CAS_OAUTH_CLIENT_BASIC_AUTHN);
    final DirectFormClient directFormClient = new DirectFormClient(authenticator);
    directFormClient.setName(Authenticators.CAS_OAUTH_CLIENT_DIRECT_FORM);
    directFormClient.setUsernameParameter(CLIENT_ID);
    directFormClient.setPasswordParameter(CLIENT_SECRET);
    final DirectFormClient userFormClient = new DirectFormClient(oAuthUserAuthenticator());
    userFormClient.setName(Authenticators.CAS_OAUTH_CLIENT_USER_FORM);
    return new Config(OAuthUtils.casOAuthCallbackUrl(casProperties.getServer().getPrefix()), oauthCasClient, basicAuthClient, directFormClient, userFormClient);
}
Also used : DirectFormClient(org.pac4j.http.client.direct.DirectFormClient) CasConfiguration(org.pac4j.cas.config.CasConfiguration) Config(org.pac4j.core.config.Config) DirectBasicAuthClient(org.pac4j.http.client.direct.DirectBasicAuthClient) OAuthUserAuthenticator(org.apereo.cas.support.oauth.authenticator.OAuthUserAuthenticator) OAuthClientAuthenticator(org.apereo.cas.support.oauth.authenticator.OAuthClientAuthenticator) Authenticator(org.pac4j.core.credentials.authenticator.Authenticator) CasClient(org.pac4j.cas.client.CasClient) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

OAuthClientAuthenticator (org.apereo.cas.support.oauth.authenticator.OAuthClientAuthenticator)1 OAuthUserAuthenticator (org.apereo.cas.support.oauth.authenticator.OAuthUserAuthenticator)1 CasClient (org.pac4j.cas.client.CasClient)1 CasConfiguration (org.pac4j.cas.config.CasConfiguration)1 Config (org.pac4j.core.config.Config)1 Authenticator (org.pac4j.core.credentials.authenticator.Authenticator)1 DirectBasicAuthClient (org.pac4j.http.client.direct.DirectBasicAuthClient)1 DirectFormClient (org.pac4j.http.client.direct.DirectFormClient)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1