Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 6 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 CanonicalUserID

func CanonicalUserID(ctx context.Context) string

CanonicalUserID returns the canonical Agently users.id from context, or an empty string when no canonical owner has been resolved. Callers persisting delegated (per-provider) credentials must fail closed on empty results and must never fall back to EffectiveUserID.

func EffectiveUserID

func EffectiveUserID(ctx context.Context) string

EffectiveUserID returns a stable user identifier from context (subject or email). Returns empty string when no identity is present.

func IDToken

func IDToken(ctx context.Context) string

IDToken returns a raw ID token from context, if present.

func MCPAuthToken

func MCPAuthToken(ctx context.Context, useIDToken bool) string

MCPAuthToken selects a single token string suitable for outbound MCP calls. When useIDToken is true, it prefers a live IDToken and falls back to the access token or legacy bearer when the ID token has expired. When false, it prefers AccessToken and falls back to the legacy bearer key.

func Provider

func Provider(ctx context.Context) string

Provider returns the auth provider name from context, if present.

func TokensFromContext

func TokensFromContext(ctx context.Context) *scyauth.Token

TokensFromContext returns the token bundle from context, if present.

func WithBearer

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

WithBearer stores a raw bearer token in context.

func WithCanonicalUserID

func WithCanonicalUserID(ctx context.Context, id string) context.Context

WithCanonicalUserID stores the canonical Agently users.id resolved for the verified workspace identity. It is a persistence identity only: it never replaces EffectiveUserID, which stays on the workspace provider subject/email for the entire request lifetime.

func WithIDToken

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

WithIDToken stores a raw ID token in context.

func WithProvider

func WithProvider(ctx context.Context, provider string) context.Context

WithProvider stores an auth provider name in context.

func WithTokens

func WithTokens(ctx context.Context, t *scyauth.Token) context.Context

WithTokens stores a token bundle in context.

func WithUserInfo

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

WithUserInfo stores identity data in context.

func WithoutTokens

func WithoutTokens(ctx context.Context) context.Context

WithoutTokens returns a child context that masks token and downstream auth values inherited from its parent. It is used when stale credentials must be preserved in storage but must not be sent to downstream services.

Types

type UserInfo

type UserInfo struct {
	Subject string
	Email   string
}

UserInfo carries minimal identity extracted from a bearer token.

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