Search in sources :

Example 6 with KeycloakConfigResolver

use of org.keycloak.adapters.KeycloakConfigResolver in project shinyproxy by openanalytics.

the class KeycloakAuthenticationBackend method adapterDeploymentContext.

@Bean
@ConditionalOnProperty(name = "shiny.proxy.authentication", havingValue = "keycloak")
protected AdapterDeploymentContext adapterDeploymentContext() throws Exception {
    AdapterConfig cfg = new AdapterConfig();
    cfg.setRealm(environment.getProperty("shiny.proxy.keycloak.realm"));
    cfg.setAuthServerUrl(environment.getProperty("shiny.proxy.keycloak.auth-server-url"));
    cfg.setResource(environment.getProperty("shiny.proxy.keycloak.resource"));
    Map<String, Object> credentials = new HashMap<>();
    credentials.put("secret", environment.getProperty("shiny.proxy.keycloak.credentials-secret"));
    cfg.setCredentials(credentials);
    KeycloakDeployment dep = KeycloakDeploymentBuilder.build(cfg);
    AdapterDeploymentContextFactoryBean factoryBean = new AdapterDeploymentContextFactoryBean(new KeycloakConfigResolver() {

        @Override
        public KeycloakDeployment resolve(Request facade) {
            return dep;
        }
    });
    factoryBean.afterPropertiesSet();
    return factoryBean.getObject();
}
Also used : HashMap(java.util.HashMap) KeycloakConfigResolver(org.keycloak.adapters.KeycloakConfigResolver) AdapterConfig(org.keycloak.representations.adapters.config.AdapterConfig) KeycloakDeployment(org.keycloak.adapters.KeycloakDeployment) Request(org.keycloak.adapters.spi.HttpFacade.Request) AdapterDeploymentContextFactoryBean(org.keycloak.adapters.springsecurity.AdapterDeploymentContextFactoryBean) AdapterDeploymentContextFactoryBean(org.keycloak.adapters.springsecurity.AdapterDeploymentContextFactoryBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Aggregations

KeycloakConfigResolver (org.keycloak.adapters.KeycloakConfigResolver)6 KeycloakDeployment (org.keycloak.adapters.KeycloakDeployment)6 FileInputStream (java.io.FileInputStream)5 FileNotFoundException (java.io.FileNotFoundException)5 InputStream (java.io.InputStream)5 AdapterDeploymentContext (org.keycloak.adapters.AdapterDeploymentContext)5 NodesRegistrationManagement (org.keycloak.adapters.NodesRegistrationManagement)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)2 AuthenticationMechanism (io.undertow.security.api.AuthenticationMechanism)1 AuthenticationMechanismFactory (io.undertow.security.api.AuthenticationMechanismFactory)1 Account (io.undertow.security.idm.Account)1 Credential (io.undertow.security.idm.Credential)1 IdentityManager (io.undertow.security.idm.IdentityManager)1 FormParserFactory (io.undertow.server.handlers.form.FormParserFactory)1 InstanceFactory (io.undertow.servlet.api.InstanceFactory)1 ListenerInfo (io.undertow.servlet.api.ListenerInfo)1 ServletSessionConfig (io.undertow.servlet.api.ServletSessionConfig)1 ImmediateInstanceHandle (io.undertow.servlet.util.ImmediateInstanceHandle)1