auth

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bearer

func Bearer(ctx context.Context) string

Bearer returns a raw bearer token from context, if present.

func ExtractBearer

func ExtractBearer(authzHeader string) string

ExtractBearer strips the Bearer prefix from an Authorization header value.

func WithBearer

func WithBearer(ctx context.Context, token string) context.Context

WithBearer stores a raw bearer token in context.

func WithUserInfo

func WithUserInfo(ctx context.Context, info *UserInfo) context.Context

WithUserInfo stores identity data in context.

Types

type UserInfo

type UserInfo struct {
	Subject string
	Email   string
}

UserInfo carries minimal identity extracted from a bearer token.

func DecodeUserInfo

func DecodeUserInfo(token string) (*UserInfo, error)

DecodeUserInfo parses a JWT token payload without verifying signature and extracts common identity fields (email, sub). It returns nil when parsing fails or when no useful claims are present.

func User

func User(ctx context.Context) *UserInfo

User returns identity data from context when available.

Jump to

Keyboard shortcuts

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