mirror of
https://github.com/hanzoai/porto.git
synced 2026-11-03 18:08:27 +00:00
25 lines
1.4 KiB
Go
25 lines
1.4 KiB
Go
// Package credentials implements gRPC transport and per-RPC credentials for
|
|
// porto clients and servers.
|
|
//
|
|
// NewBundle wraps a *tls.Config into a grpccredentials.Bundle whose
|
|
// PerRPCCredentials attaches an "authorization" metadata entry to every RPC.
|
|
// The token can be set statically with Bundle.UpdateAuthToken, refreshed on
|
|
// expiry through a CallerIdentity provider (Bundle.WithCallerIdentity, used for
|
|
// AWS STS presigned tokens), and for "DPoP" tokens a proof header is signed per
|
|
// call when a dpop.Signer is supplied with Bundle.WithDPoP.
|
|
// DPoP proofs bind POST to https://<authority><full method path>, using
|
|
// grpc-go's HTTPS credential audience and the RequestInfo in the RPC context.
|
|
// Missing or invalid audience/method information returns an error.
|
|
// The setters are safe to call while RPCs run, and concurrent RPCs that find the token
|
|
// expired share one provider call.
|
|
//
|
|
// b := credentials.NewBundle(credentials.Config{TLSConfig: tlsCfg})
|
|
// b.UpdateAuthToken(credentials.Token{TokenType: "Bearer", AccessToken: jwt})
|
|
// conn, err := grpc.NewClient(target,
|
|
// grpc.WithTransportCredentials(b.TransportCredentials()),
|
|
// grpc.WithPerRPCCredentials(b.PerRPCCredentials()))
|
|
//
|
|
// NewOauthAccess is a simpler PerRPCCredentials that sends a fixed, already
|
|
// formatted authorization value and requires a PrivacyAndIntegrity transport.
|
|
package credentials
|