Documentation
¶
Overview ¶
Package authctx defines context keys and accessor functions for credentials stored in a request context by authentication middleware.
This package is a domain-level leaf: it imports no auth sub-packages, so any package in the auth module can import it without creating import cycles.
Index ¶
- func AuthenticatedCustomClaimsFromContext(ctx context.Context) (map[string]any, bool)
- func AuthenticatedPrincipalFromContext(ctx context.Context) (string, bool)
- func AuthenticatedRegisteredClaimsFromContext(ctx context.Context) (jwtvalidator.RegisteredClaims, bool)
- func ContextWithAuthenticatedCustomClaims(ctx context.Context, claims map[string]any) context.Context
- func ContextWithAuthenticatedPrincipal(ctx context.Context, principal string) context.Context
- func ContextWithAuthenticatedRegisteredClaims(ctx context.Context, claims jwtvalidator.RegisteredClaims) context.Context
- func NewContextWithGitHubUserInfo(ctx context.Context, userInfo *GitHubUserInfo) context.Context
- type GitHubUserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticatedCustomClaimsFromContext ¶
AuthenticatedCustomClaimsFromContext extracts the authenticated claims from context.
func AuthenticatedPrincipalFromContext ¶
AuthenticatedPrincipalFromContext extracts the authenticated principal from context.
func AuthenticatedRegisteredClaimsFromContext ¶
func AuthenticatedRegisteredClaimsFromContext(ctx context.Context) (jwtvalidator.RegisteredClaims, bool)
AuthenticatedRegisteredClaimsFromContext extracts the authenticated claims from context.
func ContextWithAuthenticatedCustomClaims ¶
func ContextWithAuthenticatedCustomClaims(ctx context.Context, claims map[string]any) context.Context
ContextWithAuthenticatedCustomClaims stores the authenticated claims on the context.
func ContextWithAuthenticatedPrincipal ¶
ContextWithAuthenticatedPrincipal stores the authenticated principal on the context.
func ContextWithAuthenticatedRegisteredClaims ¶
func ContextWithAuthenticatedRegisteredClaims(ctx context.Context, claims jwtvalidator.RegisteredClaims) context.Context
ContextWithAuthenticatedRegisteredClaims stores the authenticated claims on the context.
func NewContextWithGitHubUserInfo ¶
func NewContextWithGitHubUserInfo(ctx context.Context, userInfo *GitHubUserInfo) context.Context
NewContextWithGitHubUserInfo returns a new context with the provided GitHub user info.
Types ¶
type GitHubUserInfo ¶
type GitHubUserInfo struct {
Login string
Name string
PrimaryEmail string
PrimaryEmailVerified bool
Company string
WebSite string
Location string
PlanName string
}
GitHubUserInfo contains information about a GitHub user.
func GitHubUserInfoFromContext ¶
func GitHubUserInfoFromContext(ctx context.Context) *GitHubUserInfo
GitHubUserInfoFromContext returns the GitHub user info from the provided context. It returns nil if no user info is found.