reqctx

package
v0.0.0-...-5106b98 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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 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 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 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