All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.gov.nationalarchives.tdr.keycloak.TdrKeycloakDeployment.scala Maven / Gradle / Ivy

Go to download

Helper classes related to Keycloak and authentication for the Transfer Digital Records service

There is a newer version: 0.0.220
Show newest version
package uk.gov.nationalarchives.tdr.keycloak

import org.keycloak.adapters.{HttpClientBuilder, KeycloakDeployment}
import org.keycloak.adapters.rotation.JWKPublicKeyLocator
import org.keycloak.representations.adapters.config.AdapterConfig

class TdrKeycloakDeployment extends KeycloakDeployment {
}

object TdrKeycloakDeployment {
  def apply(authServer: String, realm: String, ttlSeconds: Int): TdrKeycloakDeployment = {
    val keycloakDeployment = new TdrKeycloakDeployment()
    keycloakDeployment.setClient(new HttpClientBuilder().build())

    keycloakDeployment.setPublicKeyCacheTtl(ttlSeconds)

    val adaptorConfig = new AdapterConfig()
    adaptorConfig.setAuthServerUrl(authServer)
    keycloakDeployment.setAuthServerBaseUrl(adaptorConfig)

    keycloakDeployment.setRealm(realm)

    keycloakDeployment.setPublicKeyLocator(new JWKPublicKeyLocator)
    keycloakDeployment
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy