oauth

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateState

func GenerateState() (string, error)

GenerateState generates a random state parameter for CSRF protection

Types

type Client

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

Client handles OAuth2 authorization flow

func NewClient

func NewClient(site string) *Client

NewClient creates a new OAuth client

func (*Client) BuildAuthorizationURL

func (c *Client) BuildAuthorizationURL(
	clientID string,
	redirectURI string,
	state string,
	challenge *PKCEChallenge,
	scopes []string,
) string

BuildAuthorizationURL builds the OAuth2 authorization URL with PKCE

func (*Client) GetAuthConfig

func (c *Client) GetAuthConfig(scopes []string) *types.AuthConfig

GetAuthConfig returns the authentication configuration

func (*Client) ParseCallbackError

func (c *Client) ParseCallbackError(errorCode, errorDescription string) error

ParseCallbackError parses OAuth error from callback parameters

func (*Client) ValidateCallback

func (c *Client) ValidateCallback(code, state, expectedState string) error

ValidateCallback validates the OAuth callback parameters

type PKCEChallenge

type PKCEChallenge struct {
	Verifier  string
	Challenge string
	Method    string
}

PKCEChallenge represents a PKCE code challenge

func GeneratePKCEChallenge

func GeneratePKCEChallenge() (*PKCEChallenge, error)

GeneratePKCEChallenge generates a PKCE code verifier and challenge Uses S256 method as specified in RFC 7636

Jump to

Keyboard shortcuts

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