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 ¶
- Variables
- type Assertions
- type Client
- func (c *Client) Exchange(ctx context.Context, req identitybroker.TokenExchange) (identitybroker.TokenExchangeResult, error)
- func (c *Client) IssueIDJAG(ctx context.Context, req identitybroker.IDJAGRequest) (identitybroker.IDJAGResult, error)
- func (c *Client) Redeem(ctx context.Context, req identitybroker.Redemption) (identitybroker.GatewayTokenResult, error)
- func (c *Client) Revoke(ctx context.Context, form url.Values) error
- func (c *Client) Token(ctx context.Context, form url.Values, out any) error
- type Config
Constants ¶
This section is empty.
Variables ¶
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 (*Client) Exchange ¶
func (c *Client) Exchange(ctx context.Context, req identitybroker.TokenExchange) (identitybroker.TokenExchangeResult, error)
Exchange implements identitybroker.AuthServer: AS-1's session-open exchange (design step (3)). It posts an RFC 8693 token exchange of req.SubjectToken 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 ¶
func (c *Client) IssueIDJAG(ctx context.Context, req identitybroker.IDJAGRequest) (identitybroker.IDJAGResult, error)
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, naming the call's operation in mecatl_operation. 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 ¶
func (c *Client) Redeem(ctx context.Context, req identitybroker.Redemption) (identitybroker.GatewayTokenResult, error)
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. 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) Token ¶
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.