usercontext

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package usercontext carries the authenticated subject through a request context.

It lives outside the auth package so that layers auth itself depends on - services, typically - can still read who is performing an action without creating an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetUserContext

func SetUserContext(ctx context.Context, userCtx *UserContext) context.Context

SetUserContext adds a UserContext to the given context.

Types

type UserContext

type UserContext struct {
	UserID             int64
	Username           string
	SubjectPermissions *model.SubjectPermissions
	AuthType           types.AuthType
}

func GetUser

func GetUser(ctx context.Context) *UserContext

func (UserContext) GetUserIdStr

func (uc UserContext) GetUserIdStr() string

func (UserContext) IsUser

func (uc UserContext) IsUser() bool

IsUser reports whether the subject is a real user account. API tokens authenticate without one and carry the token name instead.

Jump to

Keyboard shortcuts

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