auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthURL

func AuthURL() (url, state string)

func GenerateEncryptionKey

func GenerateEncryptionKey() string

GenerateEncryptionKey returns a new random 256-bit key as a 64-char hex string.

func HandleCallback

func HandleCallback(ctx context.Context, code, state string, storePendingFn func(state, token string, user DiscordUser) error) error

HandleCallback exchanges the OAuth2 code for Discord user info, then calls storePendingFn with the state, a new session token, and the Discord user.

func Init

func Init(clientID, clientSecret, redirectURL string)

func RequireAuth

func RequireAuth(db *sql.DB, next http.HandlerFunc) http.HandlerFunc

RequireAuth is an HTTP middleware that validates the Bearer token from the DB.

Types

type DiscordUser

type DiscordUser struct {
	ID        string
	Username  string
	AvatarURL string
}

DiscordUser holds the fields we capture from the Discord /users/@me endpoint.

Jump to

Keyboard shortcuts

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