api_op_GetWebIdentityToken.go (4545B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package sts 4 5 import ( 6 "context" 7 "time" 8 9 "github.com/aws/aws-sdk-go-v2/service/sts/types" 10 "github.com/aws/smithy-go/middleware" 11 ) 12 13 // Returns a signed JSON Web Token (JWT) that represents the calling Amazon Web 14 // Services identity. The returned JWT can be used to authenticate with external 15 // services that support OIDC discovery. The token is signed by Amazon Web Services 16 // STS and can be publicly verified using the verification keys published at the 17 // issuer's JWKS endpoint. 18 func (c *Client) GetWebIdentityToken(ctx context.Context, params *GetWebIdentityTokenInput, optFns ...func(*Options)) (*GetWebIdentityTokenOutput, error) { 19 if params == nil { 20 params = &GetWebIdentityTokenInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "GetWebIdentityToken", params, optFns, c.addOperationGetWebIdentityTokenMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*GetWebIdentityTokenOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31 } 32 33 type GetWebIdentityTokenInput struct { 34 35 // The intended recipient of the web identity token. This value populates the aud 36 // claim in the JWT and should identify the service or application that will 37 // validate and use the token. The external service should verify this claim to 38 // ensure the token was intended for their use. 39 // 40 // This member is required. 41 Audience []string 42 43 // The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid 44 // values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with 45 // SHA-384). 46 // 47 // This member is required. 48 SigningAlgorithm *string 49 50 // The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. 51 // The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not 52 // specified, the default duration is 300 seconds (5 minutes). The token is 53 // designed to be short-lived and should be used for proof of identity, then 54 // exchanged for credentials or short-lived tokens in the external service. 55 DurationSeconds *int32 56 57 // An optional list of tags to include in the JSON Web Token (JWT). These tags are 58 // added as custom claims to the JWT and can be used by the downstream service for 59 // authorization decisions. 60 Tags []types.Tag 61 62 noSmithyDocumentSerde 63 } 64 65 type GetWebIdentityTokenOutput struct { 66 67 // The date and time when the web identity token expires, in UTC. The expiration 68 // is determined by adding the DurationSeconds value to the time the token was 69 // issued. After this time, the token should no longer be considered valid. 70 Expiration *time.Time 71 72 // A signed JSON Web Token (JWT) that represents the caller's Amazon Web Services 73 // identity. The token contains standard JWT claims such as subject, audience, 74 // expiration time, and additional identity attributes added by STS as custom 75 // claims. You can also add your own custom claims to the token by passing tags as 76 // request parameters to the GetWebIdentityToken API. The token is signed using 77 // the specified signing algorithm and can be verified using the verification keys 78 // available at the issuer's JWKS endpoint. 79 WebIdentityToken *string 80 81 // Metadata pertaining to the operation's result. 82 ResultMetadata middleware.Metadata 83 84 noSmithyDocumentSerde 85 } 86 87 func (c *Client) addOperationGetWebIdentityTokenMiddlewares(stack *middleware.Stack, options Options) (err error) { 88 err = stack.Serialize.Add(&awsAwsquery_serializeOpGetWebIdentityToken{}, middleware.After) 89 if err != nil { 90 return err 91 } 92 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetWebIdentityToken{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 97 if err = addComputeContentLength(stack); err != nil { 98 return err 99 } 100 if err = addResolveEndpointMiddleware(stack, options); err != nil { 101 return err 102 } 103 if err = addComputePayloadSHA256(stack); err != nil { 104 return err 105 } 106 if err = addRecordResponseTiming(stack, options); err != nil { 107 return err 108 } 109 if err = addCredentialSource(stack, options); err != nil { 110 return err 111 } 112 if err = addOpGetWebIdentityTokenValidationMiddleware(stack); err != nil { 113 return err 114 } 115 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addResponseErrorMiddleware(stack); err != nil { 119 return err 120 } 121 if err = addRequestResponseLogging(stack, options); err != nil { 122 return err 123 } 124 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 125 return err 126 } 127 if err = addInterceptors(stack, options); err != nil { 128 return err 129 } 130 return nil 131 }