auth

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBearerToken

func ExtractBearerToken(r *http.Request) string

ExtractBearerToken (if any) from the supplied request.

func Middleware

func Middleware(next http.Handler) http.Handler

Middleware extracts credentials from the HTTP request and stashes them in its context.

Types

type Credentials

type Credentials struct {
	BearerToken   string
	BasicUsername string
	BasicPassword string
	Impersonate   Impersonation
}

Credentials that a caller may pass to xgql in order to authenticate to a Kubernetes API server.

func FromContext

func FromContext(ctx context.Context) (Credentials, bool)

FromContext extracts credentials from the supplied context.

func (Credentials) Hash

func (c Credentials) Hash(extra []byte) string

Hash returns a SHA-256 hash of the supplied credentials, plus any extra bytes that were supplied.

func (Credentials) Inject

func (c Credentials) Inject(cfg *rest.Config) *rest.Config

Inject returns a copy of the supplied REST config with credentials injected.

type Impersonation

type Impersonation struct {
	Username string
	Groups   []string
	Extra    map[string][]string
}

Impersonation specifies a subject to impersonate. Impersonation configuration does not consistute credentials; it must be supplied alongside credentials for a subject that has been granted RBAC access to impersonate.

func ExtractImpersonation

func ExtractImpersonation(r *http.Request) Impersonation

ExtractImpersonation configuration (if any) from the supplied request.

Jump to

Keyboard shortcuts

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