authctx

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSubject

func WithSubject(ctx context.Context, subject Subject) context.Context

WithSubject injects Subject into context Multiple subjects can be added (e.g., both IAP and Slack authentication) Returns a new context with the subject added, without modifying the original

Types

type Subject

type Subject struct {
	Type   SubjectType `json:"type"`
	UserID string      `json:"user_id"`
	Email  string      `json:"email,omitempty"`
}

Subject represents an authenticated subject (user or system)

func GetSubjects

func GetSubjects(ctx context.Context) []Subject

GetSubjects retrieves all Subjects from context Returns a copy of the slice containing all authenticated subjects If no subjects found, returns empty slice (non-nil) The returned slice is a copy to ensure immutability

func NewSubjectFromGoogleID

func NewSubjectFromGoogleID(claims map[string]interface{}) (Subject, error)

NewSubjectFromGoogleID creates Subject from Google ID token claims

func NewSubjectFromIAP

func NewSubjectFromIAP(claims map[string]interface{}) (Subject, error)

NewSubjectFromIAP creates Subject from IAP JWT claims

func NewSubjectFromSlackUser

func NewSubjectFromSlackUser(userID string) (Subject, error)

NewSubjectFromSlackUser creates Subject from Slack user information Returns error if userID is empty

type SubjectType

type SubjectType string

SubjectType represents the type of authentication source

const (
	SubjectTypeIAP      SubjectType = "iap"
	SubjectTypeGoogleID SubjectType = "google_id"
	SubjectTypeSlack    SubjectType = "slack"
)

Jump to

Keyboard shortcuts

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