vendor: github.com/aws/aws-sdk-go-v2/config v1.26.6

vendor github.com/aws/aws-sdk-go-v2/config v1.26.6 and related dependencies.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-02-05 18:08:03 +01:00
parent 089982153f
commit 43ed470208
190 changed files with 12340 additions and 13837 deletions

View File

@ -1,3 +1,158 @@
# v1.21.7 (2024-01-16)
* No change notes available for this release.
# v1.21.6 (2024-01-04)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.5 (2023-12-08)
* **Bug Fix**: Reinstate presence of default Retryer in functional options, but still respect max attempts set therein.
# v1.21.4 (2023-12-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.3 (2023-12-06)
* **Bug Fix**: Restore pre-refactor auth behavior where all operations could technically be performed anonymously.
# v1.21.2 (2023-12-01)
* **Bug Fix**: Correct wrapping of errors in authentication workflow.
* **Bug Fix**: Correctly recognize cache-wrapped instances of AnonymousCredentials at client construction.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.1 (2023-11-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.0 (2023-11-29)
* **Feature**: Expose Options() accessor on service clients.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.20.3 (2023-11-28.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.20.2 (2023-11-28)
* **Bug Fix**: Respect setting RetryMaxAttempts in functional options at client construction.
# v1.20.1 (2023-11-20)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.20.0 (2023-11-17)
* **Feature**: Adding support for `sso-oauth:CreateTokenWithIAM`.
# v1.19.2 (2023-11-15)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.1 (2023-11-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.0 (2023-11-01)
* **Feature**: Adds support for configured endpoints via environment variables and the AWS shared configuration file.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.0 (2023-10-31)
* **Feature**: **BREAKING CHANGE**: Bump minimum go version to 1.19 per the revised [go version support policy](https://aws.amazon.com/blogs/developer/aws-sdk-for-go-aligns-with-go-release-policy-on-supported-runtimes/).
* **Dependency Update**: Updated to the latest SDK module versions
# v1.17.3 (2023-10-12)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.17.2 (2023-10-06)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.17.1 (2023-09-22)
* No change notes available for this release.
# v1.17.0 (2023-09-20)
* **Feature**: Update FIPS endpoints in aws-us-gov.
# v1.16.0 (2023-09-18)
* **Announcement**: [BREAKFIX] Change in MaxResults datatype from value to pointer type in cognito-sync service.
* **Feature**: Adds several endpoint ruleset changes across all models: smaller rulesets, removed non-unique regional endpoints, fixes FIPS and DualStack endpoints, and make region not required in SDK::Endpoint. Additional breakfix to cognito-sync field.
# v1.15.6 (2023-09-05)
* No change notes available for this release.
# v1.15.5 (2023-08-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.15.4 (2023-08-18)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.15.3 (2023-08-17)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.15.2 (2023-08-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.15.1 (2023-08-01)
* No change notes available for this release.
# v1.15.0 (2023-07-31)
* **Feature**: Adds support for smithy-modeled endpoint resolution. A new rules-based endpoint resolution will be added to the SDK which will supercede and deprecate existing endpoint resolution. Specifically, EndpointResolver will be deprecated while BaseEndpoint and EndpointResolverV2 will take its place. For more information, please see the Endpoints section in our Developer Guide.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.14 (2023-07-28)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.13 (2023-07-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.12 (2023-06-15)
* No change notes available for this release.
# v1.14.11 (2023-06-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.10 (2023-05-04)
* No change notes available for this release.
# v1.14.9 (2023-04-24)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.8 (2023-04-10)
* No change notes available for this release.
# v1.14.7 (2023-04-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.6 (2023-03-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.5 (2023-03-10)
* **Dependency Update**: Updated to the latest SDK module versions

View File

@ -4,12 +4,15 @@ package ssooidc
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/defaults"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
internalauth "github.com/aws/aws-sdk-go-v2/internal/auth"
internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy"
internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources"
smithy "github.com/aws/smithy-go"
smithydocument "github.com/aws/smithy-go/document"
@ -45,12 +48,22 @@ func New(options Options, optFns ...func(*Options)) *Client {
resolveHTTPSignerV4(&options)
resolveDefaultEndpointConfiguration(&options)
resolveEndpointResolverV2(&options)
resolveAuthSchemeResolver(&options)
for _, fn := range optFns {
fn(&options)
}
finalizeRetryMaxAttempts(&options)
ignoreAnonymousAuth(&options)
wrapWithAnonymousAuth(&options)
resolveAuthSchemes(&options)
client := &Client{
options: options,
}
@ -58,115 +71,25 @@ func New(options Options, optFns ...func(*Options)) *Client {
return client
}
type Options struct {
// Set of options to modify how an operation is invoked. These apply to all
// operations invoked for this client. Use functional options on operation call to
// modify this list for per operation behavior.
APIOptions []func(*middleware.Stack) error
// Configures the events that will be sent to the configured logger.
ClientLogMode aws.ClientLogMode
// The credentials object to use when signing requests.
Credentials aws.CredentialsProvider
// The configuration DefaultsMode that the SDK should use when constructing the
// clients initial default settings.
DefaultsMode aws.DefaultsMode
// The endpoint options to be used when attempting to resolve an endpoint.
EndpointOptions EndpointResolverOptions
// The service endpoint resolver.
EndpointResolver EndpointResolver
// Signature Version 4 (SigV4) Signer
HTTPSignerV4 HTTPSignerV4
// The logger writer interface to write logging messages to.
Logger logging.Logger
// The region to send requests to. (Required)
Region string
// RetryMaxAttempts specifies the maximum number attempts an API client will call
// an operation that fails with a retryable error. A value of 0 is ignored, and
// will not be used to configure the API client created default retryer, or modify
// per operation call's retry max attempts. When creating a new API Clients this
// member will only be used if the Retryer Options member is nil. This value will
// be ignored if Retryer is not nil. If specified in an operation call's functional
// options with a value that is different than the constructed client's Options,
// the Client's Retryer will be wrapped to use the operation's specific
// RetryMaxAttempts value.
RetryMaxAttempts int
// RetryMode specifies the retry mode the API client will be created with, if
// Retryer option is not also specified. When creating a new API Clients this
// member will only be used if the Retryer Options member is nil. This value will
// be ignored if Retryer is not nil. Currently does not support per operation call
// overrides, may in the future.
RetryMode aws.RetryMode
// Retryer guides how HTTP requests should be retried in case of recoverable
// failures. When nil the API client will use a default retryer. The kind of
// default retry created by the API client can be changed with the RetryMode
// option.
Retryer aws.Retryer
// The RuntimeEnvironment configuration, only populated if the DefaultsMode is set
// to DefaultsModeAuto and is initialized using config.LoadDefaultConfig. You
// should not populate this structure programmatically, or rely on the values here
// within your applications.
RuntimeEnvironment aws.RuntimeEnvironment
// The initial DefaultsMode used when the client options were constructed. If the
// DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved
// value was at that point in time. Currently does not support per operation call
// overrides, may in the future.
resolvedDefaultsMode aws.DefaultsMode
// The HTTP client to invoke API calls with. Defaults to client's default HTTP
// implementation if nil.
HTTPClient HTTPClient
// Options returns a copy of the client configuration.
//
// Callers SHOULD NOT perform mutations on any inner structures within client
// config. Config overrides should instead be made on a per-operation basis through
// functional options.
func (c *Client) Options() Options {
return c.options.Copy()
}
// WithAPIOptions returns a functional option for setting the Client's APIOptions
// option.
func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) {
return func(o *Options) {
o.APIOptions = append(o.APIOptions, optFns...)
}
}
// WithEndpointResolver returns a functional option for setting the Client's
// EndpointResolver option.
func WithEndpointResolver(v EndpointResolver) func(*Options) {
return func(o *Options) {
o.EndpointResolver = v
}
}
type HTTPClient interface {
Do(*http.Request) (*http.Response, error)
}
// Copy creates a clone where the APIOptions list is deep copied.
func (o Options) Copy() Options {
to := o
to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions))
copy(to.APIOptions, o.APIOptions)
return to
}
func (c *Client) invokeOperation(ctx context.Context, opID string, params interface{}, optFns []func(*Options), stackFns ...func(*middleware.Stack, Options) error) (result interface{}, metadata middleware.Metadata, err error) {
ctx = middleware.ClearStackValues(ctx)
stack := middleware.NewStack(opID, smithyhttp.NewStackRequest)
options := c.options.Copy()
for _, fn := range optFns {
fn(&options)
}
finalizeRetryMaxAttemptOptions(&options, *c)
finalizeOperationRetryMaxAttempts(&options, *c)
finalizeClientEndpointResolverOptions(&options)
@ -194,8 +117,89 @@ func (c *Client) invokeOperation(ctx context.Context, opID string, params interf
return result, metadata, err
}
type operationInputKey struct{}
func setOperationInput(ctx context.Context, input interface{}) context.Context {
return middleware.WithStackValue(ctx, operationInputKey{}, input)
}
func getOperationInput(ctx context.Context) interface{} {
return middleware.GetStackValue(ctx, operationInputKey{})
}
type setOperationInputMiddleware struct {
}
func (*setOperationInputMiddleware) ID() string {
return "setOperationInput"
}
func (m *setOperationInputMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
ctx = setOperationInput(ctx, in.Parameters)
return next.HandleSerialize(ctx, in)
}
func addProtocolFinalizerMiddlewares(stack *middleware.Stack, options Options, operation string) error {
if err := stack.Finalize.Add(&resolveAuthSchemeMiddleware{operation: operation, options: options}, middleware.Before); err != nil {
return fmt.Errorf("add ResolveAuthScheme: %w", err)
}
if err := stack.Finalize.Insert(&getIdentityMiddleware{options: options}, "ResolveAuthScheme", middleware.After); err != nil {
return fmt.Errorf("add GetIdentity: %v", err)
}
if err := stack.Finalize.Insert(&resolveEndpointV2Middleware{options: options}, "GetIdentity", middleware.After); err != nil {
return fmt.Errorf("add ResolveEndpointV2: %v", err)
}
if err := stack.Finalize.Insert(&signRequestMiddleware{}, "ResolveEndpointV2", middleware.After); err != nil {
return fmt.Errorf("add Signing: %w", err)
}
return nil
}
func resolveAuthSchemeResolver(options *Options) {
if options.AuthSchemeResolver == nil {
options.AuthSchemeResolver = &defaultAuthSchemeResolver{}
}
}
func resolveAuthSchemes(options *Options) {
if options.AuthSchemes == nil {
options.AuthSchemes = []smithyhttp.AuthScheme{
internalauth.NewHTTPAuthScheme("aws.auth#sigv4", &internalauthsmithy.V4SignerAdapter{
Signer: options.HTTPSignerV4,
Logger: options.Logger,
LogSigning: options.ClientLogMode.IsSigning(),
}),
}
}
}
type noSmithyDocumentSerde = smithydocument.NoSerde
type legacyEndpointContextSetter struct {
LegacyResolver EndpointResolver
}
func (*legacyEndpointContextSetter) ID() string {
return "legacyEndpointContextSetter"
}
func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
if m.LegacyResolver != nil {
ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true)
}
return next.HandleInitialize(ctx, in)
}
func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error {
return stack.Initialize.Add(&legacyEndpointContextSetter{
LegacyResolver: o.EndpointResolver,
}, middleware.Before)
}
func resolveDefaultLogger(o *Options) {
if o.Logger != nil {
return
@ -233,6 +237,7 @@ func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client {
APIOptions: cfg.APIOptions,
Logger: cfg.Logger,
ClientLogMode: cfg.ClientLogMode,
AppID: cfg.AppID,
}
resolveAWSRetryerProvider(cfg, &opts)
resolveAWSRetryMaxAttempts(cfg, &opts)
@ -240,6 +245,7 @@ func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client {
resolveAWSEndpointResolver(cfg, &opts)
resolveUseDualStackEndpoint(cfg, &opts)
resolveUseFIPSEndpoint(cfg, &opts)
resolveBaseEndpoint(cfg, &opts)
return New(opts, optFns...)
}
@ -331,7 +337,15 @@ func resolveAWSRetryMaxAttempts(cfg aws.Config, o *Options) {
o.RetryMaxAttempts = cfg.RetryMaxAttempts
}
func finalizeRetryMaxAttemptOptions(o *Options, client Client) {
func finalizeRetryMaxAttempts(o *Options) {
if o.RetryMaxAttempts == 0 {
return
}
o.Retryer = retry.AddWithMaxAttempts(o.Retryer, o.RetryMaxAttempts)
}
func finalizeOperationRetryMaxAttempts(o *Options, client Client) {
if v := o.RetryMaxAttempts; v == 0 || v == client.options.RetryMaxAttempts {
return
}
@ -343,20 +357,19 @@ func resolveAWSEndpointResolver(cfg aws.Config, o *Options) {
if cfg.EndpointResolver == nil && cfg.EndpointResolverWithOptions == nil {
return
}
o.EndpointResolver = withEndpointResolver(cfg.EndpointResolver, cfg.EndpointResolverWithOptions, NewDefaultEndpointResolver())
o.EndpointResolver = withEndpointResolver(cfg.EndpointResolver, cfg.EndpointResolverWithOptions)
}
func addClientUserAgent(stack *middleware.Stack) error {
return awsmiddleware.AddSDKAgentKeyValue(awsmiddleware.APIMetadata, "ssooidc", goModuleVersion)(stack)
}
func addClientUserAgent(stack *middleware.Stack, options Options) error {
if err := awsmiddleware.AddSDKAgentKeyValue(awsmiddleware.APIMetadata, "ssooidc", goModuleVersion)(stack); err != nil {
return err
}
func addHTTPSignerV4Middleware(stack *middleware.Stack, o Options) error {
mw := v4.NewSignHTTPRequestMiddleware(v4.SignHTTPRequestMiddlewareOptions{
CredentialsProvider: o.Credentials,
Signer: o.HTTPSignerV4,
LogSigning: o.ClientLogMode.IsSigning(),
})
return stack.Finalize.Add(mw, middleware.After)
if len(options.AppID) > 0 {
return awsmiddleware.AddSDKAgentKey(awsmiddleware.ApplicationIdentifier, options.AppID)(stack)
}
return nil
}
type HTTPSignerV4 interface {
@ -431,3 +444,32 @@ func addRequestResponseLogging(stack *middleware.Stack, o Options) error {
LogResponseWithBody: o.ClientLogMode.IsResponseWithBody(),
}, middleware.After)
}
type disableHTTPSMiddleware struct {
DisableHTTPS bool
}
func (*disableHTTPSMiddleware) ID() string {
return "disableHTTPS"
}
func (m *disableHTTPSMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if m.DisableHTTPS && !smithyhttp.GetHostnameImmutable(ctx) {
req.URL.Scheme = "http"
}
return next.HandleFinalize(ctx, in)
}
func addDisableHTTPSMiddleware(stack *middleware.Stack, o Options) error {
return stack.Finalize.Insert(&disableHTTPSMiddleware{
DisableHTTPS: o.EndpointOptions.DisableHTTPS,
}, "ResolveEndpointV2", middleware.After)
}

View File

@ -4,14 +4,16 @@ package ssooidc
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates and returns an access token for the authorized client. The access token
// issued will be used to fetch short-term credentials for the assigned roles in
// the AWS account.
// Creates and returns access and refresh tokens for clients that are
// authenticated using client secrets. The access token can be used to fetch
// short-term credentials for the assigned AWS accounts or to access application
// APIs using bearer authentication.
func (c *Client) CreateToken(ctx context.Context, params *CreateTokenInput, optFns ...func(*Options)) (*CreateTokenOutput, error) {
if params == nil {
params = &CreateTokenInput{}
@ -29,8 +31,8 @@ func (c *Client) CreateToken(ctx context.Context, params *CreateTokenInput, optF
type CreateTokenInput struct {
// The unique identifier string for each client. This value should come from the
// persisted result of the RegisterClient API.
// The unique identifier string for the client or application. This value comes
// from the result of the RegisterClient API.
//
// This member is required.
ClientId *string
@ -41,38 +43,42 @@ type CreateTokenInput struct {
// This member is required.
ClientSecret *string
// Supports grant types for the authorization code, refresh token, and device code
// request. For device code requests, specify the following value:
// urn:ietf:params:oauth:grant-type:device_code For information about how to
// obtain the device code, see the StartDeviceAuthorization topic.
// Supports the following OAuth grant types: Device Code and Refresh Token.
// Specify either of the following values, depending on the grant type that you
// want: * Device Code - urn:ietf:params:oauth:grant-type:device_code * Refresh
// Token - refresh_token For information about how to obtain the device code, see
// the StartDeviceAuthorization topic.
//
// This member is required.
GrantType *string
// The authorization code received from the authorization service. This parameter
// is required to perform an authorization grant request to get access to a token.
// Used only when calling this API for the Authorization Code grant type. The
// short-term code is used to identify this authorization request. This grant type
// is currently unsupported for the CreateToken API.
Code *string
// Used only when calling this API for the device code grant type. This short-term
// code is used to identify this authentication attempt. This should come from an
// in-memory reference to the result of the StartDeviceAuthorization API.
// Used only when calling this API for the Device Code grant type. This short-term
// code is used to identify this authorization request. This comes from the result
// of the StartDeviceAuthorization API.
DeviceCode *string
// The location of the application that will receive the authorization code. Users
// authorize the service to send the request to this location.
// Used only when calling this API for the Authorization Code grant type. This
// value specifies the location of the client or application that has registered to
// receive the authorization code.
RedirectUri *string
// Currently, refreshToken is not yet implemented and is not supported. For more
// information about the features and limitations of the current IAM Identity
// Center OIDC implementation, see Considerations for Using this Guide in the IAM
// Identity Center OIDC API Reference
// (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html).
// The token used to obtain an access token in the event that the access token is
// invalid or expired.
// Used only when calling this API for the Refresh Token grant type. This token is
// used to refresh short-term tokens, such as the access token, that might expire.
// For more information about the features and limitations of the current IAM
// Identity Center OIDC implementation, see Considerations for Using this Guide in
// the IAM Identity Center OIDC API Reference (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html)
// .
RefreshToken *string
// The list of scopes that is defined by the client. Upon authorization, this list
// is used to restrict permissions when granting an access token.
// The list of scopes for which authorization is requested. The access token that
// is issued is limited to the scopes that are granted. If this value is not
// specified, IAM Identity Center authorizes all scopes that are configured for the
// client during the call to RegisterClient .
Scope []string
noSmithyDocumentSerde
@ -80,31 +86,30 @@ type CreateTokenInput struct {
type CreateTokenOutput struct {
// An opaque token to access IAM Identity Center resources assigned to a user.
// A bearer token to access AWS accounts and applications assigned to a user.
AccessToken *string
// Indicates the time in seconds when an access token will expire.
ExpiresIn int32
// Currently, idToken is not yet implemented and is not supported. For more
// information about the features and limitations of the current IAM Identity
// Center OIDC implementation, see Considerations for Using this Guide in the IAM
// Identity Center OIDC API Reference
// (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html).
// The identifier of the user that associated with the access token, if present.
// The idToken is not implemented or supported. For more information about the
// features and limitations of the current IAM Identity Center OIDC implementation,
// see Considerations for Using this Guide in the IAM Identity Center OIDC API
// Reference (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html)
// . A JSON Web Token (JWT) that identifies who is associated with the issued
// access token.
IdToken *string
// Currently, refreshToken is not yet implemented and is not supported. For more
// information about the features and limitations of the current IAM Identity
// Center OIDC implementation, see Considerations for Using this Guide in the IAM
// Identity Center OIDC API Reference
// (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html).
// A token that, if present, can be used to refresh a previously issued access
// token that might have expired.
// token that might have expired. For more information about the features and
// limitations of the current IAM Identity Center OIDC implementation, see
// Considerations for Using this Guide in the IAM Identity Center OIDC API
// Reference (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html)
// .
RefreshToken *string
// Used to notify the client that the returned token is an access token. The
// supported type is BearerToken.
// supported token type is Bearer .
TokenType *string
// Metadata pertaining to the operation's result.
@ -114,6 +119,9 @@ type CreateTokenOutput struct {
}
func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateToken{}, middleware.After)
if err != nil {
return err
@ -122,6 +130,13 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateToken"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
@ -143,7 +158,7 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack); err != nil {
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
@ -152,12 +167,18 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpCreateTokenValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateToken(options.Region), middleware.Before); err != nil {
return err
}
if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
@ -167,6 +188,9 @@ func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, opt
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,230 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package ssooidc
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates and returns access and refresh tokens for clients and applications that
// are authenticated using IAM entities. The access token can be used to fetch
// short-term credentials for the assigned AWS accounts or to access application
// APIs using bearer authentication.
func (c *Client) CreateTokenWithIAM(ctx context.Context, params *CreateTokenWithIAMInput, optFns ...func(*Options)) (*CreateTokenWithIAMOutput, error) {
if params == nil {
params = &CreateTokenWithIAMInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateTokenWithIAM", params, optFns, c.addOperationCreateTokenWithIAMMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateTokenWithIAMOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateTokenWithIAMInput struct {
// The unique identifier string for the client or application. This value is an
// application ARN that has OAuth grants configured.
//
// This member is required.
ClientId *string
// Supports the following OAuth grant types: Authorization Code, Refresh Token,
// JWT Bearer, and Token Exchange. Specify one of the following values, depending
// on the grant type that you want: * Authorization Code - authorization_code *
// Refresh Token - refresh_token * JWT Bearer -
// urn:ietf:params:oauth:grant-type:jwt-bearer * Token Exchange -
// urn:ietf:params:oauth:grant-type:token-exchange
//
// This member is required.
GrantType *string
// Used only when calling this API for the JWT Bearer grant type. This value
// specifies the JSON Web Token (JWT) issued by a trusted token issuer. To
// authorize a trusted token issuer, configure the JWT Bearer GrantOptions for the
// application.
Assertion *string
// Used only when calling this API for the Authorization Code grant type. This
// short-term code is used to identify this authorization request. The code is
// obtained through a redirect from IAM Identity Center to a redirect URI persisted
// in the Authorization Code GrantOptions for the application.
Code *string
// Used only when calling this API for the Authorization Code grant type. This
// value specifies the location of the client or application that has registered to
// receive the authorization code.
RedirectUri *string
// Used only when calling this API for the Refresh Token grant type. This token is
// used to refresh short-term tokens, such as the access token, that might expire.
// For more information about the features and limitations of the current IAM
// Identity Center OIDC implementation, see Considerations for Using this Guide in
// the IAM Identity Center OIDC API Reference (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html)
// .
RefreshToken *string
// Used only when calling this API for the Token Exchange grant type. This value
// specifies the type of token that the requester can receive. The following values
// are supported: * Access Token - urn:ietf:params:oauth:token-type:access_token *
// Refresh Token - urn:ietf:params:oauth:token-type:refresh_token
RequestedTokenType *string
// The list of scopes for which authorization is requested. The access token that
// is issued is limited to the scopes that are granted. If the value is not
// specified, IAM Identity Center authorizes all scopes configured for the
// application, including the following default scopes: openid , aws ,
// sts:identity_context .
Scope []string
// Used only when calling this API for the Token Exchange grant type. This value
// specifies the subject of the exchange. The value of the subject token must be an
// access token issued by IAM Identity Center to a different client or application.
// The access token must have authorized scopes that indicate the requested
// application as a target audience.
SubjectToken *string
// Used only when calling this API for the Token Exchange grant type. This value
// specifies the type of token that is passed as the subject of the exchange. The
// following value is supported: * Access Token -
// urn:ietf:params:oauth:token-type:access_token
SubjectTokenType *string
noSmithyDocumentSerde
}
type CreateTokenWithIAMOutput struct {
// A bearer token to access AWS accounts and applications assigned to a user.
AccessToken *string
// Indicates the time in seconds when an access token will expire.
ExpiresIn int32
// A JSON Web Token (JWT) that identifies the user associated with the issued
// access token.
IdToken *string
// Indicates the type of tokens that are issued by IAM Identity Center. The
// following values are supported: * Access Token -
// urn:ietf:params:oauth:token-type:access_token * Refresh Token -
// urn:ietf:params:oauth:token-type:refresh_token
IssuedTokenType *string
// A token that, if present, can be used to refresh a previously issued access
// token that might have expired. For more information about the features and
// limitations of the current IAM Identity Center OIDC implementation, see
// Considerations for Using this Guide in the IAM Identity Center OIDC API
// Reference (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html)
// .
RefreshToken *string
// The list of scopes for which authorization is granted. The access token that is
// issued is limited to the scopes that are granted.
Scope []string
// Used to notify the requester that the returned token is an access token. The
// supported token type is Bearer .
TokenType *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateTokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateTokenWithIAM{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateTokenWithIAM{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateTokenWithIAM"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
return err
}
if err = addRetryMiddlewares(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
return err
}
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpCreateTokenWithIAMValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateTokenWithIAM(options.Region), middleware.Before); err != nil {
return err
}
if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateTokenWithIAM(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "CreateTokenWithIAM",
}
}

View File

@ -4,6 +4,7 @@ package ssooidc
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
@ -40,8 +41,8 @@ type RegisterClientInput struct {
// This member is required.
ClientType *string
// The list of scopes that are defined by the client. Upon authorization, this list
// is used to restrict permissions when granting an access token.
// The list of scopes that are defined by the client. Upon authorization, this
// list is used to restrict permissions when granting an access token.
Scopes []string
noSmithyDocumentSerde
@ -49,7 +50,7 @@ type RegisterClientInput struct {
type RegisterClientOutput struct {
// The endpoint where the client can request authorization.
// An endpoint that the client can use to request authorization.
AuthorizationEndpoint *string
// The unique identifier string for each client. This client uses this identifier
@ -59,14 +60,14 @@ type RegisterClientOutput struct {
// Indicates the time at which the clientId and clientSecret were issued.
ClientIdIssuedAt int64
// A secret string generated for the client. The client will use this string to get
// authenticated by the service in subsequent calls.
// A secret string generated for the client. The client will use this string to
// get authenticated by the service in subsequent calls.
ClientSecret *string
// Indicates the time at which the clientId and clientSecret will become invalid.
ClientSecretExpiresAt int64
// The endpoint where the client can get an access token.
// An endpoint that the client can use to create tokens.
TokenEndpoint *string
// Metadata pertaining to the operation's result.
@ -76,6 +77,9 @@ type RegisterClientOutput struct {
}
func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsRestjson1_serializeOpRegisterClient{}, middleware.After)
if err != nil {
return err
@ -84,6 +88,13 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack,
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "RegisterClient"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
@ -105,7 +116,7 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack,
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack); err != nil {
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
@ -114,12 +125,18 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack,
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpRegisterClientValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opRegisterClient(options.Region), middleware.Before); err != nil {
return err
}
if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
@ -129,6 +146,9 @@ func (c *Client) addOperationRegisterClientMiddlewares(stack *middleware.Stack,
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}

View File

@ -4,6 +4,7 @@ package ssooidc
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
@ -28,9 +29,9 @@ func (c *Client) StartDeviceAuthorization(ctx context.Context, params *StartDevi
type StartDeviceAuthorizationInput struct {
// The unique identifier string for the client that is registered with IAM Identity
// Center. This value should come from the persisted result of the RegisterClient
// API operation.
// The unique identifier string for the client that is registered with IAM
// Identity Center. This value should come from the persisted result of the
// RegisterClient API operation.
//
// This member is required.
ClientId *string
@ -41,9 +42,8 @@ type StartDeviceAuthorizationInput struct {
// This member is required.
ClientSecret *string
// The URL for the AWS access portal. For more information, see Using the AWS
// access portal
// (https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html)
// The URL for the Amazon Web Services access portal. For more information, see
// Using the Amazon Web Services access portal (https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html)
// in the IAM Identity Center User Guide.
//
// This member is required.
@ -73,9 +73,9 @@ type StartDeviceAuthorizationOutput struct {
// device.
VerificationUri *string
// An alternate URL that the client can use to automatically launch a browser. This
// process skips the manual step in which the user visits the verification page and
// enters their code.
// An alternate URL that the client can use to automatically launch a browser.
// This process skips the manual step in which the user visits the verification
// page and enters their code.
VerificationUriComplete *string
// Metadata pertaining to the operation's result.
@ -85,6 +85,9 @@ type StartDeviceAuthorizationOutput struct {
}
func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsRestjson1_serializeOpStartDeviceAuthorization{}, middleware.After)
if err != nil {
return err
@ -93,6 +96,13 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "StartDeviceAuthorization"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
@ -114,7 +124,7 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack); err != nil {
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
@ -123,12 +133,18 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpStartDeviceAuthorizationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartDeviceAuthorization(options.Region), middleware.Before); err != nil {
return err
}
if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
@ -138,6 +154,9 @@ func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middlewa
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,302 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package ssooidc
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
smithy "github.com/aws/smithy-go"
smithyauth "github.com/aws/smithy-go/auth"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
func bindAuthParamsRegion(params *AuthResolverParameters, _ interface{}, options Options) {
params.Region = options.Region
}
type setLegacyContextSigningOptionsMiddleware struct {
}
func (*setLegacyContextSigningOptionsMiddleware) ID() string {
return "setLegacyContextSigningOptions"
}
func (m *setLegacyContextSigningOptionsMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
rscheme := getResolvedAuthScheme(ctx)
schemeID := rscheme.Scheme.SchemeID()
if sn := awsmiddleware.GetSigningName(ctx); sn != "" {
if schemeID == "aws.auth#sigv4" {
smithyhttp.SetSigV4SigningName(&rscheme.SignerProperties, sn)
} else if schemeID == "aws.auth#sigv4a" {
smithyhttp.SetSigV4ASigningName(&rscheme.SignerProperties, sn)
}
}
if sr := awsmiddleware.GetSigningRegion(ctx); sr != "" {
if schemeID == "aws.auth#sigv4" {
smithyhttp.SetSigV4SigningRegion(&rscheme.SignerProperties, sr)
} else if schemeID == "aws.auth#sigv4a" {
smithyhttp.SetSigV4ASigningRegions(&rscheme.SignerProperties, []string{sr})
}
}
return next.HandleFinalize(ctx, in)
}
func addSetLegacyContextSigningOptionsMiddleware(stack *middleware.Stack) error {
return stack.Finalize.Insert(&setLegacyContextSigningOptionsMiddleware{}, "Signing", middleware.Before)
}
type withAnonymous struct {
resolver AuthSchemeResolver
}
var _ AuthSchemeResolver = (*withAnonymous)(nil)
func (v *withAnonymous) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) {
opts, err := v.resolver.ResolveAuthSchemes(ctx, params)
if err != nil {
return nil, err
}
opts = append(opts, &smithyauth.Option{
SchemeID: smithyauth.SchemeIDAnonymous,
})
return opts, nil
}
func wrapWithAnonymousAuth(options *Options) {
if _, ok := options.AuthSchemeResolver.(*defaultAuthSchemeResolver); !ok {
return
}
options.AuthSchemeResolver = &withAnonymous{
resolver: options.AuthSchemeResolver,
}
}
// AuthResolverParameters contains the set of inputs necessary for auth scheme
// resolution.
type AuthResolverParameters struct {
// The name of the operation being invoked.
Operation string
// The region in which the operation is being invoked.
Region string
}
func bindAuthResolverParams(operation string, input interface{}, options Options) *AuthResolverParameters {
params := &AuthResolverParameters{
Operation: operation,
}
bindAuthParamsRegion(params, input, options)
return params
}
// AuthSchemeResolver returns a set of possible authentication options for an
// operation.
type AuthSchemeResolver interface {
ResolveAuthSchemes(context.Context, *AuthResolverParameters) ([]*smithyauth.Option, error)
}
type defaultAuthSchemeResolver struct{}
var _ AuthSchemeResolver = (*defaultAuthSchemeResolver)(nil)
func (*defaultAuthSchemeResolver) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) {
if overrides, ok := operationAuthOptions[params.Operation]; ok {
return overrides(params), nil
}
return serviceAuthOptions(params), nil
}
var operationAuthOptions = map[string]func(*AuthResolverParameters) []*smithyauth.Option{
"CreateToken": func(params *AuthResolverParameters) []*smithyauth.Option {
return []*smithyauth.Option{
{SchemeID: smithyauth.SchemeIDAnonymous},
}
},
"RegisterClient": func(params *AuthResolverParameters) []*smithyauth.Option {
return []*smithyauth.Option{
{SchemeID: smithyauth.SchemeIDAnonymous},
}
},
"StartDeviceAuthorization": func(params *AuthResolverParameters) []*smithyauth.Option {
return []*smithyauth.Option{
{SchemeID: smithyauth.SchemeIDAnonymous},
}
},
}
func serviceAuthOptions(params *AuthResolverParameters) []*smithyauth.Option {
return []*smithyauth.Option{
{
SchemeID: smithyauth.SchemeIDSigV4,
SignerProperties: func() smithy.Properties {
var props smithy.Properties
smithyhttp.SetSigV4SigningName(&props, "sso-oauth")
smithyhttp.SetSigV4SigningRegion(&props, params.Region)
return props
}(),
},
}
}
type resolveAuthSchemeMiddleware struct {
operation string
options Options
}
func (*resolveAuthSchemeMiddleware) ID() string {
return "ResolveAuthScheme"
}
func (m *resolveAuthSchemeMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
params := bindAuthResolverParams(m.operation, getOperationInput(ctx), m.options)
options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params)
if err != nil {
return out, metadata, fmt.Errorf("resolve auth scheme: %w", err)
}
scheme, ok := m.selectScheme(options)
if !ok {
return out, metadata, fmt.Errorf("could not select an auth scheme")
}
ctx = setResolvedAuthScheme(ctx, scheme)
return next.HandleFinalize(ctx, in)
}
func (m *resolveAuthSchemeMiddleware) selectScheme(options []*smithyauth.Option) (*resolvedAuthScheme, bool) {
for _, option := range options {
if option.SchemeID == smithyauth.SchemeIDAnonymous {
return newResolvedAuthScheme(smithyhttp.NewAnonymousScheme(), option), true
}
for _, scheme := range m.options.AuthSchemes {
if scheme.SchemeID() != option.SchemeID {
continue
}
if scheme.IdentityResolver(m.options) != nil {
return newResolvedAuthScheme(scheme, option), true
}
}
}
return nil, false
}
type resolvedAuthSchemeKey struct{}
type resolvedAuthScheme struct {
Scheme smithyhttp.AuthScheme
IdentityProperties smithy.Properties
SignerProperties smithy.Properties
}
func newResolvedAuthScheme(scheme smithyhttp.AuthScheme, option *smithyauth.Option) *resolvedAuthScheme {
return &resolvedAuthScheme{
Scheme: scheme,
IdentityProperties: option.IdentityProperties,
SignerProperties: option.SignerProperties,
}
}
func setResolvedAuthScheme(ctx context.Context, scheme *resolvedAuthScheme) context.Context {
return middleware.WithStackValue(ctx, resolvedAuthSchemeKey{}, scheme)
}
func getResolvedAuthScheme(ctx context.Context) *resolvedAuthScheme {
v, _ := middleware.GetStackValue(ctx, resolvedAuthSchemeKey{}).(*resolvedAuthScheme)
return v
}
type getIdentityMiddleware struct {
options Options
}
func (*getIdentityMiddleware) ID() string {
return "GetIdentity"
}
func (m *getIdentityMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
rscheme := getResolvedAuthScheme(ctx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
resolver := rscheme.Scheme.IdentityResolver(m.options)
if resolver == nil {
return out, metadata, fmt.Errorf("no identity resolver")
}
identity, err := resolver.GetIdentity(ctx, rscheme.IdentityProperties)
if err != nil {
return out, metadata, fmt.Errorf("get identity: %w", err)
}
ctx = setIdentity(ctx, identity)
return next.HandleFinalize(ctx, in)
}
type identityKey struct{}
func setIdentity(ctx context.Context, identity smithyauth.Identity) context.Context {
return middleware.WithStackValue(ctx, identityKey{}, identity)
}
func getIdentity(ctx context.Context) smithyauth.Identity {
v, _ := middleware.GetStackValue(ctx, identityKey{}).(smithyauth.Identity)
return v
}
type signRequestMiddleware struct {
}
func (*signRequestMiddleware) ID() string {
return "Signing"
}
func (m *signRequestMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unexpected transport type %T", in.Request)
}
rscheme := getResolvedAuthScheme(ctx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
identity := getIdentity(ctx)
if identity == nil {
return out, metadata, fmt.Errorf("no identity")
}
signer := rscheme.Scheme.Signer()
if signer == nil {
return out, metadata, fmt.Errorf("no signer")
}
if err := signer.SignRequest(ctx, req, identity, rscheme.SignerProperties); err != nil {
return out, metadata, fmt.Errorf("sign request: %w", err)
}
return next.HandleFinalize(ctx, in)
}

View File

@ -239,6 +239,244 @@ func awsRestjson1_deserializeOpDocumentCreateTokenOutput(v **CreateTokenOutput,
return nil
}
type awsRestjson1_deserializeOpCreateTokenWithIAM struct {
}
func (*awsRestjson1_deserializeOpCreateTokenWithIAM) ID() string {
return "OperationDeserializer"
}
func (m *awsRestjson1_deserializeOpCreateTokenWithIAM) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
) {
out, metadata, err = next.HandleDeserialize(ctx, in)
if err != nil {
return out, metadata, err
}
response, ok := out.RawResponse.(*smithyhttp.Response)
if !ok {
return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)}
}
if response.StatusCode < 200 || response.StatusCode >= 300 {
return out, metadata, awsRestjson1_deserializeOpErrorCreateTokenWithIAM(response, &metadata)
}
output := &CreateTokenWithIAMOutput{}
out.Result = output
var buff [1024]byte
ringBuffer := smithyio.NewRingBuffer(buff[:])
body := io.TeeReader(response.Body, ringBuffer)
decoder := json.NewDecoder(body)
decoder.UseNumber()
var shape interface{}
if err := decoder.Decode(&shape); err != nil && err != io.EOF {
var snapshot bytes.Buffer
io.Copy(&snapshot, ringBuffer)
err = &smithy.DeserializationError{
Err: fmt.Errorf("failed to decode response body, %w", err),
Snapshot: snapshot.Bytes(),
}
return out, metadata, err
}
err = awsRestjson1_deserializeOpDocumentCreateTokenWithIAMOutput(&output, shape)
if err != nil {
var snapshot bytes.Buffer
io.Copy(&snapshot, ringBuffer)
return out, metadata, &smithy.DeserializationError{
Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err),
Snapshot: snapshot.Bytes(),
}
}
return out, metadata, err
}
func awsRestjson1_deserializeOpErrorCreateTokenWithIAM(response *smithyhttp.Response, metadata *middleware.Metadata) error {
var errorBuffer bytes.Buffer
if _, err := io.Copy(&errorBuffer, response.Body); err != nil {
return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)}
}
errorBody := bytes.NewReader(errorBuffer.Bytes())
errorCode := "UnknownError"
errorMessage := errorCode
headerCode := response.Header.Get("X-Amzn-ErrorType")
if len(headerCode) != 0 {
errorCode = restjson.SanitizeErrorCode(headerCode)
}
var buff [1024]byte
ringBuffer := smithyio.NewRingBuffer(buff[:])
body := io.TeeReader(errorBody, ringBuffer)
decoder := json.NewDecoder(body)
decoder.UseNumber()
jsonCode, message, err := restjson.GetErrorInfo(decoder)
if err != nil {
var snapshot bytes.Buffer
io.Copy(&snapshot, ringBuffer)
err = &smithy.DeserializationError{
Err: fmt.Errorf("failed to decode response body, %w", err),
Snapshot: snapshot.Bytes(),
}
return err
}
errorBody.Seek(0, io.SeekStart)
if len(headerCode) == 0 && len(jsonCode) != 0 {
errorCode = restjson.SanitizeErrorCode(jsonCode)
}
if len(message) != 0 {
errorMessage = message
}
switch {
case strings.EqualFold("AccessDeniedException", errorCode):
return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody)
case strings.EqualFold("AuthorizationPendingException", errorCode):
return awsRestjson1_deserializeErrorAuthorizationPendingException(response, errorBody)
case strings.EqualFold("ExpiredTokenException", errorCode):
return awsRestjson1_deserializeErrorExpiredTokenException(response, errorBody)
case strings.EqualFold("InternalServerException", errorCode):
return awsRestjson1_deserializeErrorInternalServerException(response, errorBody)
case strings.EqualFold("InvalidClientException", errorCode):
return awsRestjson1_deserializeErrorInvalidClientException(response, errorBody)
case strings.EqualFold("InvalidGrantException", errorCode):
return awsRestjson1_deserializeErrorInvalidGrantException(response, errorBody)
case strings.EqualFold("InvalidRequestException", errorCode):
return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody)
case strings.EqualFold("InvalidRequestRegionException", errorCode):
return awsRestjson1_deserializeErrorInvalidRequestRegionException(response, errorBody)
case strings.EqualFold("InvalidScopeException", errorCode):
return awsRestjson1_deserializeErrorInvalidScopeException(response, errorBody)
case strings.EqualFold("SlowDownException", errorCode):
return awsRestjson1_deserializeErrorSlowDownException(response, errorBody)
case strings.EqualFold("UnauthorizedClientException", errorCode):
return awsRestjson1_deserializeErrorUnauthorizedClientException(response, errorBody)
case strings.EqualFold("UnsupportedGrantTypeException", errorCode):
return awsRestjson1_deserializeErrorUnsupportedGrantTypeException(response, errorBody)
default:
genericError := &smithy.GenericAPIError{
Code: errorCode,
Message: errorMessage,
}
return genericError
}
}
func awsRestjson1_deserializeOpDocumentCreateTokenWithIAMOutput(v **CreateTokenWithIAMOutput, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)
}
if value == nil {
return nil
}
shape, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected JSON type %v", value)
}
var sv *CreateTokenWithIAMOutput
if *v == nil {
sv = &CreateTokenWithIAMOutput{}
} else {
sv = *v
}
for key, value := range shape {
switch key {
case "accessToken":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected AccessToken to be of type string, got %T instead", value)
}
sv.AccessToken = ptr.String(jtv)
}
case "expiresIn":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected ExpirationInSeconds to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.ExpiresIn = int32(i64)
}
case "idToken":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected IdToken to be of type string, got %T instead", value)
}
sv.IdToken = ptr.String(jtv)
}
case "issuedTokenType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected TokenTypeURI to be of type string, got %T instead", value)
}
sv.IssuedTokenType = ptr.String(jtv)
}
case "refreshToken":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected RefreshToken to be of type string, got %T instead", value)
}
sv.RefreshToken = ptr.String(jtv)
}
case "scope":
if err := awsRestjson1_deserializeDocumentScopes(&sv.Scope, value); err != nil {
return err
}
case "tokenType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected TokenType to be of type string, got %T instead", value)
}
sv.TokenType = ptr.String(jtv)
}
default:
_, _ = key, value
}
}
*v = sv
return nil
}
type awsRestjson1_deserializeOpRegisterClient struct {
}
@ -956,6 +1194,42 @@ func awsRestjson1_deserializeErrorInvalidRequestException(response *smithyhttp.R
return output
}
func awsRestjson1_deserializeErrorInvalidRequestRegionException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
output := &types.InvalidRequestRegionException{}
var buff [1024]byte
ringBuffer := smithyio.NewRingBuffer(buff[:])
body := io.TeeReader(errorBody, ringBuffer)
decoder := json.NewDecoder(body)
decoder.UseNumber()
var shape interface{}
if err := decoder.Decode(&shape); err != nil && err != io.EOF {
var snapshot bytes.Buffer
io.Copy(&snapshot, ringBuffer)
err = &smithy.DeserializationError{
Err: fmt.Errorf("failed to decode response body, %w", err),
Snapshot: snapshot.Bytes(),
}
return err
}
err := awsRestjson1_deserializeDocumentInvalidRequestRegionException(&output, shape)
if err != nil {
var snapshot bytes.Buffer
io.Copy(&snapshot, ringBuffer)
err = &smithy.DeserializationError{
Err: fmt.Errorf("failed to decode response body, %w", err),
Snapshot: snapshot.Bytes(),
}
return err
}
errorBody.Seek(0, io.SeekStart)
return output
}
func awsRestjson1_deserializeErrorInvalidScopeException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
output := &types.InvalidScopeException{}
var buff [1024]byte
@ -1492,6 +1766,73 @@ func awsRestjson1_deserializeDocumentInvalidRequestException(v **types.InvalidRe
return nil
}
func awsRestjson1_deserializeDocumentInvalidRequestRegionException(v **types.InvalidRequestRegionException, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)
}
if value == nil {
return nil
}
shape, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected JSON type %v", value)
}
var sv *types.InvalidRequestRegionException
if *v == nil {
sv = &types.InvalidRequestRegionException{}
} else {
sv = *v
}
for key, value := range shape {
switch key {
case "endpoint":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Location to be of type string, got %T instead", value)
}
sv.Endpoint = ptr.String(jtv)
}
case "error":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Error to be of type string, got %T instead", value)
}
sv.Error_ = ptr.String(jtv)
}
case "error_description":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value)
}
sv.Error_description = ptr.String(jtv)
}
case "region":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Region to be of type string, got %T instead", value)
}
sv.Region = ptr.String(jtv)
}
default:
_, _ = key, value
}
}
*v = sv
return nil
}
func awsRestjson1_deserializeDocumentInvalidScopeException(v **types.InvalidScopeException, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)
@ -1541,6 +1882,42 @@ func awsRestjson1_deserializeDocumentInvalidScopeException(v **types.InvalidScop
return nil
}
func awsRestjson1_deserializeDocumentScopes(v *[]string, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)
}
if value == nil {
return nil
}
shape, ok := value.([]interface{})
if !ok {
return fmt.Errorf("unexpected JSON type %v", value)
}
var cv []string
if *v == nil {
cv = []string{}
} else {
cv = *v
}
for _, value := range shape {
var col string
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Scope to be of type string, got %T instead", value)
}
col = jtv
}
cv = append(cv, col)
}
*v = cv
return nil
}
func awsRestjson1_deserializeDocumentSlowDownException(v **types.SlowDownException, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)

View File

@ -1,46 +1,38 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
// Package ssooidc provides the API client, operations, and parameter types for AWS
// SSO OIDC.
// Package ssooidc provides the API client, operations, and parameter types for
// AWS SSO OIDC.
//
// AWS IAM Identity Center (successor to AWS Single Sign-On) OpenID Connect (OIDC)
// is a web service that enables a client (such as AWS CLI or a native application)
// to register with IAM Identity Center. The service also enables the client to
// fetch the users access token upon successful authentication and authorization
// with IAM Identity Center. Although AWS Single Sign-On was renamed, the sso and
// identitystore API namespaces will continue to retain their original name for
// backward compatibility purposes. For more information, see IAM Identity Center
// rename
// (https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html#renamed).
// Considerations for Using This Guide Before you begin using this guide, we
// recommend that you first review the following important information about how
// the IAM Identity Center OIDC service works.
// IAM Identity Center OpenID Connect (OIDC) is a web service that enables a
// client (such as CLI or a native application) to register with IAM Identity
// Center. The service also enables the client to fetch the users access token
// upon successful authentication and authorization with IAM Identity Center. IAM
// Identity Center uses the sso and identitystore API namespaces. Considerations
// for Using This Guide Before you begin using this guide, we recommend that you
// first review the following important information about how the IAM Identity
// Center OIDC service works.
// - The IAM Identity Center OIDC service currently implements only the portions
// of the OAuth 2.0 Device Authorization Grant standard (
// https://tools.ietf.org/html/rfc8628 (https://tools.ietf.org/html/rfc8628) )
// that are necessary to enable single sign-on authentication with the CLI.
// - With older versions of the CLI, the service only emits OIDC access tokens,
// so to obtain a new token, users must explicitly re-authenticate. To access the
// OIDC flow that supports token refresh and doesnt require re-authentication,
// update to the latest CLI version (1.27.10 for CLI V1 and 2.9.0 for CLI V2) with
// support for OIDC token refresh and configurable IAM Identity Center session
// durations. For more information, see Configure Amazon Web Services access
// portal session duration (https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-user-session.html)
// .
// - The access tokens provided by this service grant access to all Amazon Web
// Services account entitlements assigned to an IAM Identity Center user, not just
// a particular application.
// - The documentation in this guide does not describe the mechanism to convert
// the access token into Amazon Web Services Auth (“sigv4”) credentials for use
// with IAM-protected Amazon Web Services service endpoints. For more information,
// see GetRoleCredentials (https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html)
// in the IAM Identity Center Portal API Reference Guide.
//
// * The IAM Identity Center OIDC
// service currently implements only the portions of the OAuth 2.0 Device
// Authorization Grant standard (https://tools.ietf.org/html/rfc8628
// (https://tools.ietf.org/html/rfc8628)) that are necessary to enable single
// sign-on authentication with the AWS CLI. Support for other OIDC flows frequently
// needed for native applications, such as Authorization Code Flow (+ PKCE), will
// be addressed in future releases.
//
// * The service emits only OIDC access tokens,
// such that obtaining a new token (For example, token refresh) requires explicit
// user re-authentication.
//
// * The access tokens provided by this service grant
// access to all AWS account entitlements assigned to an IAM Identity Center user,
// not just a particular application.
//
// * The documentation in this guide does not
// describe the mechanism to convert the access token into AWS Auth (“sigv4”)
// credentials for use with IAM-protected AWS service endpoints. For more
// information, see GetRoleCredentials
// (https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html)
// in the IAM Identity Center Portal API Reference Guide.
//
// For general information
// about IAM Identity Center, see What is IAM Identity Center?
// (https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html) in the
// IAM Identity Center User Guide.
// For general information about IAM Identity Center, see What is IAM Identity
// Center? (https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html)
// in the IAM Identity Center User Guide.
package ssooidc

View File

@ -8,10 +8,18 @@ import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources"
"github.com/aws/aws-sdk-go-v2/internal/endpoints"
"github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn"
internalendpoints "github.com/aws/aws-sdk-go-v2/service/ssooidc/internal/endpoints"
smithyauth "github.com/aws/smithy-go/auth"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/aws/smithy-go/middleware"
"github.com/aws/smithy-go/ptr"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net/http"
"net/url"
"os"
"strings"
)
@ -39,13 +47,6 @@ func (fn EndpointResolverFunc) ResolveEndpoint(region string, options EndpointRe
return fn(region, options)
}
func resolveDefaultEndpointConfiguration(o *Options) {
if o.EndpointResolver != nil {
return
}
o.EndpointResolver = NewDefaultEndpointResolver()
}
// EndpointResolverFromURL returns an EndpointResolver configured using the
// provided endpoint url. By default, the resolved endpoint resolver uses the
// client region as signing region, and the endpoint source is set to
@ -79,6 +80,10 @@ func (*ResolveEndpoint) ID() string {
func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
if !awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
return next.HandleSerialize(ctx, in)
}
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
@ -94,6 +99,11 @@ func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.Ser
var endpoint aws.Endpoint
endpoint, err = m.Resolver.ResolveEndpoint(awsmiddleware.GetRegion(ctx), eo)
if err != nil {
nf := (&aws.EndpointNotFoundError{})
if errors.As(err, &nf) {
ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, false)
return next.HandleSerialize(ctx, in)
}
return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
}
@ -105,7 +115,7 @@ func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.Ser
if len(awsmiddleware.GetSigningName(ctx)) == 0 {
signingName := endpoint.SigningName
if len(signingName) == 0 {
signingName = "awsssooidc"
signingName = "sso-oauth"
}
ctx = awsmiddleware.SetSigningName(ctx, signingName)
}
@ -129,27 +139,10 @@ func removeResolveEndpointMiddleware(stack *middleware.Stack) error {
type wrappedEndpointResolver struct {
awsResolver aws.EndpointResolverWithOptions
resolver EndpointResolver
}
func (w *wrappedEndpointResolver) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) {
if w.awsResolver == nil {
goto fallback
}
endpoint, err = w.awsResolver.ResolveEndpoint(ServiceID, region, options)
if err == nil {
return endpoint, nil
}
if nf := (&aws.EndpointNotFoundError{}); !errors.As(err, &nf) {
return endpoint, err
}
fallback:
if w.resolver == nil {
return endpoint, fmt.Errorf("default endpoint resolver provided was nil")
}
return w.resolver.ResolveEndpoint(region, options)
return w.awsResolver.ResolveEndpoint(ServiceID, region, options)
}
type awsEndpointResolverAdaptor func(service, region string) (aws.Endpoint, error)
@ -160,12 +153,13 @@ func (a awsEndpointResolverAdaptor) ResolveEndpoint(service, region string, opti
var _ aws.EndpointResolverWithOptions = awsEndpointResolverAdaptor(nil)
// withEndpointResolver returns an EndpointResolver that first delegates endpoint resolution to the awsResolver.
// If awsResolver returns aws.EndpointNotFoundError error, the resolver will use the the provided
// fallbackResolver for resolution.
// withEndpointResolver returns an aws.EndpointResolverWithOptions that first delegates endpoint resolution to the awsResolver.
// If awsResolver returns aws.EndpointNotFoundError error, the v1 resolver middleware will swallow the error,
// and set an appropriate context flag such that fallback will occur when EndpointResolverV2 is invoked
// via its middleware.
//
// fallbackResolver must not be nil
func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptions aws.EndpointResolverWithOptions, fallbackResolver EndpointResolver) EndpointResolver {
// If another error (besides aws.EndpointNotFoundError) is returned, then that error will be propagated.
func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptions aws.EndpointResolverWithOptions) EndpointResolver {
var resolver aws.EndpointResolverWithOptions
if awsResolverWithOptions != nil {
@ -176,7 +170,6 @@ func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptio
return &wrappedEndpointResolver{
awsResolver: resolver,
resolver: fallbackResolver,
}
}
@ -198,3 +191,338 @@ func finalizeClientEndpointResolverOptions(options *Options) {
}
}
func resolveEndpointResolverV2(options *Options) {
if options.EndpointResolverV2 == nil {
options.EndpointResolverV2 = NewDefaultEndpointResolverV2()
}
}
func resolveBaseEndpoint(cfg aws.Config, o *Options) {
if cfg.BaseEndpoint != nil {
o.BaseEndpoint = cfg.BaseEndpoint
}
_, g := os.LookupEnv("AWS_ENDPOINT_URL")
_, s := os.LookupEnv("AWS_ENDPOINT_URL_SSO_OIDC")
if g && !s {
return
}
value, found, err := internalConfig.ResolveServiceBaseEndpoint(context.Background(), "SSO OIDC", cfg.ConfigSources)
if found && err == nil {
o.BaseEndpoint = &value
}
}
// EndpointParameters provides the parameters that influence how endpoints are
// resolved.
type EndpointParameters struct {
// The AWS region used to dispatch the request.
//
// Parameter is
// required.
//
// AWS::Region
Region *string
// When true, use the dual-stack endpoint. If the configured endpoint does not
// support dual-stack, dispatching the request MAY return an error.
//
// Defaults to
// false if no value is provided.
//
// AWS::UseDualStack
UseDualStack *bool
// When true, send this request to the FIPS-compliant regional endpoint. If the
// configured endpoint does not have a FIPS compliant endpoint, dispatching the
// request will return an error.
//
// Defaults to false if no value is
// provided.
//
// AWS::UseFIPS
UseFIPS *bool
// Override the endpoint used to send this request
//
// Parameter is
// required.
//
// SDK::Endpoint
Endpoint *string
}
// ValidateRequired validates required parameters are set.
func (p EndpointParameters) ValidateRequired() error {
if p.UseDualStack == nil {
return fmt.Errorf("parameter UseDualStack is required")
}
if p.UseFIPS == nil {
return fmt.Errorf("parameter UseFIPS is required")
}
return nil
}
// WithDefaults returns a shallow copy of EndpointParameterswith default values
// applied to members where applicable.
func (p EndpointParameters) WithDefaults() EndpointParameters {
if p.UseDualStack == nil {
p.UseDualStack = ptr.Bool(false)
}
if p.UseFIPS == nil {
p.UseFIPS = ptr.Bool(false)
}
return p
}
// EndpointResolverV2 provides the interface for resolving service endpoints.
type EndpointResolverV2 interface {
// ResolveEndpoint attempts to resolve the endpoint with the provided options,
// returning the endpoint if found. Otherwise an error is returned.
ResolveEndpoint(ctx context.Context, params EndpointParameters) (
smithyendpoints.Endpoint, error,
)
}
// resolver provides the implementation for resolving endpoints.
type resolver struct{}
func NewDefaultEndpointResolverV2() EndpointResolverV2 {
return &resolver{}
}
// ResolveEndpoint attempts to resolve the endpoint with the provided options,
// returning the endpoint if found. Otherwise an error is returned.
func (r *resolver) ResolveEndpoint(
ctx context.Context, params EndpointParameters,
) (
endpoint smithyendpoints.Endpoint, err error,
) {
params = params.WithDefaults()
if err = params.ValidateRequired(); err != nil {
return endpoint, fmt.Errorf("endpoint parameters are not valid, %w", err)
}
_UseDualStack := *params.UseDualStack
_UseFIPS := *params.UseFIPS
if exprVal := params.Endpoint; exprVal != nil {
_Endpoint := *exprVal
_ = _Endpoint
if _UseFIPS == true {
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: FIPS and custom endpoint are not supported")
}
if _UseDualStack == true {
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Dualstack and custom endpoint are not supported")
}
uriString := _Endpoint
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
if exprVal := params.Region; exprVal != nil {
_Region := *exprVal
_ = _Region
if exprVal := awsrulesfn.GetPartition(_Region); exprVal != nil {
_PartitionResult := *exprVal
_ = _PartitionResult
if _UseFIPS == true {
if _UseDualStack == true {
if true == _PartitionResult.SupportsFIPS {
if true == _PartitionResult.SupportsDualStack {
uriString := func() string {
var out strings.Builder
out.WriteString("https://oidc-fips.")
out.WriteString(_Region)
out.WriteString(".")
out.WriteString(_PartitionResult.DualStackDnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both")
}
}
if _UseFIPS == true {
if _PartitionResult.SupportsFIPS == true {
if _PartitionResult.Name == "aws-us-gov" {
uriString := func() string {
var out strings.Builder
out.WriteString("https://oidc.")
out.WriteString(_Region)
out.WriteString(".amazonaws.com")
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
uriString := func() string {
var out strings.Builder
out.WriteString("https://oidc-fips.")
out.WriteString(_Region)
out.WriteString(".")
out.WriteString(_PartitionResult.DnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS")
}
if _UseDualStack == true {
if true == _PartitionResult.SupportsDualStack {
uriString := func() string {
var out strings.Builder
out.WriteString("https://oidc.")
out.WriteString(_Region)
out.WriteString(".")
out.WriteString(_PartitionResult.DualStackDnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack")
}
uriString := func() string {
var out strings.Builder
out.WriteString("https://oidc.")
out.WriteString(_Region)
out.WriteString(".")
out.WriteString(_PartitionResult.DnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
return endpoint, fmt.Errorf("Endpoint resolution failed. Invalid operation or environment input.")
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region")
}
type endpointParamsBinder interface {
bindEndpointParams(*EndpointParameters)
}
func bindEndpointParams(input interface{}, options Options) *EndpointParameters {
params := &EndpointParameters{}
params.Region = aws.String(endpoints.MapFIPSRegion(options.Region))
params.UseDualStack = aws.Bool(options.EndpointOptions.UseDualStackEndpoint == aws.DualStackEndpointStateEnabled)
params.UseFIPS = aws.Bool(options.EndpointOptions.UseFIPSEndpoint == aws.FIPSEndpointStateEnabled)
params.Endpoint = options.BaseEndpoint
if b, ok := input.(endpointParamsBinder); ok {
b.bindEndpointParams(params)
}
return params
}
type resolveEndpointV2Middleware struct {
options Options
}
func (*resolveEndpointV2Middleware) ID() string {
return "ResolveEndpointV2"
}
func (m *resolveEndpointV2Middleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
if awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
return next.HandleFinalize(ctx, in)
}
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if m.options.EndpointResolverV2 == nil {
return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil")
}
params := bindEndpointParams(getOperationInput(ctx), m.options)
endpt, err := m.options.EndpointResolverV2.ResolveEndpoint(ctx, *params)
if err != nil {
return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
}
if endpt.URI.RawPath == "" && req.URL.RawPath != "" {
endpt.URI.RawPath = endpt.URI.Path
}
req.URL.Scheme = endpt.URI.Scheme
req.URL.Host = endpt.URI.Host
req.URL.Path = smithyhttp.JoinPath(endpt.URI.Path, req.URL.Path)
req.URL.RawPath = smithyhttp.JoinPath(endpt.URI.RawPath, req.URL.RawPath)
for k := range endpt.Headers {
req.Header.Set(k, endpt.Headers.Get(k))
}
rscheme := getResolvedAuthScheme(ctx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
opts, _ := smithyauth.GetAuthOptions(&endpt.Properties)
for _, o := range opts {
rscheme.SignerProperties.SetAll(&o.SignerProperties)
}
return next.HandleFinalize(ctx, in)
}

View File

@ -3,20 +3,26 @@
"github.com/aws/aws-sdk-go-v2": "v1.4.0",
"github.com/aws/aws-sdk-go-v2/internal/configsources": "v0.0.0-00010101000000-000000000000",
"github.com/aws/aws-sdk-go-v2/internal/endpoints/v2": "v2.0.0-00010101000000-000000000000",
"github.com/aws/smithy-go": "v1.4.0"
"github.com/aws/smithy-go": "v1.4.0",
"github.com/google/go-cmp": "v0.5.4"
},
"files": [
"api_client.go",
"api_client_test.go",
"api_op_CreateToken.go",
"api_op_CreateTokenWithIAM.go",
"api_op_RegisterClient.go",
"api_op_StartDeviceAuthorization.go",
"auth.go",
"deserializers.go",
"doc.go",
"endpoints.go",
"endpoints_config_test.go",
"endpoints_test.go",
"generated.json",
"internal/endpoints/endpoints.go",
"internal/endpoints/endpoints_test.go",
"options.go",
"protocol_test.go",
"serializers.go",
"types/errors.go",

View File

@ -3,4 +3,4 @@
package ssooidc
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.14.5"
const goModuleVersion = "1.21.7"

View File

@ -89,13 +89,17 @@ var partitionRegexp = struct {
AwsCn *regexp.Regexp
AwsIso *regexp.Regexp
AwsIsoB *regexp.Regexp
AwsIsoE *regexp.Regexp
AwsIsoF *regexp.Regexp
AwsUsGov *regexp.Regexp
}{
Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$"),
Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af|il)\\-\\w+\\-\\d+$"),
AwsCn: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"),
AwsIso: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"),
AwsIsoB: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"),
AwsIsoE: regexp.MustCompile("^eu\\-isoe\\-\\w+\\-\\d+$"),
AwsIsoF: regexp.MustCompile("^us\\-isof\\-\\w+\\-\\d+$"),
AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"),
}
@ -223,6 +227,14 @@ var defaultPartitions = endpoints.Partitions{
Region: "eu-central-1",
},
},
endpoints.EndpointKey{
Region: "eu-central-2",
}: endpoints.Endpoint{
Hostname: "oidc.eu-central-2.amazonaws.com",
CredentialScope: endpoints.CredentialScope{
Region: "eu-central-2",
},
},
endpoints.EndpointKey{
Region: "eu-north-1",
}: endpoints.Endpoint{
@ -263,6 +275,22 @@ var defaultPartitions = endpoints.Partitions{
Region: "eu-west-3",
},
},
endpoints.EndpointKey{
Region: "il-central-1",
}: endpoints.Endpoint{
Hostname: "oidc.il-central-1.amazonaws.com",
CredentialScope: endpoints.CredentialScope{
Region: "il-central-1",
},
},
endpoints.EndpointKey{
Region: "me-central-1",
}: endpoints.Endpoint{
Hostname: "oidc.me-central-1.amazonaws.com",
CredentialScope: endpoints.CredentialScope{
Region: "me-central-1",
},
},
endpoints.EndpointKey{
Region: "me-south-1",
}: endpoints.Endpoint{
@ -347,6 +375,24 @@ var defaultPartitions = endpoints.Partitions{
},
RegionRegex: partitionRegexp.AwsCn,
IsRegionalized: true,
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "cn-north-1",
}: endpoints.Endpoint{
Hostname: "oidc.cn-north-1.amazonaws.com.cn",
CredentialScope: endpoints.CredentialScope{
Region: "cn-north-1",
},
},
endpoints.EndpointKey{
Region: "cn-northwest-1",
}: endpoints.Endpoint{
Hostname: "oidc.cn-northwest-1.amazonaws.com.cn",
CredentialScope: endpoints.CredentialScope{
Region: "cn-northwest-1",
},
},
},
},
{
ID: "aws-iso",
@ -390,6 +436,48 @@ var defaultPartitions = endpoints.Partitions{
RegionRegex: partitionRegexp.AwsIsoB,
IsRegionalized: true,
},
{
ID: "aws-iso-e",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "oidc-fips.{region}.cloud.adc-e.uk",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "oidc.{region}.cloud.adc-e.uk",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIsoE,
IsRegionalized: true,
},
{
ID: "aws-iso-f",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "oidc-fips.{region}.csp.hci.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "oidc.{region}.csp.hci.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIsoF,
IsRegionalized: true,
},
{
ID: "aws-us-gov",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{

View File

@ -0,0 +1,217 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package ssooidc
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy"
smithyauth "github.com/aws/smithy-go/auth"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net/http"
)
type HTTPClient interface {
Do(*http.Request) (*http.Response, error)
}
type Options struct {
// Set of options to modify how an operation is invoked. These apply to all
// operations invoked for this client. Use functional options on operation call to
// modify this list for per operation behavior.
APIOptions []func(*middleware.Stack) error
// The optional application specific identifier appended to the User-Agent header.
AppID string
// This endpoint will be given as input to an EndpointResolverV2. It is used for
// providing a custom base endpoint that is subject to modifications by the
// processing EndpointResolverV2.
BaseEndpoint *string
// Configures the events that will be sent to the configured logger.
ClientLogMode aws.ClientLogMode
// The credentials object to use when signing requests.
Credentials aws.CredentialsProvider
// The configuration DefaultsMode that the SDK should use when constructing the
// clients initial default settings.
DefaultsMode aws.DefaultsMode
// The endpoint options to be used when attempting to resolve an endpoint.
EndpointOptions EndpointResolverOptions
// The service endpoint resolver.
//
// Deprecated: Deprecated: EndpointResolver and WithEndpointResolver. Providing a
// value for this field will likely prevent you from using any endpoint-related
// service features released after the introduction of EndpointResolverV2 and
// BaseEndpoint. To migrate an EndpointResolver implementation that uses a custom
// endpoint, set the client option BaseEndpoint instead.
EndpointResolver EndpointResolver
// Resolves the endpoint used for a particular service operation. This should be
// used over the deprecated EndpointResolver.
EndpointResolverV2 EndpointResolverV2
// Signature Version 4 (SigV4) Signer
HTTPSignerV4 HTTPSignerV4
// The logger writer interface to write logging messages to.
Logger logging.Logger
// The region to send requests to. (Required)
Region string
// RetryMaxAttempts specifies the maximum number attempts an API client will call
// an operation that fails with a retryable error. A value of 0 is ignored, and
// will not be used to configure the API client created default retryer, or modify
// per operation call's retry max attempts. If specified in an operation call's
// functional options with a value that is different than the constructed client's
// Options, the Client's Retryer will be wrapped to use the operation's specific
// RetryMaxAttempts value.
RetryMaxAttempts int
// RetryMode specifies the retry mode the API client will be created with, if
// Retryer option is not also specified. When creating a new API Clients this
// member will only be used if the Retryer Options member is nil. This value will
// be ignored if Retryer is not nil. Currently does not support per operation call
// overrides, may in the future.
RetryMode aws.RetryMode
// Retryer guides how HTTP requests should be retried in case of recoverable
// failures. When nil the API client will use a default retryer. The kind of
// default retry created by the API client can be changed with the RetryMode
// option.
Retryer aws.Retryer
// The RuntimeEnvironment configuration, only populated if the DefaultsMode is set
// to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You
// should not populate this structure programmatically, or rely on the values here
// within your applications.
RuntimeEnvironment aws.RuntimeEnvironment
// The initial DefaultsMode used when the client options were constructed. If the
// DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved
// value was at that point in time. Currently does not support per operation call
// overrides, may in the future.
resolvedDefaultsMode aws.DefaultsMode
// The HTTP client to invoke API calls with. Defaults to client's default HTTP
// implementation if nil.
HTTPClient HTTPClient
// The auth scheme resolver which determines how to authenticate for each
// operation.
AuthSchemeResolver AuthSchemeResolver
// The list of auth schemes supported by the client.
AuthSchemes []smithyhttp.AuthScheme
}
// Copy creates a clone where the APIOptions list is deep copied.
func (o Options) Copy() Options {
to := o
to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions))
copy(to.APIOptions, o.APIOptions)
return to
}
func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver {
if schemeID == "aws.auth#sigv4" {
return getSigV4IdentityResolver(o)
}
if schemeID == "smithy.api#noAuth" {
return &smithyauth.AnonymousIdentityResolver{}
}
return nil
}
// WithAPIOptions returns a functional option for setting the Client's APIOptions
// option.
func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) {
return func(o *Options) {
o.APIOptions = append(o.APIOptions, optFns...)
}
}
// Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for
// this field will likely prevent you from using any endpoint-related service
// features released after the introduction of EndpointResolverV2 and BaseEndpoint.
// To migrate an EndpointResolver implementation that uses a custom endpoint, set
// the client option BaseEndpoint instead.
func WithEndpointResolver(v EndpointResolver) func(*Options) {
return func(o *Options) {
o.EndpointResolver = v
}
}
// WithEndpointResolverV2 returns a functional option for setting the Client's
// EndpointResolverV2 option.
func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) {
return func(o *Options) {
o.EndpointResolverV2 = v
}
}
func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver {
if o.Credentials != nil {
return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials}
}
return nil
}
// WithSigV4SigningName applies an override to the authentication workflow to
// use the given signing name for SigV4-authenticated operations.
//
// This is an advanced setting. The value here is FINAL, taking precedence over
// the resolved signing name from both auth scheme resolution and endpoint
// resolution.
func WithSigV4SigningName(name string) func(*Options) {
fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in)
}
return func(o *Options) {
o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
return s.Initialize.Add(
middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn),
middleware.Before,
)
})
}
}
// WithSigV4SigningRegion applies an override to the authentication workflow to
// use the given signing region for SigV4-authenticated operations.
//
// This is an advanced setting. The value here is FINAL, taking precedence over
// the resolved signing region from both auth scheme resolution and endpoint
// resolution.
func WithSigV4SigningRegion(region string) func(*Options) {
fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in)
}
return func(o *Options) {
o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
return s.Initialize.Add(
middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn),
middleware.Before,
)
})
}
}
func ignoreAnonymousAuth(options *Options) {
if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) {
options.Credentials = nil
}
}

View File

@ -38,7 +38,14 @@ func (m *awsRestjson1_serializeOpCreateToken) HandleSerialize(ctx context.Contex
request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
request.Method = "POST"
restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
var restEncoder *httpbinding.Encoder
if request.URL.RawPath == "" {
restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
} else {
request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
}
if err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
@ -118,6 +125,128 @@ func awsRestjson1_serializeOpDocumentCreateTokenInput(v *CreateTokenInput, value
return nil
}
type awsRestjson1_serializeOpCreateTokenWithIAM struct {
}
func (*awsRestjson1_serializeOpCreateTokenWithIAM) ID() string {
return "OperationSerializer"
}
func (m *awsRestjson1_serializeOpCreateTokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
request, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
}
input, ok := in.Parameters.(*CreateTokenWithIAMInput)
_ = input
if !ok {
return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
}
opPath, opQuery := httpbinding.SplitURI("/token?aws_iam=t")
request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
request.Method = "POST"
var restEncoder *httpbinding.Encoder
if request.URL.RawPath == "" {
restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
} else {
request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
}
if err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
restEncoder.SetHeader("Content-Type").String("application/json")
jsonEncoder := smithyjson.NewEncoder()
if err := awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(input, jsonEncoder.Value); err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
if request.Request, err = restEncoder.Encode(request.Request); err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
in.Request = request
return next.HandleSerialize(ctx, in)
}
func awsRestjson1_serializeOpHttpBindingsCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, encoder *httpbinding.Encoder) error {
if v == nil {
return fmt.Errorf("unsupported serialization of nil %T", v)
}
return nil
}
func awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, value smithyjson.Value) error {
object := value.Object()
defer object.Close()
if v.Assertion != nil {
ok := object.Key("assertion")
ok.String(*v.Assertion)
}
if v.ClientId != nil {
ok := object.Key("clientId")
ok.String(*v.ClientId)
}
if v.Code != nil {
ok := object.Key("code")
ok.String(*v.Code)
}
if v.GrantType != nil {
ok := object.Key("grantType")
ok.String(*v.GrantType)
}
if v.RedirectUri != nil {
ok := object.Key("redirectUri")
ok.String(*v.RedirectUri)
}
if v.RefreshToken != nil {
ok := object.Key("refreshToken")
ok.String(*v.RefreshToken)
}
if v.RequestedTokenType != nil {
ok := object.Key("requestedTokenType")
ok.String(*v.RequestedTokenType)
}
if v.Scope != nil {
ok := object.Key("scope")
if err := awsRestjson1_serializeDocumentScopes(v.Scope, ok); err != nil {
return err
}
}
if v.SubjectToken != nil {
ok := object.Key("subjectToken")
ok.String(*v.SubjectToken)
}
if v.SubjectTokenType != nil {
ok := object.Key("subjectTokenType")
ok.String(*v.SubjectTokenType)
}
return nil
}
type awsRestjson1_serializeOpRegisterClient struct {
}
@ -143,7 +272,14 @@ func (m *awsRestjson1_serializeOpRegisterClient) HandleSerialize(ctx context.Con
request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
request.Method = "POST"
restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
var restEncoder *httpbinding.Encoder
if request.URL.RawPath == "" {
restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
} else {
request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
}
if err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}
@ -223,7 +359,14 @@ func (m *awsRestjson1_serializeOpStartDeviceAuthorization) HandleSerialize(ctx c
request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
request.Method = "POST"
restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
var restEncoder *httpbinding.Encoder
if request.URL.RawPath == "" {
restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
} else {
request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
}
if err != nil {
return out, metadata, &smithy.SerializationError{Err: err}
}

View File

@ -36,8 +36,8 @@ func (e *AccessDeniedException) ErrorCode() string {
}
func (e *AccessDeniedException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Indicates that a request to authorize a client with an access user session token
// is pending.
// Indicates that a request to authorize a client with an access user session
// token is pending.
type AuthorizationPendingException struct {
Message *string
@ -128,7 +128,7 @@ func (e *InternalServerException) ErrorFault() smithy.ErrorFault { return smithy
// Indicates that the clientId or clientSecret in the request is invalid. For
// example, this can occur when a client sends an incorrect clientId or an expired
// clientSecret.
// clientSecret .
type InvalidClientException struct {
Message *string
@ -157,8 +157,8 @@ func (e *InvalidClientException) ErrorCode() string {
}
func (e *InvalidClientException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Indicates that the client information sent in the request during registration is
// invalid.
// Indicates that the client information sent in the request during registration
// is invalid.
type InvalidClientMetadataException struct {
Message *string
@ -247,6 +247,38 @@ func (e *InvalidRequestException) ErrorCode() string {
}
func (e *InvalidRequestException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Indicates that a token provided as input to the request was issued by and is
// only usable by calling IAM Identity Center endpoints in another region.
type InvalidRequestRegionException struct {
Message *string
ErrorCodeOverride *string
Error_ *string
Error_description *string
Endpoint *string
Region *string
noSmithyDocumentSerde
}
func (e *InvalidRequestRegionException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *InvalidRequestRegionException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *InvalidRequestRegionException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "InvalidRequestRegionException"
}
return *e.ErrorCodeOverride
}
func (e *InvalidRequestRegionException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Indicates that the scope provided in the request is invalid.
type InvalidScopeException struct {
Message *string

View File

@ -29,6 +29,26 @@ func (m *validateOpCreateToken) HandleInitialize(ctx context.Context, in middlew
return next.HandleInitialize(ctx, in)
}
type validateOpCreateTokenWithIAM struct {
}
func (*validateOpCreateTokenWithIAM) ID() string {
return "OperationInputValidation"
}
func (m *validateOpCreateTokenWithIAM) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
input, ok := in.Parameters.(*CreateTokenWithIAMInput)
if !ok {
return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
}
if err := validateOpCreateTokenWithIAMInput(input); err != nil {
return out, metadata, err
}
return next.HandleInitialize(ctx, in)
}
type validateOpRegisterClient struct {
}
@ -73,6 +93,10 @@ func addOpCreateTokenValidationMiddleware(stack *middleware.Stack) error {
return stack.Initialize.Add(&validateOpCreateToken{}, middleware.After)
}
func addOpCreateTokenWithIAMValidationMiddleware(stack *middleware.Stack) error {
return stack.Initialize.Add(&validateOpCreateTokenWithIAM{}, middleware.After)
}
func addOpRegisterClientValidationMiddleware(stack *middleware.Stack) error {
return stack.Initialize.Add(&validateOpRegisterClient{}, middleware.After)
}
@ -102,6 +126,24 @@ func validateOpCreateTokenInput(v *CreateTokenInput) error {
}
}
func validateOpCreateTokenWithIAMInput(v *CreateTokenWithIAMInput) error {
if v == nil {
return nil
}
invalidParams := smithy.InvalidParamsError{Context: "CreateTokenWithIAMInput"}
if v.ClientId == nil {
invalidParams.Add(smithy.NewErrParamRequired("ClientId"))
}
if v.GrantType == nil {
invalidParams.Add(smithy.NewErrParamRequired("GrantType"))
}
if invalidParams.Len() > 0 {
return invalidParams
} else {
return nil
}
}
func validateOpRegisterClientInput(v *RegisterClientInput) error {
if v == nil {
return nil