repository

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeState

func DecodeState(encodedState string) (string, error)

DecodeState decodes a state parameter (can be overridden for signed states)

func EncodeState

func EncodeState(state string) (string, error)

EncodeState encodes a state parameter (can be overridden for signed states)

func ParseAuthorizationCodeFromRequest

func ParseAuthorizationCodeFromRequest(r *http.Request) (code, state string, err error)

ParseAuthorizationCodeFromRequest extracts the authorization code and state from the request

func ValidateOAuthState

func ValidateOAuthState(expectedState, receivedState string) error

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

func (p *BaseOAuthProvider) GetAuthorizationURL(ctx context.Context, state string) (string, error)

GetAuthorizationURL returns the URL to redirect the user to for authorization

func (*BaseOAuthProvider) GetUser

GetUser retrieves the user profile from the provider

func (*BaseOAuthProvider) Name

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL