contexthandler

package
v0.0.0-test.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package contexthandler contains the ContextHandler service.

Index

Constants

View Source
const (
	InvalidJWT   = "Invalid JWT"
	InvalidRole  = "Invalid Role"
	UserNotFound = "User not found"
)
View Source
const (
	InvalidUsernamePassword = "invalid username or password"
	/* #nosec */
	InvalidAPIKey = "invalid API key"
)

Variables

This section is empty.

Functions

func CopyWithReqContext

func CopyWithReqContext(ctx context.Context) context.Context

CopyWithReqContext returns a copy of the parent context with a semi-shallow copy of the ReqContext as a value. The ReqContexts's *web.Context is deep copied so that headers are thread-safe; additional properties are shallow copied and should be treated as read-only.

func FromContext

func FromContext(c context.Context) *contextmodel.ReqContext

FromContext returns the ReqContext value stored in a context.Context, if any.

func WithAuthHTTPHeaders

func WithAuthHTTPHeaders(ctx context.Context, cfg *setting.Cfg) context.Context

WithAuthHTTPHeaders returns a new context in which all possible configured auth header will be included and later retrievable by AuthHTTPHeaderListFromContext.

Types

type AuthHTTPHeaderList

type AuthHTTPHeaderList struct {
	Items []string
}

AuthHTTPHeaderList used to record HTTP headers that being when verifying authentication of an incoming HTTP request.

func AuthHTTPHeaderListFromContext

func AuthHTTPHeaderListFromContext(c context.Context) *AuthHTTPHeaderList

AuthHTTPHeaderListFromContext returns the AuthHTTPHeaderList in a context.Context, if any, and will include any HTTP headers used when verifying authentication of an incoming HTTP request.

type ContextHandler

type ContextHandler struct {
	Cfg              *setting.Cfg
	AuthTokenService auth.UserTokenService
	JWTAuthService   auth.JWTVerifierService
	RemoteCache      *remotecache.RemoteCache
	RenderService    rendering.Service
	SQLStore         db.DB

	// GetTime returns the current time.
	// Stubbable by tests.
	GetTime func() time.Time
	// contains filtered or unexported fields
}

ContextHandler is a middleware.

func ProvideService

func ProvideService(cfg *setting.Cfg, tokenService auth.UserTokenService, jwtService jwt.JWTService,
	remoteCache *remotecache.RemoteCache, renderService rendering.Service, sqlStore db.DB,
	tracer tracing.Tracer, authProxy *authproxy.AuthProxy, loginService login.Service,
	apiKeyService apikey.Service, authenticator loginpkg.Authenticator, userService user.Service,
	orgService org.Service, oauthTokenService oauthtoken.OAuthTokenService, features *featuremgmt.FeatureManager,
	authnService authn.Service, anonSessionService anonymous.Service,
) *ContextHandler

func (*ContextHandler) Middleware

func (h *ContextHandler) Middleware(next http.Handler) http.Handler

Middleware provides a middleware to initialize the request context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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