Search in sources :

Example 16 with OidcConfiguration

use of org.pac4j.oidc.config.OidcConfiguration in project cas by apereo.

the class DefaultDelegatedClientAuthenticationWebflowManagerTests method verifyOidcStoreOperation.

@Test
public void verifyOidcStoreOperation() throws Exception {
    val config = new OidcConfiguration();
    config.setClientId(UUID.randomUUID().toString());
    config.setSecret(UUID.randomUUID().toString());
    val client = new OidcClient(config);
    client.setConfiguration(config);
    val ticket = delegatedClientAuthenticationWebflowManager.store(context, client);
    assertNotNull(ticketRegistry.getTicket(ticket.getId()));
    val service = delegatedClientAuthenticationWebflowManager.retrieve(requestContext, context, client);
    assertNotNull(service);
    assertNull(ticketRegistry.getTicket(ticket.getId()));
}
Also used : lombok.val(lombok.val) OidcConfiguration(org.pac4j.oidc.config.OidcConfiguration) OidcClient(org.pac4j.oidc.client.OidcClient) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with OidcConfiguration

use of org.pac4j.oidc.config.OidcConfiguration in project ddf by codice.

the class OidcHandlerConfigurationImplTest method testCreateOidcConfigurationAzure.

@Test
public void testCreateOidcConfigurationAzure() {
    OidcConfiguration oidcConfiguration = handlerConfiguration.createOidcConfiguration("Azure", "master", "https://base/uri");
    assertTrue(oidcConfiguration instanceof AzureAdOidcConfiguration);
    assertThat(((AzureAdOidcConfiguration) oidcConfiguration).getTenant(), is("master"));
}
Also used : OidcConfiguration(org.pac4j.oidc.config.OidcConfiguration) AzureAdOidcConfiguration(org.pac4j.oidc.config.AzureAdOidcConfiguration) KeycloakOidcConfiguration(org.pac4j.oidc.config.KeycloakOidcConfiguration) AzureAdOidcConfiguration(org.pac4j.oidc.config.AzureAdOidcConfiguration) Test(org.junit.Test)

Example 18 with OidcConfiguration

use of org.pac4j.oidc.config.OidcConfiguration in project ddf by codice.

the class OidcHandlerConfigurationImplTest method testCreateOidcConfigurationKeycloak.

@Test
public void testCreateOidcConfigurationKeycloak() {
    OidcConfiguration oidcConfiguration = handlerConfiguration.createOidcConfiguration("Keycloak", "master", "https://base/uri");
    assertTrue(oidcConfiguration instanceof KeycloakOidcConfiguration);
    assertThat(((KeycloakOidcConfiguration) oidcConfiguration).getRealm(), is("master"));
    assertThat(((KeycloakOidcConfiguration) oidcConfiguration).getBaseUri(), is("https://base/uri"));
}
Also used : OidcConfiguration(org.pac4j.oidc.config.OidcConfiguration) AzureAdOidcConfiguration(org.pac4j.oidc.config.AzureAdOidcConfiguration) KeycloakOidcConfiguration(org.pac4j.oidc.config.KeycloakOidcConfiguration) KeycloakOidcConfiguration(org.pac4j.oidc.config.KeycloakOidcConfiguration) Test(org.junit.Test)

Example 19 with OidcConfiguration

use of org.pac4j.oidc.config.OidcConfiguration in project druid by druid-io.

the class Pac4jAuthenticator method createPac4jConfig.

private Config createPac4jConfig(OIDCConfig oidcConfig) {
    OidcConfiguration oidcConf = new OidcConfiguration();
    oidcConf.setClientId(oidcConfig.getClientID());
    oidcConf.setSecret(oidcConfig.getClientSecret().getPassword());
    oidcConf.setDiscoveryURI(oidcConfig.getDiscoveryURI());
    oidcConf.setExpireSessionWithToken(true);
    oidcConf.setUseNonce(true);
    oidcConf.setReadTimeout(Ints.checkedCast(pac4jCommonConfig.getReadTimeout().getMillis()));
    oidcConf.setResourceRetriever(// ResourceRetriever is used to get Auth server configuration from "discoveryURI"
    new CustomSSLResourceRetriever(pac4jCommonConfig.getReadTimeout().getMillis(), sslSocketFactory));
    OidcClient oidcClient = new OidcClient(oidcConf);
    oidcClient.setUrlResolver(new DefaultUrlResolver(true));
    oidcClient.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
    // This is used by OidcClient in various places to make HTTPrequests.
    if (sslSocketFactory != null) {
        HTTPRequest.setDefaultSSLSocketFactory(sslSocketFactory);
    }
    return new Config(Pac4jCallbackResource.SELF_URL, oidcClient);
}
Also used : OidcConfiguration(org.pac4j.oidc.config.OidcConfiguration) OidcClient(org.pac4j.oidc.client.OidcClient) Config(org.pac4j.core.config.Config) DefaultUrlResolver(org.pac4j.core.http.url.DefaultUrlResolver) NoParameterCallbackUrlResolver(org.pac4j.core.http.callback.NoParameterCallbackUrlResolver)

Aggregations

OidcConfiguration (org.pac4j.oidc.config.OidcConfiguration)19 OidcClient (org.pac4j.oidc.client.OidcClient)13 AzureAdOidcConfiguration (org.pac4j.oidc.config.AzureAdOidcConfiguration)8 GoogleOidcClient (org.pac4j.oidc.client.GoogleOidcClient)7 KeycloakOidcConfiguration (org.pac4j.oidc.config.KeycloakOidcConfiguration)7 Test (org.junit.Test)5 AzureAdClient (org.pac4j.oidc.client.AzureAdClient)4 KeycloakOidcClient (org.pac4j.oidc.client.KeycloakOidcClient)4 Verb (com.github.scribejava.core.model.Verb)2 JWSAlgorithm (com.nimbusds.jose.JWSAlgorithm)2 OIDCProviderMetadata (com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata)2 Collection (java.util.Collection)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 StringUtils (org.apache.commons.lang3.StringUtils)2 OidcAuthenticationToken (org.codice.ddf.security.handler.OidcAuthenticationToken)2 TechnicalException (org.pac4j.core.exception.TechnicalException)2 OidcCredentials (org.pac4j.oidc.credentials.OidcCredentials)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1