Documentation
¶
Index ¶
- Variables
- type APIAuthRequest
- type APIAuthResponse
- type AuthResult
- type HTTPAPIAuthProvider
- type LocalAuthProvider
- type OAuthProvider
- func (p *OAuthProvider) ExchangeCode(ctx context.Context, code string) (*oauth2.Token, error)
- func (p *OAuthProvider) GetAuthURL(state string) string
- func (p *OAuthProvider) GetDisplayName() string
- func (p *OAuthProvider) GetProvider() string
- func (p *OAuthProvider) GetUserInfo(ctx context.Context, token *oauth2.Token) (*OAuthUserInfo, error)
- type OAuthProviderConfig
- type OAuthUserInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCredentials = errors.New("invalid username or password") // HTTP API errors ErrHTTPAPIConnection = errors.New("failed to connect to authentication API") ErrHTTPAPIAuthFailed = errors.New("authentication API rejected credentials") ErrHTTPAPIInvalidResp = errors.New("invalid response from authentication API") )
Functions ¶
This section is empty.
Types ¶
type APIAuthRequest ¶
APIAuthRequest is the request payload sent to external API
type APIAuthResponse ¶
type APIAuthResponse struct {
Success bool `json:"success"`
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
FullName string `json:"full_name,omitempty"`
Message string `json:"message,omitempty"`
}
APIAuthResponse is the expected response from external API
type AuthResult ¶
type AuthResult struct {
Username string
ExternalID string // External user ID (e.g., LDAP DN, API user ID)
Email string // Optional
FullName string // Optional
Success bool
}
AuthResult represents the result of authentication
type HTTPAPIAuthProvider ¶
type HTTPAPIAuthProvider struct {
// contains filtered or unexported fields
}
HTTPAPIAuthProvider handles HTTP API-based authentication
func NewHTTPAPIAuthProvider ¶
func NewHTTPAPIAuthProvider(cfg *config.Config) *HTTPAPIAuthProvider
NewHTTPAPIAuthProvider creates a new HTTP API authentication provider
func (*HTTPAPIAuthProvider) Authenticate ¶
func (p *HTTPAPIAuthProvider) Authenticate( ctx context.Context, username, password string, ) (*AuthResult, error)
Authenticate verifies credentials against external HTTP API
func (*HTTPAPIAuthProvider) Name ¶
func (p *HTTPAPIAuthProvider) Name() string
Name returns provider name for logging
type LocalAuthProvider ¶
type LocalAuthProvider struct {
// contains filtered or unexported fields
}
LocalAuthProvider handles local database authentication
func NewLocalAuthProvider ¶
func NewLocalAuthProvider(s *store.Store) *LocalAuthProvider
NewLocalAuthProvider creates a new local authentication provider
func (*LocalAuthProvider) Authenticate ¶
func (p *LocalAuthProvider) Authenticate( ctx context.Context, username, password string, ) (*AuthResult, error)
Authenticate verifies credentials against local database
func (*LocalAuthProvider) Name ¶
func (p *LocalAuthProvider) Name() string
Name returns provider name for logging
type OAuthProvider ¶ added in v0.6.0
type OAuthProvider struct {
// contains filtered or unexported fields
}
OAuthProvider handles OAuth authentication
func NewGitHubProvider ¶ added in v0.6.0
func NewGitHubProvider(cfg OAuthProviderConfig) *OAuthProvider
NewGitHubProvider creates a new GitHub OAuth provider
func NewGiteaProvider ¶ added in v0.6.0
func NewGiteaProvider(cfg OAuthProviderConfig, giteaURL string) *OAuthProvider
NewGiteaProvider creates a new Gitea OAuth provider
func (*OAuthProvider) ExchangeCode ¶ added in v0.6.0
ExchangeCode exchanges authorization code for access token
func (*OAuthProvider) GetAuthURL ¶ added in v0.6.0
func (p *OAuthProvider) GetAuthURL(state string) string
GetAuthURL returns the OAuth authorization URL
func (*OAuthProvider) GetDisplayName ¶ added in v0.6.0
func (p *OAuthProvider) GetDisplayName() string
GetDisplayName returns the human-readable provider name
func (*OAuthProvider) GetProvider ¶ added in v0.6.0
func (p *OAuthProvider) GetProvider() string
GetProvider returns the provider name
func (*OAuthProvider) GetUserInfo ¶ added in v0.6.0
func (p *OAuthProvider) GetUserInfo( ctx context.Context, token *oauth2.Token, ) (*OAuthUserInfo, error)
GetUserInfo retrieves user information from the OAuth provider
type OAuthProviderConfig ¶ added in v0.6.0
type OAuthProviderConfig struct {
ClientID string
ClientSecret string
RedirectURL string
Scopes []string
}
OAuthProviderConfig contains configuration for an OAuth provider
type OAuthUserInfo ¶ added in v0.6.0
type OAuthUserInfo struct {
ProviderUserID string // Provider's user ID
Username string // Provider's username
Email string // User email (required)
FullName string // User full name
AvatarURL string // Avatar URL
}
OAuthUserInfo contains user information from OAuth provider