oauth

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const RefreshGrace = time.Minute

RefreshGrace is the safety window before expiry where tokens are refreshed.

Variables

This section is empty.

Functions

func PublicHTTPSURL

func PublicHTTPSURL(ctx context.Context, raw string) (string, error)

PublicHTTPSURL canonicalizes one HTTPS endpoint and rejects non-public addresses so OAuth exchanges cannot target local or reserved networks.

func Refresh

func Refresh(ctx context.Context, client *http.Client, cfg AuthConfig, record Record) (*oauth2.Token, []string, error)

Refresh exchanges one refresh token for a fresh access token.

func TokenUsable

func TokenUsable(token *oauth2.Token, now time.Time) bool

TokenUsable reports whether one access token is still safe to inject.

Types

type AuthConfig

type AuthConfig struct {
	TokenEndpoint           string
	TokenEndpointAuthMethod string
	Resource                string
	Scopes                  []string
}

AuthConfig describes the non-sensitive OAuth metadata needed for refresh.

type Record

type Record struct {
	ClientID     string         `json:"clientId,omitempty"`
	ClientSecret string         `json:"clientSecret,omitempty"`
	Token        *oauth2.Token  `json:"token,omitempty"`
	Scopes       []string       `json:"scopes,omitempty"`
	Registration map[string]any `json:"registration,omitempty"`
	Revocation   map[string]any `json:"revocation,omitempty"`
	UpdatedAt    time.Time      `json:"updatedAt"`
}

Record stores the shared OAuth credential material kept in OpenBao.

Jump to

Keyboard shortcuts

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