Documentation
¶
Index ¶
- func DecodeState(encodedState string) (string, error)
- func EncodeState(state string) (string, error)
- func ParseAuthorizationCodeFromRequest(r *http.Request) (code, state string, err error)
- func ValidateOAuthState(expectedState, receivedState string) error
- type BaseOAuthProvider
- func (p *BaseOAuthProvider) BuildAuthCodeURLWith(state string, params ...oauth2.AuthCodeOption) (string, error)
- func (p *BaseOAuthProvider) ExchangeCode(ctx context.Context, code string) (*account.OAuthTokens, error)
- func (p *BaseOAuthProvider) GetAuthorizationURL(ctx context.Context, state string) (string, error)
- func (p *BaseOAuthProvider) GetUser(ctx context.Context, tokens *account.OAuthTokens) (*account.OAuthUser, error)
- func (p *BaseOAuthProvider) Name() account.ProviderType
- func (p *BaseOAuthProvider) RefreshAccessToken(ctx context.Context, refreshToken string) (*account.OAuthTokens, error)
- type DiscordOAuthProvider
- type GitHubOAuthProvider
- type GoogleOAuthProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeState ¶
DecodeState decodes a state parameter (can be overridden for signed states)
func EncodeState ¶
EncodeState encodes a state parameter (can be overridden for signed states)
func ParseAuthorizationCodeFromRequest ¶
ParseAuthorizationCodeFromRequest extracts the authorization code and state from the request
func ValidateOAuthState ¶
ValidateState validates that the state parameter matches (basic implementation)
Types ¶
type BaseOAuthProvider ¶
type BaseOAuthProvider struct {
// contains filtered or unexported fields
}
BaseOAuthProvider provides common OAuth2 functionality
func NewBaseOAuthProvider ¶
func NewBaseOAuthProvider( name account.ProviderType, config *oauth2.Config, userInfoURL string, ) *BaseOAuthProvider
NewBaseOAuthProvider creates a new base OAuth provider
func (*BaseOAuthProvider) BuildAuthCodeURLWith ¶
func (p *BaseOAuthProvider) BuildAuthCodeURLWith(state string, params ...oauth2.AuthCodeOption) (string, error)
BuildAuthCodeURLWith allows building auth code URL with additional parameters
func (*BaseOAuthProvider) ExchangeCode ¶
func (p *BaseOAuthProvider) ExchangeCode(ctx context.Context, code string) (*account.OAuthTokens, error)
ExchangeCode exchanges an authorization code for tokens
func (*BaseOAuthProvider) GetAuthorizationURL ¶
GetAuthorizationURL returns the URL to redirect the user to for authorization
func (*BaseOAuthProvider) GetUser ¶
func (p *BaseOAuthProvider) GetUser(ctx context.Context, tokens *account.OAuthTokens) (*account.OAuthUser, error)
GetUser retrieves the user profile from the provider
func (*BaseOAuthProvider) Name ¶
func (p *BaseOAuthProvider) Name() account.ProviderType
Name returns the provider name
func (*BaseOAuthProvider) RefreshAccessToken ¶
func (p *BaseOAuthProvider) RefreshAccessToken(ctx context.Context, refreshToken string) (*account.OAuthTokens, error)
RefreshAccessToken refreshes the access token using the refresh token
type DiscordOAuthProvider ¶
type DiscordOAuthProvider struct {
*BaseOAuthProvider
}
DiscordOAuthProvider implements account.OAuthProvider for Discord OAuth
func NewDiscordOAuthProvider ¶
func NewDiscordOAuthProvider(clientID, clientSecret, redirectURI string) (*DiscordOAuthProvider, error)
NewDiscordOAuthProvider creates a new Discord OAuth provider
type GitHubOAuthProvider ¶
type GitHubOAuthProvider struct {
*BaseOAuthProvider
}
GitHubOAuthProvider implements account.OAuthProvider for GitHub OAuth
func NewGitHubOAuthProvider ¶
func NewGitHubOAuthProvider(clientID, clientSecret, redirectURI string) (*GitHubOAuthProvider, error)
NewGitHubOAuthProvider creates a new GitHub OAuth provider
type GoogleOAuthProvider ¶
type GoogleOAuthProvider struct {
*BaseOAuthProvider
}
GoogleOAuthProvider implements account.OAuthProvider for Google OAuth
func NewGoogleOAuthProvider ¶
func NewGoogleOAuthProvider(clientID, clientSecret, redirectURI string) (*GoogleOAuthProvider, error)
NewGoogleOAuthProvider creates a new Google OAuth provider