mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-12 04:04:26 +00:00
- [x] Reorganize golangci-lint configuration with documented disable reasons - [x] Simplify errcheck and revive linter rules with targeted exclusions - [x] Pre-compile regex patterns in input_validation.go for performance - [x] Fix type assertions in memory_shard.go and resp.go with safety checks - [x] Replace string comparison with EqualFold for case-insensitive matching - [x] Fix loop variable captures in jwk.go and logout.go - [x] Change high goroutine log level from Info to Debug in autocleanup.go - [x] Replace deprecated "cancelled" spelling with "canceled" throughout - [x] Add nolint annotations for intentional unused parameters - [x] Improve comment formatting for deprecated functions - [x] Fix comment spelling: "marshalling" → "marshaling" - [x] Refactor provider warnings formatting in internal/providers/warnings.go - [x] Simplify metrics summary building in internal/recovery/metrics.go - [x] Pre-allocate slice in error_recovery.go GetDegradedServices - [x] Refactor context cancellation checks in redis.go
75 lines
2.1 KiB
Go
75 lines
2.1 KiB
Go
package providers
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// AWSCognitoProvider encapsulates AWS Cognito-specific OIDC logic.
|
|
type AWSCognitoProvider struct {
|
|
*BaseProvider
|
|
}
|
|
|
|
// NewAWSCognitoProvider creates a new instance of the AWSCognitoProvider.
|
|
func NewAWSCognitoProvider() *AWSCognitoProvider {
|
|
return &AWSCognitoProvider{
|
|
BaseProvider: NewBaseProvider(),
|
|
}
|
|
}
|
|
|
|
// GetType returns the provider's type.
|
|
func (p *AWSCognitoProvider) GetType() ProviderType {
|
|
return ProviderTypeAWSCognito
|
|
}
|
|
|
|
// GetCapabilities returns the specific capabilities of the AWS Cognito provider.
|
|
func (p *AWSCognitoProvider) GetCapabilities() ProviderCapabilities {
|
|
return ProviderCapabilities{
|
|
SupportsRefreshTokens: true,
|
|
RequiresOfflineAccessScope: false, // Cognito doesn't use offline_access scope
|
|
RequiresPromptConsent: false,
|
|
PreferredTokenValidation: "id", // Cognito typically uses ID tokens
|
|
}
|
|
}
|
|
|
|
// BuildAuthParams configures AWS Cognito-specific authentication parameters.
|
|
func (p *AWSCognitoProvider) BuildAuthParams(baseParams url.Values, scopes []string) (*AuthParams, error) {
|
|
// AWS Cognito supports standard OIDC parameters
|
|
baseParams.Set("response_type", "code")
|
|
|
|
// Remove offline_access scope as Cognito doesn't use it (case-insensitive)
|
|
var filteredScopes []string
|
|
for _, scope := range scopes {
|
|
if !strings.EqualFold(scope, ScopeOfflineAccess) {
|
|
filteredScopes = append(filteredScopes, scope)
|
|
}
|
|
}
|
|
|
|
// Ensure openid scope is present
|
|
hasOpenID := false
|
|
for _, scope := range filteredScopes {
|
|
if scope == ScopeOpenID {
|
|
hasOpenID = true
|
|
break
|
|
}
|
|
}
|
|
if !hasOpenID {
|
|
filteredScopes = append(filteredScopes, ScopeOpenID)
|
|
}
|
|
|
|
// Default Cognito scopes if none specified
|
|
if len(filteredScopes) == 1 && filteredScopes[0] == ScopeOpenID {
|
|
filteredScopes = append(filteredScopes, ScopeEmail, ScopeProfile)
|
|
}
|
|
|
|
return &AuthParams{
|
|
URLValues: baseParams,
|
|
Scopes: deduplicateScopes(filteredScopes),
|
|
}, nil
|
|
}
|
|
|
|
// AWS Cognito requires user pool and domain configuration.
|
|
func (p *AWSCognitoProvider) ValidateConfig() error {
|
|
return p.BaseProvider.ValidateConfig()
|
|
}
|