mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-06-05 22:44:17 +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>
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package providers
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
// GitHubProvider encapsulates GitHub-specific OIDC logic.
|
|
type GitHubProvider struct {
|
|
*BaseProvider
|
|
}
|
|
|
|
// NewGitHubProvider creates a new instance of the GitHubProvider.
|
|
func NewGitHubProvider() *GitHubProvider {
|
|
return &GitHubProvider{
|
|
BaseProvider: NewBaseProvider(),
|
|
}
|
|
}
|
|
|
|
// GetType returns the provider's type.
|
|
func (p *GitHubProvider) GetType() ProviderType {
|
|
return ProviderTypeGitHub
|
|
}
|
|
|
|
// GetCapabilities returns the specific capabilities of the GitHub provider.
|
|
// WARNING: GitHub does NOT support OpenID Connect - it's OAuth 2.0 only.
|
|
// This provider should only be used for OAuth flows, not OIDC authentication.
|
|
func (p *GitHubProvider) GetCapabilities() ProviderCapabilities {
|
|
return ProviderCapabilities{
|
|
SupportsRefreshTokens: false, // GitHub OAuth apps don't support refresh tokens
|
|
RequiresOfflineAccessScope: false, // GitHub doesn't use offline_access
|
|
RequiresPromptConsent: false,
|
|
PreferredTokenValidation: "access", // GitHub only provides access tokens, no ID tokens
|
|
}
|
|
}
|
|
|
|
// BuildAuthParams configures GitHub-specific authentication parameters.
|
|
func (p *GitHubProvider) BuildAuthParams(baseParams url.Values, scopes []string) (*AuthParams, error) {
|
|
// GitHub doesn't use offline_access scope, so remove it if present
|
|
var filteredScopes []string
|
|
for _, scope := range scopes {
|
|
if scope != ScopeOfflineAccess {
|
|
filteredScopes = append(filteredScopes, scope)
|
|
}
|
|
}
|
|
|
|
// If no scopes specified, use default GitHub scopes for OAuth
|
|
// Note: GitHub doesn't support 'openid' scope as it's not an OIDC provider
|
|
if len(filteredScopes) == 0 {
|
|
filteredScopes = []string{"user:email", "read:user"}
|
|
}
|
|
|
|
return &AuthParams{
|
|
URLValues: baseParams,
|
|
Scopes: deduplicateScopes(filteredScopes),
|
|
}, nil
|
|
}
|
|
|
|
// GitHub requires specific configuration for proper operation.
|
|
func (p *GitHubProvider) ValidateConfig() error {
|
|
return p.BaseProvider.ValidateConfig()
|
|
}
|