Documentation ¶
Overview ¶
Package internal contains internal functions used by server/auth package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterClientFactory ¶
func RegisterClientFactory(f ClientFactory)
RegisterClientFactory allows external module to provide implementation of the ClientFactory.
This is needed to resolve module dependency cycle between server/auth and server/auth/internal.
See init() in server/auth/client.go.
If client factory is not set, Do(...) uses http.DefaultClient. This happens in unit tests for various auth/* subpackages.
func SplitAuthHeader ¶
SplitAuthHeader takes "Bearer <token>" and returns ("bearer", "<token>").
If there's only one word, return ("", "<token>"). If there are more than two words, returns ("bearer", "<token> <more>").
Strips spaces. Lower-cases the `typ`.
func WithTestTransport ¶
func WithTestTransport(ctx context.Context, cb TestTransportCallback) context.Context
WithTestTransport puts a testing transport in the context to use for fetches.
Types ¶
type ClientFactory ¶
ClientFactory knows how to produce http.Client that attach proper OAuth headers.
If 'scopes' is empty, the factory should return a client that makes anonymous requests.
type MergedContext ¶
MergedContext is a context that inherits everything from Root, except values are additionally inherited from Fallback.
func (*MergedContext) Done ¶
func (mc *MergedContext) Done() <-chan struct{}
func (*MergedContext) Err ¶
func (mc *MergedContext) Err() error
func (*MergedContext) Value ¶
func (mc *MergedContext) Value(key any) any
type Request ¶
type Request struct { Method string // HTTP method to use URL string // URL to access Scopes []string // OAuth2 scopes to authenticate with or anonymous call if empty Headers map[string]string // optional map with request headers Body any // object to convert to JSON and send as body or []byte with the body Out any // where to deserialize the response to }
Request represents one JSON REST API request.