auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomState

func GenerateRandomState() (string, error)

GenerateRandomState generates a random state parameter for CSRF protection

func GetPlatformName

func GetPlatformName() string

GetPlatformName returns a human-readable platform name

func IsBrowserAvailable

func IsBrowserAvailable() bool

IsBrowserAvailable checks if a browser is available on the system

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the default browser to the specified URL

Types

type OAuthCallbackResult

type OAuthCallbackResult struct {
	Code  string
	Error error
}

OAuthCallbackResult represents the result of OAuth callback

type PKCEChallenge

type PKCEChallenge struct {
	CodeVerifier  string
	CodeChallenge string
	Method        string
}

PKCEChallenge represents a PKCE code challenge and verifier pair

func GeneratePKCEChallenge

func GeneratePKCEChallenge() (*PKCEChallenge, error)

GeneratePKCEChallenge creates a new PKCE challenge according to RFC 7636

func (*PKCEChallenge) Verify

func (p *PKCEChallenge) Verify(verifier string) bool

Verify checks if the given verifier matches this challenge

type PKCEOAuthService

type PKCEOAuthService struct {
	// contains filtered or unexported fields
}

PKCEOAuthService handles OAuth2 authentication with PKCE

func NewPKCEOAuthService

func NewPKCEOAuthService(cfg *config.Config) *PKCEOAuthService

NewPKCEOAuthService creates a new PKCE OAuth service

func (*PKCEOAuthService) GetAccessToken

func (s *PKCEOAuthService) GetAccessToken() string

GetAccessToken returns the current access token

func (*PKCEOAuthService) IsAuthenticated

func (s *PKCEOAuthService) IsAuthenticated() bool

IsAuthenticated checks if user is authenticated

func (*PKCEOAuthService) Login

func (s *PKCEOAuthService) Login(ctx context.Context) error

Login performs OAuth2 authentication with PKCE

type UserInfo added in v0.2.0

type UserInfo struct {
	ID          string    `json:"id"`
	Username    string    `json:"username"`
	Email       string    `json:"email"`
	Name        string    `json:"name"`
	FirstName   string    `json:"first_name"`
	LastName    string    `json:"last_name"`
	Avatar      string    `json:"avatar"`
	Verified    bool      `json:"verified"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	LastLoginAt time.Time `json:"last_login_at"`
	Roles       []string  `json:"roles"`
	Permissions []string  `json:"permissions"`
}

UserInfo represents the user information returned by the OAuth userinfo endpoint

func (*UserInfo) FormatUserInfo added in v0.2.0

func (ui *UserInfo) FormatUserInfo() string

FormatUserInfo formats user information for display

type UserInfoService added in v0.2.0

type UserInfoService struct {
	// contains filtered or unexported fields
}

UserInfoService handles OAuth userinfo API calls

func NewUserInfoService added in v0.2.0

func NewUserInfoService(cfg *config.Config) *UserInfoService

NewUserInfoService creates a new userinfo service

func (*UserInfoService) GetUserInfo added in v0.2.0

func (s *UserInfoService) GetUserInfo(ctx context.Context, accessToken string) (*UserInfo, error)

GetUserInfo fetches user information from the OAuth userinfo endpoint

Jump to

Keyboard shortcuts

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