traefik plugin 0.7.7 (#73)

* Automatic discovery of the scopes.

Issue #61 raised very valid concerns about users configuring scopes that are not supported by the provider.
This change introduces automatic discovery of supported scopes by fetching the provider's discovery document and filtering out unsupported scopes.

Before:
User configures: scopes: ["openid", "profile", "email", "offline_access"]
Self-hosted GitLab: "The requested scope is invalid, unknown, or malformed"
Authentication: ❌ FAILS

After:
User configures: scopes: ["openid", "profile", "email", "offline_access"]
Middleware checks discovery doc → offline_access not supported
Automatically filters to: ["openid", "profile", "email"]
Authentication: ✅ SUCCEEDS

* Resolves issue #74 by enabling user to specify expected audience in the configuration.

* Fix flaky tests.
This commit is contained in:
2025-10-08 11:44:00 +01:00
committed by GitHub
parent 79d34ea4c9
commit bde1db1c3b
29 changed files with 3214 additions and 85 deletions
+21
View File
@@ -11,12 +11,30 @@ var (
singletonNoOpLogger *Logger
// noOpLoggerOnce ensures the singleton is created only once
noOpLoggerOnce sync.Once
// noOpLoggerMu protects access to the singleton logger during reset
noOpLoggerMu sync.RWMutex
)
// GetSingletonNoOpLogger returns the singleton no-op logger instance.
// This reduces memory allocation by reusing the same no-op logger
// instance across the entire application.
func GetSingletonNoOpLogger() *Logger {
noOpLoggerMu.RLock()
if singletonNoOpLogger != nil {
logger := singletonNoOpLogger
noOpLoggerMu.RUnlock()
return logger
}
noOpLoggerMu.RUnlock()
noOpLoggerMu.Lock()
defer noOpLoggerMu.Unlock()
// Double-check after acquiring write lock
if singletonNoOpLogger != nil {
return singletonNoOpLogger
}
noOpLoggerOnce.Do(func() {
singletonNoOpLogger = &Logger{
logError: log.New(io.Discard, "", 0),
@@ -29,6 +47,9 @@ func GetSingletonNoOpLogger() *Logger {
// ResetSingletonNoOpLogger resets the singleton instance (mainly for testing)
func ResetSingletonNoOpLogger() {
noOpLoggerMu.Lock()
defer noOpLoggerMu.Unlock()
noOpLoggerOnce = sync.Once{}
singletonNoOpLogger = nil
}