Skip to content

Commit 6e82481

Browse files
committed
OIDC: Ensure ID tokens fit into the auth_sessions.id_token column photoprism#5294
Signed-off-by: Michael Mayer <[email protected]>
1 parent d89ac51 commit 6e82481

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/api/oidc_redirect.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,14 @@ func OIDCRedirect(router *gin.RouterGroup) {
339339
sess.SetAuthID(user.AuthID, provider.Issuer())
340340
sess.SetUser(user)
341341
sess.SetGrantType(authn.GrantAuthorizationCode)
342-
sess.IdToken = tokens.IDToken
342+
343+
// Ensure that the ID token fits into the existing
344+
// database column; otherwise, truncate it.
345+
if n := len(tokens.IDToken); n > 2048 {
346+
sess.IdToken = tokens.IDToken[:2048]
347+
} else {
348+
sess.IdToken = tokens.IDToken
349+
}
343350

344351
// Set session expiration and timeout.
345352
sess.SetExpiresIn(unix.Day)

0 commit comments

Comments
 (0)