reqctx

package
v0.2.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 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

View Source
const (
	SessionUserKey                  = "user"
	SessionAuthenticationVersionKey = "authentication_version"
	SessionAuthenticatedAtKey       = "authenticated_at"
	SessionGoogleSignupKey          = "google_signup"
	SessionGoogleSignupExpiresKey   = "google_signup_expires"
)

Variables

This section is empty.

Functions

func AuditActor

func AuditActor(ctx context.Context) model.EventActor

func AuditOperation

func AuditOperation(ctx context.Context) string

func FiberRequestID

func FiberRequestID(c fiber.Ctx) string

FiberRequestID reads the middleware ID or the application-owned fallback.

func GetActiveOrganizationSlug

func GetActiveOrganizationSlug(c fiber.Ctx, store *session.Store) slug.Slug

GetActiveOrganizationSlug retrieves the selected organization slug from the session.

func GetClientIP

func GetClientIP(ctx context.Context) string

GetClientIP retrieves the trusted browser client IP from context when available.

func GetRequestID

func GetRequestID(ctx context.Context) *string

GetRequestID retrieves the request ID from context when available.

func GetUserSlug

func GetUserSlug(c fiber.Ctx, store *session.Store) slug.Slug

GetUserSlug retrieves the authenticated user's slug from the session.

func RequestIDMiddleware

func RequestIDMiddleware() fiber.Handler

RequestIDMiddleware accepts canonical UUID correlation IDs and replaces all other input.

func ResetAndSetAuthenticatedUser

func ResetAndSetAuthenticatedUser(c fiber.Ctx, store *session.Store, userSlug slug.Slug, version int64, passwordOrMFA bool) error

ResetAndSetAuthenticatedUser captures the credential generation proven at sign-in.

func ResetAndSetUserSlug

func ResetAndSetUserSlug(c fiber.Ctx, store *session.Store, userSlug slug.Slug) error

ResetAndSetUserSlug rotates the session identifier and stores the authenticated user.

func SessionAuthentication

func SessionAuthentication(c fiber.Ctx, store *session.Store) (int64, time.Time)

SessionAuthentication reads server-owned proof; missing generations fail closed.

func SetAPIKeyPrincipal

func SetAPIKeyPrincipal(c fiber.Ctx, principal APIKeyPrincipal)

func SetActiveOrganizationSlug

func SetActiveOrganizationSlug(c fiber.Ctx, store *session.Store, orgSlug slug.Slug) error

SetActiveOrganizationSlug stores the selected organization slug in the session.

func SetUserPrincipal

func SetUserPrincipal(c fiber.Ctx, principal UserPrincipal)

func SetUserSlug

func SetUserSlug(c fiber.Ctx, store *session.Store, userSlug slug.Slug) error

SetUserSlug stores the user's slug in the session.

func WithAuditActor

func WithAuditActor(ctx context.Context, actor model.EventActor) context.Context

func WithAuditOperation

func WithAuditOperation(ctx context.Context, id string) context.Context

WithAuditOperation binds credential releases to a server-owned request or job identity.

func WithClientIP

func WithClientIP(ctx context.Context, clientIP string) context.Context

WithClientIP returns a derived context carrying the trusted browser client IP for an internal frontend-to-backend call.

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID returns a derived context carrying the request ID when available.

Types

type APIKeyPrincipal

type APIKeyPrincipal struct {
	Slug             slug.Slug
	OrgSlug          slug.Slug
	Role             slug.Slug
	CanManageAPIKeys bool
}

func GetAPIKeyPrincipal

func GetAPIKeyPrincipal(c fiber.Ctx) (APIKeyPrincipal, bool)

type UserPrincipal

type UserPrincipal struct {
	Slug                          slug.Slug
	Source                        UserPrincipalSource
	PersonalAccessTokenSlug       slug.Slug
	CanManagePersonalAccessTokens bool
}

func GetUserPrincipal

func GetUserPrincipal(c fiber.Ctx, store *session.Store) (UserPrincipal, bool)

type UserPrincipalSource

type UserPrincipalSource string
const (
	UserPrincipalSourceSession             UserPrincipalSource = "session"
	UserPrincipalSourcePersonalAccessToken UserPrincipalSource = "personal_access_token"
)

Jump to

Keyboard shortcuts

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