authserverclient

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 16 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

Overview

Package authserverclient is the identity broker's client of the authorization servers AS-1 and AS-2: it calls their token and revocation endpoints, authenticating every request as the OAuth client identitybroker.BrokerClientID with private_key_jwt (RFC 7523), a fresh client assertion each time, and never with a client secret. It turns HTTP outcomes into the core's identitybroker.ServerRefusal, identitybroker.ErrNoResponse, and identitybroker.ErrTransportConfiguration, which identitybroker.IsConfigurationFault and identitybroker.IsUnavailable classify; the package itself is only transport.

The package never puts a token, an assertion, or a form value in an error.

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseTooLarge = errors.New("authserverclient: the response is too large")

ErrResponseTooLarge reports a success response body over 1 MiB that the client was asked to decode; such errors also wrap identitybroker.ErrMalformedResponse and identitybroker.ErrTransportConfiguration. An oversized refusal is a *identitybroker.ServerRefusal with its status and no code.

Functions

This section is empty.

Types

type Assertions

type Assertions interface {
	ClientAssertion(audience string, now time.Time) (identitybroker.Token, error)
}

Assertions mints client assertions; *identitybroker.ClientAssertionSigner is the implementation.

type Client

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

Client sends authenticated requests to one authorization server. It is safe for concurrent use.

func New

func New(cfg Config) (*Client, error)

New validates cfg and returns a Client.

func (*Client) Exchange

Exchange implements identitybroker.AuthServer: AS-1's session-open exchange (design step (3)), and a schedule's. It posts an RFC 8693 token exchange of req.SubjectToken, of req.SubjectTokenType or an access token when that is empty, for a refresh token, with req.Grant as the one authorization_details entry and its expires_at, when set, in Unix seconds. A success response that is not valid JSON of the expected shape, or lacks access_token or issued_token_type, wraps both identitybroker.ErrMalformedResponse and identitybroker.ErrTransportConfiguration; other errors are Token's.

func (*Client) IssueIDJAG

IssueIDJAG implements identitybroker.IDJAGIssuer: AS-1's per-call exchange (design step (7)). It posts an RFC 8693 token exchange of the session's refresh token, with the agent's SVID as the actor token, for an ID-JAG for req.Audience and req.Resource, sending req.AuthorizationDetails, when set, for AS-1 to sign into the ID-JAG: the call's entry, which carries its operation, so no other Mecatl parameter is sent. A success response that is not valid JSON of the expected shape, lacks access_token, or does not issue an ID-JAG wraps both identitybroker.ErrMalformedResponse and identitybroker.ErrTransportConfiguration; other errors are Token's.

func (*Client) Redeem

Redeem implements identitybroker.GatewayAuthServer: AS-2's redemption of an ID-JAG for a gateway token (design step (8)), an RFC 7523 JWT-bearer grant for req.Resource. The request carries no authorization_details: AS-2 takes the call entry from the claim AS-1 signed into the ID-JAG and refuses the parameter. The response's authorization_details member is returned as sent, for the broker's output check. A refresh token in the response is ignored and never kept. A success response that is not valid JSON of the expected shape, lacks access_token, or is not a bearer token wraps both identitybroker.ErrMalformedResponse and identitybroker.ErrTransportConfiguration; other errors are Token's.

func (*Client) Revoke

func (c *Client) Revoke(ctx context.Context, form url.Values) error

Revoke posts form to the revocation endpoint, with Token's errors.

func (*Client) Token

func (c *Client) Token(ctx context.Context, form url.Values, out any) error

Token posts form to the token endpoint and decodes the JSON success response into out. A refusal returns an *identitybroker.ServerRefusal; no response returns an error wrapping identitybroker.ErrNoResponse, or identitybroker.ErrTransportConfiguration when the server certificate does not verify; a success response that does not decode into out wraps both identitybroker.ErrMalformedResponse and ErrTransportConfiguration; a cancelled or expired ctx returns its error.

type Config

type Config struct {
	// Issuer is the server's issuer identifier, which every assertion names
	// as its only audience. Required.
	Issuer string
	// TokenEndpoint is the server's HTTPS token endpoint. Required.
	TokenEndpoint string
	// RevocationEndpoint is the server's HTTPS RFC 7009 revocation endpoint.
	// Empty when the broker does not revoke at this server.
	RevocationEndpoint string
	// Assertions mints the client assertions. Required.
	Assertions Assertions
	// HTTPClient sends the requests and owns the transport policy (TLS,
	// proxy, timeouts). Required. The Client uses a copy that refuses every
	// redirect.
	HTTPClient *http.Client
	// Now is the clock for assertions. Nil selects time.Now.
	Now func() time.Time
}

Config configures a Client for one authorization server.

Jump to

Keyboard shortcuts

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