contexthandler

package
v0.0.0-kmdagger2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: AGPL-3.0 Imports: 36 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 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