context

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 4 Imported by: 0 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 GetAuthzDecision

func GetAuthzDecision(ctx context.Context) any

GetAuthzDecision extracts the authorization decision from the context

func GetPostPolicyPolicyB64

func GetPostPolicyPolicyB64(ctx context.Context) string

GetPostPolicyPolicyB64 returns the base64-encoded policy document from the POST policy form.

func GetPreSignedExpiresAt

func GetPreSignedExpiresAt(ctx context.Context) (any, bool)

GetPreSignedExpiresAt returns the expiration time of the pre-signed URL

func GetUser

func GetUser(ctx context.Context) (*iam.User, error)

GetUser extracts the user from the context

func IsAnonymousRequest

func IsAnonymousRequest(ctx context.Context) bool

IsAnonymousRequest returns true if the request was marked as anonymous

func IsPostPolicyRequest

func IsPostPolicyRequest(ctx context.Context) bool

IsPostPolicyRequest returns true if request was authenticated via POST policy form upload.

func IsPreSignedRequest

func IsPreSignedRequest(ctx context.Context) bool

IsPreSignedRequest returns true if request was authenticated via pre-signed URL

func WithAnonymousRequest

func WithAnonymousRequest(ctx context.Context) context.Context

WithAnonymousRequest marks the request as anonymous in the context

func WithAuthzDecision

func WithAuthzDecision(ctx context.Context, decision any) context.Context

WithAuthzDecision returns a new context with the authorization decision set

func WithPostPolicyRequest

func WithPostPolicyRequest(ctx context.Context, user *iam.User, policyB64 string) context.Context

WithPostPolicyRequest adds a user authenticated via POST policy form upload to context. Also marks the request as a POST policy upload and stores the base64 policy for the handler.

func WithPreSignedUser

func WithPreSignedUser(ctx context.Context, user *iam.User, expiresAt any) context.Context

WithPreSignedUser adds a user authenticated via pre-signed URL to context Also marks the request as pre-signed and stores expiration for auditing

func WithServiceAccountInfo

func WithServiceAccountInfo(ctx context.Context, info *ServiceAccountInfo) context.Context

WithServiceAccountInfo returns a new context with service account metadata set.

func WithUser

func WithUser(ctx context.Context, user *iam.User) context.Context

WithUser returns a new context with the user set

Types

type KeyID

type KeyID string
const (
	RequestUserKey KeyID = "requestUser"
	// RequestIDKey is the context key for request IDs
	RequestIDKey KeyID = "requestID"
	// RequestStartTimeKey is the context key for the request start timestamp
	RequestStartTimeKey KeyID = "requestStartTime"
	// TraceIDKey is the context key for trace IDs
	TraceIDKey KeyID = "traceID"

	// AuthzDecisionKey is the context key for the authorization decision
	// Set by authorization middleware, used for logging
	AuthzDecisionKey KeyID = "authzDecision"

	// IsAnonymousRequestKey marks a request as explicitly anonymous
	// Set by auth middleware when no Authorization header is present
	IsAnonymousRequestKey KeyID = "isAnonymousRequest"

	// IsPreSignedRequestKey marks a request authenticated via pre-signed URL
	// Set by auth middleware when request uses query-based authentication
	IsPreSignedRequestKey KeyID = "isPreSignedRequest"

	// PreSignedExpiresAtKey stores the expiration time of the pre-signed URL
	// Used for auditing and logging purposes
	PreSignedExpiresAtKey KeyID = "preSignedExpiresAt"

	// ServiceAccountInfoKey holds service account metadata for policy evaluation.
	// Set by auth middleware when the authenticated access key belongs to a service account.
	ServiceAccountInfoKey KeyID = "serviceAccountInfo"

	// IsPostPolicyRequestKey marks a request authenticated via POST policy form upload.
	// Set by auth middleware when request uses multipart/form-data with a policy field.
	IsPostPolicyRequestKey KeyID = "isPostPolicyRequest"

	// PostPolicyPolicyB64Key stores the base64-encoded policy document from the form.
	// Used by the PostObject handler to validate conditions.
	PostPolicyPolicyB64Key KeyID = "postPolicyPolicyB64"
)

type ServiceAccountInfo

type ServiceAccountInfo struct {
	ParentUserUUID     *uuid.UUID     // UUID of the parent user (nil if no parent)
	PolicyMode         iam.PolicyMode // "inherit" or "override" (empty = inherit)
	EmbeddedPolicyJSON string         // raw IAM policy JSON; used directly in override mode
}

ServiceAccountInfo holds service account metadata used by the policy engine to resolve effective IAM policies at evaluation time.

func GetServiceAccountInfo

func GetServiceAccountInfo(ctx context.Context) *ServiceAccountInfo

GetServiceAccountInfo extracts service account metadata from the context. Returns nil if the request was not made by a service account.

Jump to

Keyboard shortcuts

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