aws_sdk_go_v2_sso_login

package module
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Go Reference Go Report Card Go codecov Release

AWS SDK Go V2 SSO Login

Package aws_sdk_go_v2_sso_login implements the AWS SSO OIDC flow, including optionally opening a browser with the AWS SSO auth URL.

THIS IS NOT AN OFFICIAL PART OF aws-sdk-go-v2. This was not created, endorsed, checked by Amazon/AWS.

Why This Package Exists

The official github.com/aws/aws-sdk-go-v2/service/sso does not contain a login function. AWS recommends using the AWS CLI aws sso login which requires the user has the AWS CLI installed on their system.

Goal of Package

This package's goal is to remove the need for a user to have anything installed when using AWS SSO, and enabling developers to create tools that do not need to rely on the AWS CLI.

Prerequisites

The user must have a ~/.aws/config file with at least one [profile <profileName>] section in it. Read these AWS docs for more information.

References

This package was inspired by, and aims to solve this GH issue: https://github.com/aws/aws-sdk-go-v2/issues/1222

Documentation

Overview

Package aws_sdk_go_v2_sso_login implements the AWS SSO OIDC flow, including optionally opening a browser with the AWS SSO auth URL.

THIS IS NOT AN OFFICIAL PART OF aws-sdk-go-v2. This was not created, endorsed, checked by Amazon/AWS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrowserOpenError added in v0.2.0

type BrowserOpenError struct {
	Err error
}

BrowserOpenError Failed to open a browser

func (BrowserOpenError) Error added in v0.2.0

func (e BrowserOpenError) Error() string

func (BrowserOpenError) Unwrap added in v0.2.0

func (e BrowserOpenError) Unwrap() error

type CacheFileCreationError added in v0.2.0

type CacheFileCreationError struct {
	Err           error
	Reason        string
	CacheFilePath string
}

func (CacheFileCreationError) Error added in v0.2.0

func (e CacheFileCreationError) Error() string

func (CacheFileCreationError) Unwrap added in v0.2.0

func (e CacheFileCreationError) Unwrap() error

type CacheFilepathGenerationError added in v0.2.0

type CacheFilepathGenerationError struct {
	ProfileName        string
	ProfileSSOStartURL string
	Err                error
}

CacheFilepathGenerationError failed to generate a valid filepath for the given SSO start URL

func NewCacheFilepathGenerationError added in v0.2.0

func NewCacheFilepathGenerationError(ProfileName string, ProfileSSOStartURL string, err error) CacheFilepathGenerationError

func (CacheFilepathGenerationError) Error added in v0.2.0

func (CacheFilepathGenerationError) Unwrap added in v0.2.0

type ConfigFileLoadError added in v0.2.0

type ConfigFileLoadError struct {
	Err error
}

ConfigFileLoadError failed to load default config

func (ConfigFileLoadError) Error added in v0.2.0

func (e ConfigFileLoadError) Error() string

func (ConfigFileLoadError) Unwrap added in v0.2.0

func (e ConfigFileLoadError) Unwrap() error

type CredCacheError added in v0.2.0

type CredCacheError struct {
	Err error
}

CredCacheError failed to retrieve creds from ssoCredsProvider

func (CredCacheError) Error added in v0.2.0

func (e CredCacheError) Error() string

func (CredCacheError) Unwrap added in v0.2.0

func (e CredCacheError) Unwrap() error

type GetCallerIdError added in v0.2.0

type GetCallerIdError struct {
	Err error
}

GetCallerIdError stsClient.GetCallerIdentity failed

func (GetCallerIdError) Error added in v0.2.0

func (e GetCallerIdError) Error() string

func (GetCallerIdError) Unwrap added in v0.2.0

func (e GetCallerIdError) Unwrap() error

type IdentityResult added in v0.1.0

type IdentityResult struct {
	Identity *sts.GetCallerIdentityOutput
	Error    error
}

IdentityResult contains the result of stsClient.GetCallerIdentity. If Identity is nul and error is not nul that can indicate that the credentials might be invalid.

type LoadingConfigFileError added in v0.2.0

type LoadingConfigFileError struct {
	ConfigFilePath string
	Err            error
}

LoadingConfigFileError failed to load the config file

func NewLoadingConfigFileError added in v0.2.0

func NewLoadingConfigFileError(configFilePath string, err error) LoadingConfigFileError

func (LoadingConfigFileError) Error added in v0.2.0

func (e LoadingConfigFileError) Error() string

func (LoadingConfigFileError) Unwrap added in v0.2.0

func (e LoadingConfigFileError) Unwrap() error

type LoginInput added in v0.0.7

type LoginInput struct {
	// ProfileName name of the profile in ~/.aws/config. [profile <ProfileName>]
	ProfileName string

	// LoginTimeout max time to wait for user to complete the SSO OIDC URL flow. This should be > 60 seconds. Default value is 90 seconds
	LoginTimeout time.Duration

	// Headed if true a browser will be opened with the URL for the SSO OIDC flow. You will have the [LoginTimeout] to
	// complete the flow in the browser.
	Headed bool

	// ForceLogin if true forces a new SSO OIDC flow even if the cached creds are still valid.
	ForceLogin bool
}

type LoginOutput added in v0.1.0

type LoginOutput struct {
	Config           *aws.Config
	Credentials      *aws.Credentials
	CredentialsCache *aws.CredentialsCache
	IdentityResult   *IdentityResult
}

func Login

func Login(ctx context.Context, params *LoginInput) (*LoginOutput, error)

Login runs through the AWS CLI login flow if there isn't a ~/.aws/sso/cache file with valid creds. If ForceLogin is true then the login flow will always be triggered even if the cache is valid

type MissingProfileError added in v0.2.0

type MissingProfileError struct {
	ProfileName    string
	ConfigFilePath string
	Err            error
}

MissingProfileError failed to find the requested profile

func NewMissingProfileError added in v0.2.0

func NewMissingProfileError(profileName string, configFilePath string, err error) MissingProfileError

func (MissingProfileError) Error added in v0.2.0

func (e MissingProfileError) Error() string

func (MissingProfileError) Unwrap added in v0.2.0

func (e MissingProfileError) Unwrap() error

type OsUserError added in v0.2.0

type OsUserError struct {
	Err error
}

OsUserError failed to retrieve user from osUser

func (OsUserError) Error added in v0.2.0

func (e OsUserError) Error() string

func (OsUserError) Unwrap added in v0.2.0

func (e OsUserError) Unwrap() error

type ProfileValidationError added in v0.2.0

type ProfileValidationError struct {
	ProfileName    string
	ConfigFilePath string
	FieldName      string
	CurrentValue   string
	ExpectedValue  string
}

ProfileValidationError error validating the given AWS profile. A required value may be missing.

func NewProfileValidationError added in v0.2.0

func NewProfileValidationError(profileName string, configFilePath string, fieldName string, currentValue string, expectedValue string) ProfileValidationError

func (ProfileValidationError) Error added in v0.2.0

func (e ProfileValidationError) Error() string

type SsoOidcClientError added in v0.2.0

type SsoOidcClientError struct {
	Err error
}

SsoOidcClientError Failed to register ssoOidcClient

func (SsoOidcClientError) Error added in v0.2.0

func (e SsoOidcClientError) Error() string

func (SsoOidcClientError) Unwrap added in v0.2.0

func (e SsoOidcClientError) Unwrap() error

type SsoOidcTokenCreationError added in v0.2.0

type SsoOidcTokenCreationError struct {
	Err error
}

SsoOidcTokenCreationError failed to retrieve user from osUser

func (SsoOidcTokenCreationError) Error added in v0.2.0

func (SsoOidcTokenCreationError) Unwrap added in v0.2.0

func (e SsoOidcTokenCreationError) Unwrap() error

type StartDeviceAuthorizationError added in v0.2.0

type StartDeviceAuthorizationError struct {
	Err error
}

StartDeviceAuthorizationError Failed to startDeviceAuthorization

func (StartDeviceAuthorizationError) Error added in v0.2.0

func (StartDeviceAuthorizationError) Unwrap added in v0.2.0

Jump to

Keyboard shortcuts

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