httpoauth

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package httpoauth implements the protocol boundary for customer-configured HTTP OAuth apps.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig   = xerror.New(xerror.KindInvalidInput, "HTTP_OAUTH_CONFIG_INVALID", "HTTP OAuth configuration is invalid")
	ErrGrant    = xerror.New(xerror.KindInvalidInput, "HTTP_OAUTH_INVALID_GRANT", "HTTP OAuth grant was rejected")
	ErrProvider = xerror.New(xerror.KindUnavailable, "HTTP_OAUTH_PROVIDER_UNAVAILABLE", "HTTP OAuth provider request failed")
)

Functions

func NewVerifier

func NewVerifier() (string, error)

NewVerifier uses the same cryptographic randomness as OAuth state, meeting RFC 7636's minimum length.

func ValidateDestination

func ValidateDestination(destination, raw string) error

ValidateDestination binds bearer use to the configured origin and base path.

Types

type Client

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

func New

func New(config Config, secret, redirectURI, destination string, allowPrivateHosts bool) (*Client, error)

New applies deployment private-host policy to the pinned transport, with no proxy or redirects.

func (*Client) AuthorizationURL

func (c *Client) AuthorizationURL(state, verifier string) (string, error)

AuthorizationURL requires a per-install verifier which the credential lifecycle must store encrypted.

func (*Client) ClientCredentials

func (c *Client) ClientCredentials(ctx context.Context) (TokenSet, error)

func (*Client) Exchange

func (c *Client) Exchange(ctx context.Context, code, verifier, issuer string) (TokenSet, error)

Exchange verifies the callback issuer against the stored app before sending a code.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, refreshToken string, grantedScopes []string) (TokenSet, error)

func (*Client) Revoke

func (c *Client) Revoke(ctx context.Context, token string) error

type Config

type Config struct {
	Issuer                string   `json:"issuer"`
	AuthorizationEndpoint string   `json:"authorization_endpoint,omitempty"`
	TokenEndpoint         string   `json:"token_endpoint"`
	RevocationEndpoint    string   `json:"revocation_endpoint,omitempty"`
	ClientID              string   `json:"client_id"`
	GrantType             string   `json:"grant_type"`
	Scopes                []string `json:"scopes,omitempty"`
	Audience              string   `json:"audience,omitempty"`
}

Config contains public app settings; client secrets are supplied separately from encrypted storage.

type TokenSet

type TokenSet struct {
	AccessToken  string
	RefreshToken string
	ExpiresAt    time.Time
	Scopes       []string
}

Jump to

Keyboard shortcuts

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