server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATICPATH  = "/podstatic/"
	LOGINPATH   = "/podapi/login"
	LOGOUTPATH  = "/podapi/logout"
	HEALTHZPATH = "/healthz"
	KILLPATH    = "/podapi/kill"
	SPAWNPATH   = "/podapi/spawn"
	INFOPATH    = "/podapi/info"
)

Paths that trigger server routines

View Source
const (
	ErrorTemplate = "errorPage.html"
	KillTemplate  = "killPage.html"
	SpawnTemplate = "spawnPage.html"
	WaitTemplate  = "waitPage.html"
	LoginTemplate = "loginPage.html"
)

Templates for each feedback page

View Source
const CSRFCOOKIE = "KEYPROXY_CSRF"

CSRF Cookie name

View Source
const CSRFHEADER = "X-Csrf-Token"

CSRF Header Name

View Source
const MEMORY_BUFFER_SIZE = 16

MEMORY_BUFFER_SIZE is the amount of bytes to carry in the memory buffer

View Source
const SESSIONCOOKIE = "KEYPROXY_SESSION"

Session Cookie name

Variables

This section is empty.

Functions

func Exhaust

func Exhaust(r *http.Request)

Exhaust the request body

func Middleware

func Middleware(handlerFunc func(w http.ResponseWriter, r *http.Request)) *middleware

Middleware constructor facilitates chaining middlewares

Types

type AuthManager

type AuthManager interface {
	Check(token string) (auth.Credentials, AuthSession, error)
	Login(creds auth.Credentials, password string) (AuthSession, error)
}

AuthManager encapsulates the methods expected from auth manager

type AuthSession

type AuthSession interface {
	kube.JWTSession
	Logout()
}

AuthSession encapsulates the methods expected from auth session

type ErrorBufferTooSmall

type ErrorBufferTooSmall string

ErrorBufferTooSmall raised when reader has no room

func (ErrorBufferTooSmall) Error

func (err ErrorBufferTooSmall) Error() string

type KubeFactory

type KubeFactory interface {
	Find(auth.Credentials) (KubeManager, error)
	ServerVersion() (version fmt.Stringer, err error)
}

KubeFactory encapsulates method sexpected from a pod factory

type KubeManager

type KubeManager interface {
	Delete(context.Context) error
	Proxy(ctx context.Context, create bool) (*kube.PodProxy, kube.PodInfo, error)
}

KubeManager encapsulates the methods expected from a pod manager

type LoginParams

type LoginParams struct {
	ProxyScheme string            `json:"proxyScheme"`
	Host        string            `json:"host"`
	Service     string            `json:"service"`
	Username    string            `json:"username"`
	ErrMessage  string            `json:"errMessage"`
	CSRFTag     htmlTemplate.HTML `json:"-"`
}

LoginParams passed to login page template

type ProxyHandler

type ProxyHandler struct {
	clock.Keeper
	Logger      *log.Logger
	Redirect    string // Where to redirect requests for "/"
	ProxyScheme string // scheme for the login page, "http" or "https"
	Static      fs.FS
	StaticLogin bool // true if there is an 'index.html' in podstatic
	Auth        AuthManager
	Factory     KubeFactory
	Paths       []string // Paths supported by pod

	*http.ServeMux
	// contains filtered or unexported fields
}

ProxyHandler manages the pod lifecycle requests and proxies other requests.

func New

func New(logger *log.Logger, redirect, proxyScheme string, corsOrigins []string, templates, static fs.FS, authManager AuthManager, factory KubeFactory, paths []string) (*ProxyHandler, error)

New creates new proxy handler

func (*ProxyHandler) Check

func (h *ProxyHandler) Check(ctx context.Context, token string) (context.Context, error)

Auth checks authentication and stores session in context

func (*ProxyHandler) LoginForm

func (h *ProxyHandler) LoginForm(w http.ResponseWriter, r *http.Request)

LoginForm processes the login form and sets a cookie

func (*ProxyHandler) NewParams

func (h *ProxyHandler) NewParams(r *http.Request, session Session, create bool) (TemplateParams, error)

type ReplaceReader

type ReplaceReader struct {
	Logger *log.Entry
	// contains filtered or unexported fields
}

ReplaceReader is a hack to make wso2 js work.

func (*ReplaceReader) Close

func (rb *ReplaceReader) Close() error

Close implementents io.ReadCloser

func (*ReplaceReader) Flush

func (rb *ReplaceReader) Flush()

Flush implements io.Flusher

func (*ReplaceReader) Read

func (rb *ReplaceReader) Read(buf []byte) (int, error)

Read implements io.Reader Replaces ("ws://" +) with ("wss://"+) in response body. Notice how both strings are same length, so we don't break the Content-Length header.

type Session

type Session struct {
	Credentials auth.Credentials
	AuthSession AuthSession
	Manager     KubeManager
	Logger      *log.Entry
}

type SessionKeyType

type SessionKeyType int

AuthSessionKeyType used for storing session in request context.

type TemplateParams

type TemplateParams struct {
	ProxyScheme string         `json:"proxyScheme"`
	Host        string         `json:"host"`
	Service     string         `json:"service"`
	Username    string         `json:"username"`
	EventType   kube.EventType `json:"eventType"`
	PodPhase    kube.PodPhase  `json:"podPhase"`
	Ready       bool           `json:"ready"`
	Address     string         `json:"address"`
	Paths       []string       `json:"paths"` // Additional paths supported by pod
}

TemplateParams passed to all other template pages

Jump to

Keyboard shortcuts

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