api_op_AssumeRoleWithSAML.go (20564B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package sts 4 5 import ( 6 "context" 7 8 "github.com/aws/aws-sdk-go-v2/service/sts/types" 9 "github.com/aws/smithy-go/middleware" 10 ) 11 12 // Returns a set of temporary security credentials for users who have been 13 // authenticated via a SAML authentication response. This operation provides a 14 // mechanism for tying an enterprise identity store or directory to role-based 15 // Amazon Web Services access without user-specific credentials or configuration. 16 // For a comparison of AssumeRoleWithSAML with the other API operations that 17 // produce temporary credentials, see [Requesting Temporary Security Credentials]and [Compare STS credentials] in the IAM User Guide. 18 // 19 // The temporary security credentials returned by this operation consist of an 20 // access key ID, a secret access key, and a security token. Applications can use 21 // these temporary security credentials to sign calls to Amazon Web Services 22 // services. 23 // 24 // AssumeRoleWithSAML will not work on IAM Identity Center managed roles. These 25 // roles' names start with AWSReservedSSO_ . 26 // 27 // # Session Duration 28 // 29 // By default, the temporary security credentials created by AssumeRoleWithSAML 30 // last for one hour. However, you can use the optional DurationSeconds parameter 31 // to specify the duration of your session. Your role session lasts for the 32 // duration that you specify, or until the time specified in the SAML 33 // authentication response's SessionNotOnOrAfter value, whichever is shorter. You 34 // can provide a DurationSeconds value from 900 seconds (15 minutes) up to the 35 // maximum session duration setting for the role. This setting can have a value 36 // from 1 hour to 12 hours. To learn how to view the maximum value for your role, 37 // see [View the Maximum Session Duration Setting for a Role]in the IAM User Guide. The maximum session duration limit applies when you 38 // use the AssumeRole* API operations or the assume-role* CLI commands. However 39 // the limit does not apply when you use those operations to create a console URL. 40 // For more information, see [Using IAM Roles]in the IAM User Guide. 41 // 42 // [Role chaining]limits your CLI or Amazon Web Services API role session to a maximum of one 43 // hour. When you use the AssumeRole API operation to assume a role, you can 44 // specify the duration of your role session with the DurationSeconds parameter. 45 // You can specify a parameter value of up to 43200 seconds (12 hours), depending 46 // on the maximum session duration setting for your role. However, if you assume a 47 // role using role chaining and provide a DurationSeconds parameter value greater 48 // than one hour, the operation fails. 49 // 50 // # Permissions 51 // 52 // The temporary security credentials created by AssumeRoleWithSAML can be used to 53 // make API calls to any Amazon Web Services service with the following exception: 54 // you cannot call the STS GetFederationToken or GetSessionToken API operations. 55 // 56 // (Optional) You can pass inline or managed [session policies] to this operation. You can pass a 57 // single JSON policy document to use as an inline session policy. You can also 58 // specify up to 10 managed policy Amazon Resource Names (ARNs) to use as managed 59 // session policies. The plaintext that you use for both inline and managed session 60 // policies can't exceed 2,048 characters. Passing policies to this operation 61 // returns new temporary credentials. The resulting session's permissions are the 62 // intersection of the role's identity-based policy and the session policies. You 63 // can use the role's temporary credentials in subsequent Amazon Web Services API 64 // calls to access resources in the account that owns the role. You cannot use 65 // session policies to grant more permissions than those allowed by the 66 // identity-based policy of the role that is being assumed. For more information, 67 // see [Session Policies]in the IAM User Guide. 68 // 69 // Calling AssumeRoleWithSAML does not require the use of Amazon Web Services 70 // security credentials. The identity of the caller is validated by using keys in 71 // the metadata document that is uploaded for the SAML provider entity for your 72 // identity provider. 73 // 74 // Calling AssumeRoleWithSAML can result in an entry in your CloudTrail logs. The 75 // entry includes the value in the NameID element of the SAML assertion. We 76 // recommend that you use a NameIDType that is not associated with any personally 77 // identifiable information (PII). For example, you could instead use the 78 // persistent identifier ( urn:oasis:names:tc:SAML:2.0:nameid-format:persistent ). 79 // 80 // # Tags 81 // 82 // (Optional) You can configure your IdP to pass attributes into your SAML 83 // assertion as session tags. Each session tag consists of a key name and an 84 // associated value. For more information about session tags, see [Passing Session Tags in STS]in the IAM User 85 // Guide. 86 // 87 // You can pass up to 50 session tags. The plaintext session tag keys can’t exceed 88 // 128 characters and the values can’t exceed 256 characters. For these and 89 // additional limits, see [IAM and STS Character Limits]in the IAM User Guide. 90 // 91 // An Amazon Web Services conversion compresses the passed inline session policy, 92 // managed policy ARNs, and session tags into a packed binary format that has a 93 // separate limit. Your request can fail for this limit even if your plaintext 94 // meets the other requirements. The PackedPolicySize response element indicates 95 // by percentage how close the policies and tags for your request are to the upper 96 // size limit. 97 // 98 // You can pass a session tag with the same key as a tag that is attached to the 99 // role. When you do, session tags override the role's tags with the same key. 100 // 101 // An administrator must grant you the permissions necessary to pass session tags. 102 // The administrator can also create granular permissions to allow you to pass only 103 // specific session tags. For more information, see [Tutorial: Using Tags for Attribute-Based Access Control]in the IAM User Guide. 104 // 105 // You can set the session tags as transitive. Transitive tags persist during role 106 // chaining. For more information, see [Chaining Roles with Session Tags]in the IAM User Guide. 107 // 108 // # SAML Configuration 109 // 110 // Before your application can call AssumeRoleWithSAML , you must configure your 111 // SAML identity provider (IdP) to issue the claims required by Amazon Web 112 // Services. Additionally, you must use Identity and Access Management (IAM) to 113 // create a SAML provider entity in your Amazon Web Services account that 114 // represents your identity provider. You must also create an IAM role that 115 // specifies this SAML provider in its trust policy. 116 // 117 // For more information, see the following resources: 118 // 119 // [About SAML 2.0-based Federation] 120 // - in the IAM User Guide. 121 // 122 // [Creating SAML Identity Providers] 123 // - in the IAM User Guide. 124 // 125 // [Configuring a Relying Party and Claims] 126 // - in the IAM User Guide. 127 // 128 // [Creating a Role for SAML 2.0 Federation] 129 // - in the IAM User Guide. 130 // 131 // [View the Maximum Session Duration Setting for a Role]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session 132 // [Creating a Role for SAML 2.0 Federation]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_saml.html 133 // [IAM and STS Character Limits]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html#reference_iam-limits-entity-length 134 // [Creating SAML Identity Providers]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html 135 // [session policies]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session 136 // [Requesting Temporary Security Credentials]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html 137 // [Compare STS credentials]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_sts-comparison.html 138 // [Tutorial: Using Tags for Attribute-Based Access Control]: https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html 139 // [Configuring a Relying Party and Claims]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml_relying-party.html 140 // [Role chaining]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-role-chaining 141 // [Using IAM Roles]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html 142 // [Session Policies]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session 143 // [Passing Session Tags in STS]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html 144 // [About SAML 2.0-based Federation]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html 145 // [Chaining Roles with Session Tags]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_role-chaining 146 func (c *Client) AssumeRoleWithSAML(ctx context.Context, params *AssumeRoleWithSAMLInput, optFns ...func(*Options)) (*AssumeRoleWithSAMLOutput, error) { 147 if params == nil { 148 params = &AssumeRoleWithSAMLInput{} 149 } 150 151 result, metadata, err := c.invokeOperation(ctx, "AssumeRoleWithSAML", params, optFns, c.addOperationAssumeRoleWithSAMLMiddlewares) 152 if err != nil { 153 return nil, err 154 } 155 156 out := result.(*AssumeRoleWithSAMLOutput) 157 out.ResultMetadata = metadata 158 return out, nil 159 } 160 161 type AssumeRoleWithSAMLInput struct { 162 163 // The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the 164 // IdP. 165 // 166 // This member is required. 167 PrincipalArn *string 168 169 // The Amazon Resource Name (ARN) of the role that the caller is assuming. 170 // 171 // This member is required. 172 RoleArn *string 173 174 // The base64 encoded SAML authentication response provided by the IdP. 175 // 176 // For more information, see [Configuring a Relying Party and Adding Claims] in the IAM User Guide. 177 // 178 // [Configuring a Relying Party and Adding Claims]: https://docs.aws.amazon.com/IAM/latest/UserGuide/create-role-saml-IdP-tasks.html 179 // 180 // This member is required. 181 SAMLAssertion *string 182 183 // The duration, in seconds, of the role session. Your role session lasts for the 184 // duration that you specify for the DurationSeconds parameter, or until the time 185 // specified in the SAML authentication response's SessionNotOnOrAfter value, 186 // whichever is shorter. You can provide a DurationSeconds value from 900 seconds 187 // (15 minutes) up to the maximum session duration setting for the role. This 188 // setting can have a value from 1 hour to 12 hours. If you specify a value higher 189 // than this setting, the operation fails. For example, if you specify a session 190 // duration of 12 hours, but your administrator set the maximum session duration to 191 // 6 hours, your operation fails. To learn how to view the maximum value for your 192 // role, see [View the Maximum Session Duration Setting for a Role]in the IAM User Guide. 193 // 194 // By default, the value is set to 3600 seconds. 195 // 196 // The DurationSeconds parameter is separate from the duration of a console 197 // session that you might request using the returned credentials. The request to 198 // the federation endpoint for a console sign-in token takes a SessionDuration 199 // parameter that specifies the maximum length of the console session. For more 200 // information, see [Creating a URL that Enables Federated Users to Access the Amazon Web Services Management Console]in the IAM User Guide. 201 // 202 // [View the Maximum Session Duration Setting for a Role]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session 203 // [Creating a URL that Enables Federated Users to Access the Amazon Web Services Management Console]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html 204 DurationSeconds *int32 205 206 // An IAM policy in JSON format that you want to use as an inline session policy. 207 // 208 // This parameter is optional. Passing policies to this operation returns new 209 // temporary credentials. The resulting session's permissions are the intersection 210 // of the role's identity-based policy and the session policies. You can use the 211 // role's temporary credentials in subsequent Amazon Web Services API calls to 212 // access resources in the account that owns the role. You cannot use session 213 // policies to grant more permissions than those allowed by the identity-based 214 // policy of the role that is being assumed. For more information, see [Session Policies]in the IAM 215 // User Guide. 216 // 217 // The plaintext that you use for both inline and managed session policies can't 218 // exceed 2,048 characters. The JSON policy characters can be any ASCII character 219 // from the space character to the end of the valid character list (\u0020 through 220 // \u00FF). It can also include the tab (\u0009), linefeed (\u000A), and carriage 221 // return (\u000D) characters. 222 // 223 // For more information about role session permissions, see [Session policies]. 224 // 225 // An Amazon Web Services conversion compresses the passed inline session policy, 226 // managed policy ARNs, and session tags into a packed binary format that has a 227 // separate limit. Your request can fail for this limit even if your plaintext 228 // meets the other requirements. The PackedPolicySize response element indicates 229 // by percentage how close the policies and tags for your request are to the upper 230 // size limit. 231 // 232 // [Session Policies]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session 233 // [Session policies]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session 234 Policy *string 235 236 // The Amazon Resource Names (ARNs) of the IAM managed policies that you want to 237 // use as managed session policies. The policies must exist in the same account as 238 // the role. 239 // 240 // This parameter is optional. You can provide up to 10 managed policy ARNs. 241 // However, the plaintext that you use for both inline and managed session policies 242 // can't exceed 2,048 characters. For more information about ARNs, see [Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces]in the 243 // Amazon Web Services General Reference. 244 // 245 // An Amazon Web Services conversion compresses the passed inline session policy, 246 // managed policy ARNs, and session tags into a packed binary format that has a 247 // separate limit. Your request can fail for this limit even if your plaintext 248 // meets the other requirements. The PackedPolicySize response element indicates 249 // by percentage how close the policies and tags for your request are to the upper 250 // size limit. 251 // 252 // Passing policies to this operation returns new temporary credentials. The 253 // resulting session's permissions are the intersection of the role's 254 // identity-based policy and the session policies. You can use the role's temporary 255 // credentials in subsequent Amazon Web Services API calls to access resources in 256 // the account that owns the role. You cannot use session policies to grant more 257 // permissions than those allowed by the identity-based policy of the role that is 258 // being assumed. For more information, see [Session Policies]in the IAM User Guide. 259 // 260 // [Session Policies]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session 261 // [Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html 262 PolicyArns []types.PolicyDescriptorType 263 264 noSmithyDocumentSerde 265 } 266 267 // Contains the response to a successful AssumeRoleWithSAML request, including temporary Amazon Web 268 // Services credentials that can be used to make Amazon Web Services requests. 269 type AssumeRoleWithSAMLOutput struct { 270 271 // The identifiers for the temporary security credentials that the operation 272 // returns. 273 AssumedRoleUser *types.AssumedRoleUser 274 275 // The value of the Recipient attribute of the SubjectConfirmationData element of 276 // the SAML assertion. 277 Audience *string 278 279 // The temporary security credentials, which include an access key ID, a secret 280 // access key, and a security (or session) token. 281 // 282 // The size of the security token that STS API operations return is not fixed. We 283 // strongly recommend that you make no assumptions about the maximum size. 284 Credentials *types.Credentials 285 286 // The value of the Issuer element of the SAML assertion. 287 Issuer *string 288 289 // A hash value based on the concatenation of the following: 290 // 291 // - The Issuer response value. 292 // 293 // - The Amazon Web Services account ID. 294 // 295 // - The friendly name (the last part of the ARN) of the SAML provider in IAM. 296 // 297 // The combination of NameQualifier and Subject can be used to uniquely identify a 298 // user. 299 // 300 // The following pseudocode shows how the hash value is calculated: 301 // 302 // BASE64 ( SHA1 ( "https://example.com/saml" + "123456789012" + "/MySAMLIdP" ) ) 303 NameQualifier *string 304 305 // A percentage value that indicates the packed size of the session policies and 306 // session tags combined passed in the request. The request fails if the packed 307 // size is greater than 100 percent, which means the policies and tags exceeded the 308 // allowed space. 309 PackedPolicySize *int32 310 311 // The value in the SourceIdentity attribute in the SAML assertion. The source 312 // identity value persists across [chained role]sessions. 313 // 314 // You can require users to set a source identity value when they assume a role. 315 // You do this by using the sts:SourceIdentity condition key in a role trust 316 // policy. That way, actions that are taken with the role are associated with that 317 // user. After the source identity is set, the value cannot be changed. It is 318 // present in the request for all actions that are taken by the role and persists 319 // across [chained role]sessions. You can configure your SAML identity provider to use an 320 // attribute associated with your users, like user name or email, as the source 321 // identity when calling AssumeRoleWithSAML . You do this by adding an attribute to 322 // the SAML assertion. For more information about using source identity, see [Monitor and control actions taken with assumed roles]in 323 // the IAM User Guide. 324 // 325 // The regex used to validate this parameter is a string of characters consisting 326 // of upper- and lower-case alphanumeric characters with no spaces. You can also 327 // include underscores or any of the following characters: =,.@- 328 // 329 // [chained role]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html#id_roles_terms-and-concepts 330 // [Monitor and control actions taken with assumed roles]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_monitor.html 331 SourceIdentity *string 332 333 // The value of the NameID element in the Subject element of the SAML assertion. 334 Subject *string 335 336 // The format of the name ID, as defined by the Format attribute in the NameID 337 // element of the SAML assertion. Typical examples of the format are transient or 338 // persistent . 339 // 340 // If the format includes the prefix urn:oasis:names:tc:SAML:2.0:nameid-format , 341 // that prefix is removed. For example, 342 // urn:oasis:names:tc:SAML:2.0:nameid-format:transient is returned as transient . 343 // If the format includes any other prefix, the format is returned with no 344 // modifications. 345 SubjectType *string 346 347 // Metadata pertaining to the operation's result. 348 ResultMetadata middleware.Metadata 349 350 noSmithyDocumentSerde 351 } 352 353 func (c *Client) addOperationAssumeRoleWithSAMLMiddlewares(stack *middleware.Stack, options Options) (err error) { 354 err = stack.Serialize.Add(&awsAwsquery_serializeOpAssumeRoleWithSAML{}, middleware.After) 355 if err != nil { 356 return err 357 } 358 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpAssumeRoleWithSAML{}, middleware.After) 359 if err != nil { 360 return err 361 } 362 363 if err = addComputeContentLength(stack); err != nil { 364 return err 365 } 366 if err = addResolveEndpointMiddleware(stack, options); err != nil { 367 return err 368 } 369 if err = addRecordResponseTiming(stack, options); err != nil { 370 return err 371 } 372 if err = addCredentialSource(stack, options); err != nil { 373 return err 374 } 375 if err = addOpAssumeRoleWithSAMLValidationMiddleware(stack); err != nil { 376 return err 377 } 378 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 379 return err 380 } 381 if err = addResponseErrorMiddleware(stack); err != nil { 382 return err 383 } 384 if err = addRequestResponseLogging(stack, options); err != nil { 385 return err 386 } 387 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 388 return err 389 } 390 if err = addInterceptors(stack, options); err != nil { 391 return err 392 } 393 return nil 394 }