handler

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(user user.User, expiresIn, svcAccountID string) (string, error)

CreateToken creates a token for a user

func GetServiceAccountID added in v2.2.0

func GetServiceAccountID(r *http.Request) string

GetServiceAccountID returns the service account token id from the request (if login used a service account)

func GetUserID

func GetUserID(r *http.Request) string

GetUserID returns the logged in user details

func MiddlewareAuthenticationVerification

func MiddlewareAuthenticationVerification(next http.Handler) http.Handler

MiddlewareAuthenticationVerification verifies user auth details

func SetAccessControl added in v2.2.0

func SetAccessControl(api *policyAPI.API)

SetAccessControl wires the policy API used by auth middleware (user disabled, RBAC). Call once during server HTTP setup.

func SubjectFromRequest added in v2.2.0

func SubjectFromRequest(r *http.Request) (policyAPI.Subject, error)

SubjectFromRequest builds the access control subject from the verified request context. Fails when the request did not pass authentication - the mc_userid header is only trusted after IsValidToken has rewritten it.

Types

type McApiContext added in v2.1.1

type McApiContext struct {
	Tenant           string `json:"tenant" yaml:"tenant"`
	UserID           string `json:"userId" yaml:"userId"`
	ServiceAccountID string `json:"serviceAccountId" yaml:"serviceAccountId"`
}

struct used in api request

func GetAPIContext added in v2.2.0

func GetAPIContext(r *http.Request) *McApiContext

GetAPIContext returns McApiContext from request context if present

func IsValidToken

func IsValidToken(r *http.Request) (*McApiContext, error)

steps to verify the authentication 1. Verify the token in header 2. Verify the token in cookie

Jump to

Keyboard shortcuts

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