auth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MemoryOnlyPrefix = "mem_"

MemoryOnlyPrefix is used to mark tokens that should only exist in memory

Variables

View Source
var (
	ErrPasswordTooShort = errors.New("password must be at least 8 characters")
	ErrPasswordTooLong  = errors.New("password must be less than 72 characters")
	ErrInvalidSession   = errors.New("invalid session")
)

Functions

func CheckPassword

func CheckPassword(password, hash string) bool

func HashPassword

func HashPassword(password string) (string, error)

func SignToken

func SignToken(token, secret string) string

func VerifyToken

func VerifyToken(signedToken, secret string) (string, error)

Types

type Claims

type Claims struct {
	Subject  string `json:"sub"`
	Name     string `json:"name"`
	Username string `json:"preferred_username"`
}

type OIDCConfig

type OIDCConfig struct {
	OAuth2Config oauth2.Config
	// contains filtered or unexported fields
}

func NewOIDC

func NewOIDC(ctx context.Context, cfg config.OIDCConfig) (*OIDCConfig, error)

func (*OIDCConfig) AuthURL

func (c *OIDCConfig) AuthURL() string

func (*OIDCConfig) AuthURLWithPKCE added in v0.4.0

func (c *OIDCConfig) AuthURLWithPKCE(state string, pkce *PKCEParams) string

AuthURLWithPKCE generates an authorization URL with PKCE parameters

func (*OIDCConfig) ExchangeCodeWithPKCE added in v0.4.0

func (c *OIDCConfig) ExchangeCodeWithPKCE(ctx context.Context, code string, codeVerifier string) (*oauth2.Token, error)

ExchangeCodeWithPKCE exchanges authorization code for tokens using PKCE

func (*OIDCConfig) GetClaims

func (c *OIDCConfig) GetClaims(ctx context.Context, token string) (*Claims, error)

func (*OIDCConfig) VerifyToken

func (c *OIDCConfig) VerifyToken(ctx context.Context, token string) error

type PKCEParams added in v0.4.0

type PKCEParams struct {
	CodeVerifier  string
	CodeChallenge string
}

PKCEParams holds PKCE parameters for OAuth2 flow

func GeneratePKCEParams added in v0.4.0

func GeneratePKCEParams() (*PKCEParams, error)

GeneratePKCEParams generates PKCE code verifier and challenge

Jump to

Keyboard shortcuts

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