auth

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveTokenFromRequest

func ResolveTokenFromRequest(r *http.Request, cookieName string) string

ResolveTokenFromRequest resolves token from Authorization header first, then cookie.

func ValidateGitHubToken

func ValidateGitHubToken(ctx context.Context, token string, httpClient *http.Client) error

ValidateGitHubToken validates a GitHub OAuth token by calling GET /user.

Types

type Config

type Config struct {
	GitHubClientID     string
	GitHubClientSecret string
	CallbackURL        string
	Scopes             []string
	CookieDomain       string
	CookieName         string
	CookieSecure       bool
	AuthAPIBaseURL     string
}

Config configures OAuth and shared auth cookie behavior for HTTP API/MCP servers.

func LoadConfigFromEnv

func LoadConfigFromEnv() Config

LoadConfigFromEnv loads authentication settings from environment variables.

func (Config) AuthorizeURL

func (c Config) AuthorizeURL(state string) string

AuthorizeURL returns GitHub OAuth authorize URL.

func (Config) ExchangeCodeForToken

func (c Config) ExchangeCodeForToken(ctx context.Context, code string, httpClient *http.Client) (string, error)

ExchangeCodeForToken exchanges OAuth code for a GitHub access token.

func (Config) ValidateForHTTPMode

func (c Config) ValidateForHTTPMode() error

ValidateForHTTPMode validates required auth settings before HTTP server startup.

Jump to

Keyboard shortcuts

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