auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Slack user IDs always start with "U", so "anonymous" won't conflict
	AnonymousUserID    = "anonymous"
	AnonymousUserName  = "Anonymous"
	AnonymousUserEmail = "anonymous@localhost"
)

Anonymous user constants

View Source
const TokenExpireDuration = 7 * 24 * time.Hour

Variables

This section is empty.

Functions

func ContextWithToken

func ContextWithToken(ctx context.Context, token *Token) context.Context

func GetGoogleIAPJWTClaims

func GetGoogleIAPJWTClaims(ctx context.Context) (map[string]interface{}, error)

GetGoogleIAPJWTClaims retrieves Google IAP JWT claims from context

func GetGoogleIDTokenClaims

func GetGoogleIDTokenClaims(ctx context.Context) (map[string]interface{}, error)

GetGoogleIDTokenClaims retrieves Google ID token claims from context

func WithGoogleIAPJWTClaims

func WithGoogleIAPJWTClaims(ctx context.Context, claims map[string]interface{}) context.Context

func WithGoogleIDTokenClaims

func WithGoogleIDTokenClaims(ctx context.Context, claims map[string]interface{}) context.Context

func WithHTTPRequest

func WithHTTPRequest(ctx context.Context, req *HTTPRequest) context.Context

func WithSNSMessage

func WithSNSMessage(ctx context.Context, msg *message.SNS) context.Context

Types

type Context

type Context struct {
	Google map[string]interface{} `json:"google"`
	IAP    map[string]interface{} `json:"iap"`
	SNS    *message.SNS           `json:"sns"`

	Req *HTTPRequest      `json:"req"`
	Env map[string]string `json:"env" masq:"secret"`
}

func BuildContext

func BuildContext(ctx context.Context) Context

type HTTPRequest

type HTTPRequest struct {
	Method string              `json:"method"`
	Path   string              `json:"path"`
	Body   string              `json:"body"`
	Header map[string][]string `json:"header"`
}

type Token

type Token struct {
	ID        TokenID     `json:"id"`
	Secret    TokenSecret `json:"secret" masq:"secret"`
	Sub       string      `json:"sub"`
	Email     string      `json:"email"`
	Name      string      `json:"name"`
	ExpiresAt time.Time   `json:"expires_at"`
	CreatedAt time.Time   `json:"created_at"`
}

func NewAnonymousUser added in v0.1.0

func NewAnonymousUser() *Token

NewAnonymousUser creates a new anonymous user token

func NewToken

func NewToken(sub, email, name string) *Token

func TokenFromContext

func TokenFromContext(ctx context.Context) (*Token, error)

func (*Token) IsAnonymous added in v0.1.0

func (x *Token) IsAnonymous() bool

IsAnonymous returns true if the token represents an anonymous user

func (*Token) IsExpired

func (x *Token) IsExpired() bool

func (*Token) Validate

func (x *Token) Validate() error

type TokenID

type TokenID string

func NewTokenID

func NewTokenID() TokenID

func (TokenID) String

func (x TokenID) String() string

func (TokenID) Validate

func (x TokenID) Validate() error

type TokenSecret

type TokenSecret string

func NewTokenSecret

func NewTokenSecret() TokenSecret

func (TokenSecret) String

func (x TokenSecret) String() string

Jump to

Keyboard shortcuts

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