auth

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

refer to: https://github.com/rancher/k3s/blob/master/pkg/clientaccess/clientaccess.go

Index

Constants

View Source
const (
	CookieName      = "R_SESS"
	AuthHeaderName  = "Authorization"
	AuthValuePrefix = "Bearer"
	BasicAuthPrefix = "Basic"

	OctopusAPILabel = "authn.management.octopusapi.io/octopus-api"

	TokenNamespace = "kube-system"
)

Variables

This section is empty.

Functions

func AgentAccessInfoToKubeConfig

func AgentAccessInfoToKubeConfig(destFile, server, token string) error

func Get

func Get(path string, info *Info) ([]byte, error)

func GetCACerts

func GetCACerts(u url.URL) ([]byte, error)

func GetHTTPClient

func GetHTTPClient(cacerts []byte) *http.Client

func GetJWTSecretTokenName

func GetJWTSecretTokenName(token string) (string, error)

func GetTokenAuthFromRequest

func GetTokenAuthFromRequest(req *http.Request) string

func NormalizeAndValidateTokenForUser

func NormalizeAndValidateTokenForUser(server, token, user string) (string, error)

func ParseUsernamePassword

func ParseUsernamePassword(token string) (string, string, bool)

func SplitJWTTokenParts

func SplitJWTTokenParts(token string) ([]string, error)

func SplitTokenParts

func SplitTokenParts(tokenID string) (string, string)

func ToAuthMiddleware

func ToAuthMiddleware(a Authenticator) auth.Middleware

Types

type Authenticator

type Authenticator interface {
	Authenticate(req *http.Request) (authed bool, user string, err error)
}

func NewK3sAuthenticator

func NewK3sAuthenticator(ctx context.Context, endpoint string, client *kubernetes.Clientset) Authenticator

type Handler

type Handler struct {
	Host string
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(ctx context.Context, host string, client *kubernetes.Clientset) *Handler

NewHandler creates a new AuthHandler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, req *http.Request)

type Info

type Info struct {
	URL     string `json:"url,omitempty"`
	CACerts []byte `json:"cacerts,omitempty"`

	Token string `json:"token,omitempty"`
	// contains filtered or unexported fields
}

func ParseAndValidateToken

func ParseAndValidateToken(server, token string) (*Info, error)

func (*Info) KubeConfig

func (i *Info) KubeConfig() *clientcmdapi.Config

func (*Info) ToToken

func (i *Info) ToToken() string

func (*Info) WriteKubeConfig

func (i *Info) WriteKubeConfig(destFile string) error

type K3sAuthenticator

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

func (*K3sAuthenticator) Authenticate

func (a *K3sAuthenticator) Authenticate(req *http.Request) (bool, string, error)

type OverrideURLCallback

type OverrideURLCallback func(config []byte) (*url.URL, error)

type TokenSecretData

type TokenSecretData struct {
	Issuer    string `json:"issuer,omitempty"`
	ExpiresAt string `json:"expiresAt,omitempty"`
	IssuedAt  string `json:"issuedAt,omitempty"`
	Subject   string `json:"subject,omitempty"`
	Key       string `json:"key,omitempty"`
}

Jump to

Keyboard shortcuts

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