mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-13 04:07:37 +00:00
Fix for Hashicorp Vault - accept opaque access tokens with dot-characters (#113)
This commit is contained in:
+1
-12
@@ -1820,23 +1820,12 @@ func (sd *SessionData) SetAccessToken(token string) {
|
|||||||
defer sd.sessionMutex.Unlock()
|
defer sd.sessionMutex.Unlock()
|
||||||
|
|
||||||
if token != "" {
|
if token != "" {
|
||||||
dotCount := strings.Count(token, ".")
|
if len(token) < 20 {
|
||||||
// Reject tokens with exactly 1 dot (invalid format - neither JWT nor opaque)
|
|
||||||
if dotCount == 1 {
|
|
||||||
if sd.manager != nil && sd.manager.logger != nil {
|
|
||||||
sd.manager.logger.Debug("Invalid token format during storage (dots: %d) - rejecting", dotCount)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// For opaque tokens (no dots), ensure minimum length for security
|
|
||||||
if dotCount == 0 && len(token) < 20 {
|
|
||||||
if sd.manager != nil && sd.manager.logger != nil {
|
if sd.manager != nil && sd.manager.logger != nil {
|
||||||
sd.manager.logger.Debug("Token too short for opaque token (length: %d) - rejecting", len(token))
|
sd.manager.logger.Debug("Token too short for opaque token (length: %d) - rejecting", len(token))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Tokens with 2 dots are JWTs, tokens with 0 dots are opaque
|
|
||||||
// Both are valid formats
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAccessToken := sd.getAccessTokenUnsafe()
|
currentAccessToken := sd.getAccessTokenUnsafe()
|
||||||
|
|||||||
Reference in New Issue
Block a user