mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-06-06 22:49:43 +00:00
e64fc7f730
* Add redis support for distributed caching * Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * ... and another all nighter. * fixup! ... and another all nighter. * fixup! fixup! ... and another all nighter. * fixup! fixup! fixup! ... and another all nighter. * Resolve issue #85 by adding ability to set custom claims in JWT tokens * Remove redundant validation in auth middleware ( issue #89 ) * Add ability to set cookie prefix for session cookies ( #87 ) * fixup! Add ability to set cookie prefix for session cookies ( #87 ) * Add ability to set cookie max age - issue #91 * Potential fix for code scanning alert no. 10: Size computation for allocation may overflow Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fixup! Merge main into 0.8.0-redis: resolve conflicts --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
package providers
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
// GitLabProvider encapsulates GitLab-specific OIDC logic.
|
|
type GitLabProvider struct {
|
|
*BaseProvider
|
|
}
|
|
|
|
// NewGitLabProvider creates a new instance of the GitLabProvider.
|
|
func NewGitLabProvider() *GitLabProvider {
|
|
return &GitLabProvider{
|
|
BaseProvider: NewBaseProvider(),
|
|
}
|
|
}
|
|
|
|
// GetType returns the provider's type.
|
|
func (p *GitLabProvider) GetType() ProviderType {
|
|
return ProviderTypeGitLab
|
|
}
|
|
|
|
// GetCapabilities returns the specific capabilities of the GitLab provider.
|
|
func (p *GitLabProvider) GetCapabilities() ProviderCapabilities {
|
|
return ProviderCapabilities{
|
|
SupportsRefreshTokens: true,
|
|
RequiresOfflineAccessScope: false, // GitLab doesn't use offline_access scope
|
|
RequiresPromptConsent: false,
|
|
PreferredTokenValidation: "id", // GitLab typically uses ID tokens
|
|
}
|
|
}
|
|
|
|
// BuildAuthParams configures GitLab-specific authentication parameters.
|
|
func (p *GitLabProvider) BuildAuthParams(baseParams url.Values, scopes []string) (*AuthParams, error) {
|
|
// GitLab supports standard OAuth 2.0 parameters
|
|
baseParams.Set("response_type", "code")
|
|
|
|
// Remove offline_access scope as GitLab doesn't use it
|
|
var filteredScopes []string
|
|
for _, scope := range scopes {
|
|
if scope != ScopeOfflineAccess {
|
|
filteredScopes = append(filteredScopes, scope)
|
|
}
|
|
}
|
|
|
|
// Ensure openid scope is present for OIDC
|
|
hasOpenID := false
|
|
for _, scope := range filteredScopes {
|
|
if scope == ScopeOpenID {
|
|
hasOpenID = true
|
|
break
|
|
}
|
|
}
|
|
if !hasOpenID {
|
|
filteredScopes = append(filteredScopes, ScopeOpenID)
|
|
}
|
|
|
|
// Default GitLab scopes if none specified
|
|
if len(filteredScopes) == 1 && filteredScopes[0] == ScopeOpenID {
|
|
filteredScopes = append(filteredScopes, ScopeProfile, ScopeEmail)
|
|
}
|
|
|
|
return &AuthParams{
|
|
URLValues: baseParams,
|
|
Scopes: deduplicateScopes(filteredScopes),
|
|
}, nil
|
|
}
|
|
|
|
// GitLab requires application configuration and proper redirect URIs.
|
|
func (p *GitLabProvider) ValidateConfig() error {
|
|
return p.BaseProvider.ValidateConfig()
|
|
}
|