Documentation
¶
Index ¶
- func DeserializeStringArray(s string) []string
- func SerializeStringArray(arr []string) string
- type Provider
- type Service
- func (s *Service) CanCreateUser(userInfo *types.UserInfo, providerConfig *config.SSOProviderConfig) bool
- func (s *Service) ExchangeCode(ctx context.Context, providerName string, code string) (*oauth2.Token, error)
- func (s *Service) GenerateState() (string, error)
- func (s *Service) GenerateStateToken() (string, error)
- func (s *Service) GetAuthURL(providerName string, state string) (string, error)
- func (s *Service) GetEnabledProviders() []config.SSOProviderConfig
- func (s *Service) GetOAuth2Config(providerName string) (*oauth2.Config, bool)
- func (s *Service) GetProviderConfig(providerName string) *config.SSOProviderConfig
- func (s *Service) GetUserInfo(ctx context.Context, providerName string, token *oauth2.Token) (*types.UserInfo, error)
- func (s *Service) IsEnabled() bool
- func (s *Service) MapUserAttributes(userInfo *types.UserInfo, providerConfig *config.SSOProviderConfig) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeStringArray ¶
DeserializeStringArray converts a comma-separated string to a string slice
func SerializeStringArray ¶
SerializeStringArray converts a string slice to a comma-separated string
Types ¶
type Provider ¶
type Provider interface {
// GetAuthURL returns the authorization URL for the OAuth2 flow
GetAuthURL(state string) string
// ExchangeCode exchanges an authorization code for a token
ExchangeCode(ctx context.Context, code string) (*oauth2.Token, error)
// GetUserInfo retrieves user information using the provided token
GetUserInfo(ctx context.Context, token *oauth2.Token) (*types.UserInfo, error)
// GetProviderConfig returns the provider configuration
GetProviderConfig() *config.SSOProviderConfig
// GetName returns the provider name
GetName() string
// GetProtocol returns the protocol (oidc or oauth)
GetProtocol() string
}
Provider defines the interface that all SSO providers must implement
func CreateProvider ¶
func CreateProvider(cfg *config.SSOProviderConfig, callbackURL string, logger *zap.SugaredLogger) (Provider, error)
CreateProvider creates a provider instance based on the configuration
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages SSO authentication using the provider interface pattern
func NewService ¶
NewService creates a new SSO service with configured providers
func (*Service) CanCreateUser ¶
func (s *Service) CanCreateUser(userInfo *types.UserInfo, providerConfig *config.SSOProviderConfig) bool
CanCreateUser checks if a user can be auto-created based on group membership
func (*Service) ExchangeCode ¶
func (s *Service) ExchangeCode(ctx context.Context, providerName string, code string) (*oauth2.Token, error)
ExchangeCode exchanges an authorization code for a token
func (*Service) GenerateState ¶
GenerateState is an alias for GenerateStateToken for backward compatibility
func (*Service) GenerateStateToken ¶
GenerateStateToken generates a secure random state token for OAuth2 flow
func (*Service) GetAuthURL ¶
GetAuthURL returns the authorization URL for a given provider
func (*Service) GetEnabledProviders ¶
func (s *Service) GetEnabledProviders() []config.SSOProviderConfig
GetEnabledProviders returns a list of all enabled provider configurations
func (*Service) GetOAuth2Config ¶
GetOAuth2Config returns the OAuth2 config for a provider (for backward compatibility) Returns true if the provider exists
func (*Service) GetProviderConfig ¶
func (s *Service) GetProviderConfig(providerName string) *config.SSOProviderConfig
GetProviderConfig returns the configuration for a specific provider
func (*Service) GetUserInfo ¶
func (s *Service) GetUserInfo(ctx context.Context, providerName string, token *oauth2.Token) (*types.UserInfo, error)
GetUserInfo retrieves user information from the provider
func (*Service) MapUserAttributes ¶
func (s *Service) MapUserAttributes(userInfo *types.UserInfo, providerConfig *config.SSOProviderConfig) []string
MapUserAttributes maps user groups to internal user attributes based on provider configuration