authorize

package
v0.0.0-...-98dad3e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TenantKey key
)

Variables

This section is empty.

Functions

func AgainstEndpoint

func AgainstEndpoint(logger log.Logger, client *http.Client, endpoint *url.URL, token []byte, cluster string, validate func(*http.Response) error) ([]byte, error)

func NewAuthorizeClientHandler

func NewAuthorizeClientHandler(logger log.Logger, authorizer ClientAuthorizer, next http.Handler) http.Handler

func NewHandler

func NewHandler(logger log.Logger, client *http.Client, endpoint *url.URL, tenantKey string, next http.Handler) http.HandlerFunc

NewHandler returns an http.HandlerFunc that is able to authorize requests against Tollbooth. The handler function expects a bearer token in the Authorization header consisting of a base64-encoded JSON object containing "authorization_token" and "cluster_id" fields.

func WithClient

func WithClient(ctx context.Context, client *Client) context.Context

Types

type Client

type Client struct {
	ID     string
	Labels map[string]string
}

func FromContext

func FromContext(ctx context.Context) (*Client, bool)

type ClientAuthorizer

type ClientAuthorizer interface {
	AuthorizeClient(token string) (*Client, error)
}

type ClusterAuthorizer

type ClusterAuthorizer interface {
	AuthorizeCluster(token, cluster string) (subject string, err error)
}

type ClusterAuthorizerFunc

type ClusterAuthorizerFunc func(token, cluster string) (subject string, err error)

func (ClusterAuthorizerFunc) AuthorizeCluster

func (f ClusterAuthorizerFunc) AuthorizeCluster(token, cluster string) (subject string, err error)

type ErrorWithCode

type ErrorWithCode interface {
	error
	HTTPStatusCode() int
}

func NewErrorWithCode

func NewErrorWithCode(err error, code int) ErrorWithCode

type ServerRotatingRoundTripper

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

func NewServerRotatingRoundTripper

func NewServerRotatingRoundTripper(initialToken string, endpoint *url.URL, rt http.RoundTripper) *ServerRotatingRoundTripper

func (*ServerRotatingRoundTripper) Labels

func (rt *ServerRotatingRoundTripper) Labels() (map[string]string, error)

func (*ServerRotatingRoundTripper) RoundTrip

func (rt *ServerRotatingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type TokenResponse

type TokenResponse struct {
	Version int `json:"version"`

	Token            string `json:"token"`
	ExpiresInSeconds int64  `json:"expiresInSeconds"`

	Labels map[string]string `json:"labels"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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