Compare commits

..

6 Commits

4 changed files with 25 additions and 7 deletions

View File

@@ -423,3 +423,18 @@
### Features
* Add error logging for user info retrieval in OpenIDConnectService ([861f2f1](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/861f2f1184e860fdd164481167f941c11accfedd))
## (2026-01-20)
### Features
* Add idClaimName parameter to OpenIDConnectService for flexible ID claim mapping ([2f38855](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/2f388554495d8bd44b4c533baa0f2fc27eea22c2))
## (2026-01-21)
### Features
* Change log level to warn for OpenID callback in OpenIDController ([23cdbe9](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/23cdbe9bd127bc26405fd216372bbb2d7e718a77))
## (2026-01-21)
### Features
* Change log level to warn for OpenID callback in OpenIDController ([4a6598f](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/4a6598f102d8934c7502944a0addd400dd0cbcac))

View File

@@ -49,7 +49,7 @@ class OpenIDController @Inject()(
val code = request.getQueryString("code")
val error = request.getQueryString("error")
logger.info(s"Received callback from $provider with state $sessionState, nonce $sessionNonce, provider $sessionProvider, returned state $returnedState, code $code, error $error")
logger.warn(s"Received callback from $provider with state $sessionState, nonce $sessionNonce, provider $sessionProvider, returned state $returnedState, code $code, error $error")
error match {
case Some(err) =>
@@ -61,6 +61,7 @@ class OpenIDController @Inject()(
_ <- Option(sessionProvider.contains(provider))
authCode <- code
} yield {
logger.warn(s"Authentication successful for $provider")
openIDService.exchangeCodeForTokens(provider, authCode, sessionState.get).flatMap {
case Some(tokenResponse) =>
openIDService.getUserInfo(provider, tokenResponse.accessToken).flatMap {
@@ -68,7 +69,7 @@ class OpenIDController @Inject()(
// Check if user already exists
userManager.authenticateOpenID(provider, userInfo.id) match {
case Some(user) =>
logger.info(s"User ${userInfo.name} (${userInfo.id}) already exists, logging them in")
logger.warn(s"User ${userInfo.name} (${userInfo.id}) already exists, logging them in")
// User already exists, log them in
val sessionToken = sessionManager.createSession(user)
Future.successful(Redirect(config.getOptional[String]("openid.mainRoute").getOrElse("/"))
@@ -81,7 +82,7 @@ class OpenIDController @Inject()(
))
.removingFromSession("oauth_state", "oauth_nonce", "oauth_provider", "oauth_access_token"))
case None =>
logger.info(s"User ${userInfo.name} (${userInfo.id}) not found, creating new user")
logger.warn(s"User ${userInfo.name} (${userInfo.id}) not found, creating new user")
// New user, redirect to username selection
Future.successful(Redirect(config.get[String]("openid.selectUserRoute"))
.withSession(

View File

@@ -35,7 +35,8 @@ case class OpenIDProvider(
authorizationEndpoint: String,
tokenEndpoint: String,
userInfoEndpoint: String,
scopes: Set[String] = Set("openid", "profile", "email")
scopes: Set[String] = Set("openid", "profile", "email"),
idClaimName: String = "id"
)
case class TokenResponse(
@@ -70,7 +71,8 @@ class OpenIDConnectService@Inject(ws: WSClient, config: Configuration)(implicit
authorizationEndpoint = config.get[String]("openid.keycloak.authUrl") + "/protocol/openid-connect/auth",
tokenEndpoint = config.get[String]("openid.keycloak.authUrl") + "/protocol/openid-connect/token",
userInfoEndpoint = config.get[String]("openid.keycloak.authUrl") + "/protocol/openid-connect/userinfo",
scopes = Set("openid", "profile", "email")
scopes = Set("openid", "profile", "email"),
idClaimName = "sub"
)
)
@@ -136,7 +138,7 @@ class OpenIDConnectService@Inject(ws: WSClient, config: Configuration)(implicit
if (response.status == 200) {
val json = response.json
Some(OpenIDUserInfo(
id = (json \ "id").as[String],
id = (json \ provider.idClaimName).as[String],
email = (json \ "email").asOpt[String],
name = (json \ "name").asOpt[String].orElse((json \ "login").asOpt[String]),
picture = (json \ "picture").asOpt[String].orElse((json \ "avatar_url").asOpt[String]),

View File

@@ -1,3 +1,3 @@
MAJOR=4
MINOR=46
MINOR=49
PATCH=0