oauth

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver implements OAuth2 client credentials authentication. Tokens are opaque strings stored in the oauth_tokens table.

func NewDriver

func NewDriver(env func(string, string) string, db *sql.DB) *Driver

NewDriver creates an OAuth2 client credentials auth driver. Config is read from environment:

  • OAUTH_CLIENT_ID: expected client ID (required)
  • OAUTH_CLIENT_SECRET: expected client secret (required)
  • OAUTH_TOKEN_EXPIRY: token lifetime in seconds (default: 3600)

func (*Driver) Authenticate

func (d *Driver) Authenticate(r *http.Request) (*pickle.AuthInfo, error)

Authenticate extracts the Bearer token from the request, validates it against the oauth_tokens table, and returns AuthInfo on success.

func (*Driver) TokenEndpoint

func (d *Driver) TokenEndpoint(ctx *pickle.Context) pickle.Response

TokenEndpoint is a handler for POST /oauth2/token that implements the OAuth2 client credentials grant. Wire it into your routes:

r.Post("/oauth2/token", oauth.TokenEndpoint)

func (*Driver) ValidateToken

func (d *Driver) ValidateToken(token string) (*pickle.AuthInfo, error)

ValidateToken checks an opaque token against the oauth_tokens table.

Jump to

Keyboard shortcuts

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