auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package auth handles the AWS SSO OIDC device authorization flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceAuthInfo

type DeviceAuthInfo struct {
	VerificationURI string
	UserCode        string
}

DeviceAuthInfo holds information displayed to the user during authorization.

type OIDCClient

type OIDCClient interface {
	RegisterClient(ctx context.Context, params *ssooidc.RegisterClientInput, optFns ...func(*ssooidc.Options)) (*ssooidc.RegisterClientOutput, error)
	StartDeviceAuthorization(ctx context.Context, params *ssooidc.StartDeviceAuthorizationInput, optFns ...func(*ssooidc.Options)) (*ssooidc.StartDeviceAuthorizationOutput, error)
	CreateToken(ctx context.Context, params *ssooidc.CreateTokenInput, optFns ...func(*ssooidc.Options)) (*ssooidc.CreateTokenOutput, error)
}

OIDCClient defines the interface for SSO OIDC operations (for testability).

func NewOIDCClient

func NewOIDCClient(ctx context.Context, region string) (OIDCClient, error)

NewOIDCClient creates a real SSO OIDC client for the given region.

func NewOIDCClientFromConfig

func NewOIDCClientFromConfig(cfg aws.Config) OIDCClient

NewOIDCClientFromConfig creates a real SSO OIDC client from an existing AWS config. Use this to share a single LoadDefaultConfig call across multiple clients.

type StatusCallback

type StatusCallback func(status string)

StatusCallback is called during the auth flow to report status to the UI.

type TokenResult

type TokenResult struct {
	AccessToken string
	ExpiresAt   time.Time
}

TokenResult holds the access token obtained from SSO OIDC.

func Authenticate

func Authenticate(
	ctx context.Context,
	client OIDCClient,
	startURL string,
	onDeviceAuth func(DeviceAuthInfo),
	onStatus StatusCallback,
) (*TokenResult, error)

Authenticate performs the full SSO OIDC device authorization flow. It returns the access token needed to call GetRoleCredentials.

The onDeviceAuth callback is called with the device auth info so the caller can display the verification URL and user code to the user. The onStatus callback is called with status messages during polling.

Jump to

Keyboard shortcuts

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