From 5d77c0e1d0b8d0dc3af0465cc3474e3397cb14f1 Mon Sep 17 00:00:00 2001 From: Krzysztof Zmij Date: Mon, 24 Jul 2023 14:09:36 +0200 Subject: [PATCH] test --- src/main/resources/application.conf | 2 +- src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala | 6 +++++- .../ing/wbaa/rokku/sts/keycloak/KeycloakTokenVerifier.scala | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index de5d5ab..1120541 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -37,7 +37,7 @@ rokku { defaultTokenSessionHours = ${?STS_DEFAULT_TOKEN_SESSION_HOURS} maxTokenSessionHours = ${?STS_MAX_TOKEN_SESSION_HOURS} - maxTokenSessionForNPAHours = ${?STS_MAX_TOKEN_SESSION_HOURS} + maxTokenSessionForNPAHours = ${?STS_MAX_TOKEN_SESSION_FOR_NPA_HOURS} # at least 32 bytes long. Make sure you set your own random key masterKey = ${?STS_MASTER_KEY} encryptionAlgorithm = ${?STS_ENCRYPTION_ALGORITHM} diff --git a/src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala b/src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala index 629ac41..ba61479 100644 --- a/src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala +++ b/src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala @@ -25,12 +25,16 @@ trait STSApi extends LazyLogging with TokenXML { private def parseDurationSeconds(aui: AuthenticationUserInfo, durationSeconds: Option[Int]): Duration = { val maxTokenSession = if (aui.isNPA) stsSettings.maxTokenSessionForNPADuration else stsSettings.maxTokenSessionDuration val durationRequested = durationSeconds.map(ds => Duration(ds, TimeUnit.SECONDS)) - durationRequested match { + val d = durationRequested match { case None => stsSettings.defaultTokenSessionDuration case Some(durationRequested) => if (durationRequested > maxTokenSession) maxTokenSession else durationRequested } + logger.info("stsSettings.maxTokenSessionForNPADuration {}", stsSettings.maxTokenSessionForNPADuration) + logger.info("stsSettings.maxTokenSessionDuration {}", stsSettings.maxTokenSessionDuration) + logger.info("durationRequested", durationRequested) + d } private def getSessionTokenInputs(aui: AuthenticationUserInfo) = { diff --git a/src/main/scala/com/ing/wbaa/rokku/sts/keycloak/KeycloakTokenVerifier.scala b/src/main/scala/com/ing/wbaa/rokku/sts/keycloak/KeycloakTokenVerifier.scala index 853e8e4..79493b0 100644 --- a/src/main/scala/com/ing/wbaa/rokku/sts/keycloak/KeycloakTokenVerifier.scala +++ b/src/main/scala/com/ing/wbaa/rokku/sts/keycloak/KeycloakTokenVerifier.scala @@ -23,6 +23,8 @@ trait KeycloakTokenVerifier extends LazyLogging { import scala.jdk.CollectionConverters._ private def isNPA(keycloakToken: AccessToken): Boolean = { + logger.info("user getName={}", keycloakToken.getName) + logger.info("is NPA={}", keycloakToken.getName == "NPA NPA") keycloakToken.getName == "NPA NPA" }