introspection

package
v0.0.1-dev.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 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

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(backend Backend, bearer string) http.Handler

Handler serves the RFC 7662 §2 introspection endpoint. The caller authenticates with a bearer token, which RFC 7662 §2.1 allows in place of client authentication.

Types

type Backend

type Backend interface {
	Introspect(context.Context, string) (Result, error)
}

type Client

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

func NewClient

func NewClient(endpoint, bearer string, transport *http.Client) (*Client, error)

func (*Client) Introspect

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

Introspect posts token to Handler as RFC 7662 §2.1 describes. A token Handler would refuse for its size cannot exist, so it is not active, as RFC 7662 §2.2 says of such a token. Any status but 200, or an answer that does not decode, is an error.

type Result

type Result struct {
	Active    bool                       `json:"active"`
	Issuer    string                     `json:"iss,omitempty"`
	Subject   string                     `json:"sub,omitempty"`
	ClientID  string                     `json:"client_id,omitempty"`
	Expiry    int64                      `json:"exp,omitempty"`
	NotBefore int64                      `json:"nbf,omitempty"`
	Audience  string                     `json:"aud,omitempty"`
	Scope     string                     `json:"scope,omitempty"`
	Act       json.RawMessage            `json:"act,omitempty"`
	Claims    map[string]json.RawMessage `json:"-"`
}

Result is the RFC 7662 §2.2 answer package profile requires: empty when inactive, otherwise about a Bearer token. The act extension is defined by RFC 8693 §4.1.

func (Result) Check

func (r Result) Check(issuer string, now time.Time, audiences ...string) error

Check holds an active answer to the issuer the caller trusts, the exp and nbf of RFC 7662 §2.2, and the audiences the caller accepts, of which RFC 8707 §2.2 gives a token exactly one.

func (Result) MarshalJSON

func (r Result) MarshalJSON() ([]byte, error)

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(data []byte) error

UnmarshalJSON reads an RFC 7662 §2.2 answer as package profile requires it. An answer without active, or an active one lacking a required field or with a scope outside RFC 6749 §3.3, is an error. Only a Bearer token can be active: token_type compares as RFC 6749 §5.1 says, and any other type is not active whatever else the answer holds.

Jump to

Keyboard shortcuts

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