Skip to content

Commit

Permalink
Merge pull request #64 from ing-bank/feature/new-kecloak-conf
Browse files Browse the repository at this point in the history
Feature/new keycloak conf
  • Loading branch information
kr7ysztof authored Oct 3, 2022
2 parents dba6d6b + ae7a4a9 commit 0be02f8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ dockerCommands ++= Seq(
Cmd("ENV", "PROXY_HOST", "0.0.0.0"),
Cmd("USER", "root"),
Cmd("RUN", "apt-get update && apt-get upgrade -y"),
Cmd("USER", "1001"),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait OAuth2TokenRequest {
private def getTokenResponse(formData: Map[String, String]): Future[HttpResponse] = {
val contentType = RawHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
Http().singleRequest(HttpRequest(
uri = Uri(s"${keycloakSettings.url}/auth/realms/${keycloakSettings.realm}/protocol/openid-connect/token"),
uri = Uri(s"${keycloakSettings.url}${keycloakSettings.httpRelativePath}/realms/${keycloakSettings.realm}/protocol/openid-connect/token"),
method = HttpMethods.POST,
headers = List(contentType),
entity = akka.http.scaladsl.model.FormData(formData).toEntity))
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rokku {
clientSecret = ${?KEYCLOAK_CLIENT_SECRET}
adminUsername = ${?KEYCLOAK_ADMIN_USERNAME}
adminPassword = ${?KEYCLOAK_ADMIN_PASSWORD}

httpRelativePath = ${?KEYCLOAK_HTTP_RELATIVE_PATH}
verifyToken {
checkRealmUrl = ${?KEYCLOAK_CHECK_REALM_URL}
issuerForList = ${?KEYCLOAK_CHECK_ISSUER_FOR_LIST}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rokku {
clientSecret = "q4dHVTDyViys4T0njCSSoS5Xto4GjA12"
adminUsername = "rokkuadmin"
adminPassword = "password"
httpRelativePath = "/auth"
verifyToken {
checkRealmUrl = true
issuerForList = "sts-rokku"
Expand All @@ -33,7 +34,7 @@ redis {
host = "localhost"
port = 6379
username = "default"
password = "password"
password = "password"
}

db-dispatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class KeycloakSettings(config: Config) extends Extension {
val clientSecret: String = rokkuStsKeycloakConfig.getString("clientSecret")
val adminUsername: String = rokkuStsKeycloakConfig.getString("adminUsername")
val adminPassword: String = rokkuStsKeycloakConfig.getString("adminPassword")
val httpRelativePath: String = rokkuStsKeycloakConfig.getString("httpRelativePath") //can be removed when keyclock docker image for dev will be upgraded to version 18 or above (see https://www.keycloak.org/server/all-config#_httptls http-relative-path)
}

object KeycloakSettings extends ExtensionId[KeycloakSettings] with ExtensionIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ trait KeycloakTokenVerifier extends LazyLogging {
private[this] lazy val keycloakDeployment = {
val config = new AdapterConfig()
config.setRealm(keycloakSettings.realm)
config.setAuthServerUrl(s"${keycloakSettings.url}/auth")
config.setAuthServerUrl(s"${keycloakSettings.url}${keycloakSettings.httpRelativePath}/")
config.setSslRequired("external")
config.setResource(keycloakSettings.resource)
config.setPublicClient(true)
Expand Down

0 comments on commit 0be02f8

Please sign in to comment.