Commit Graph

24 Commits

Author SHA1 Message Date
Benjamin Brabant
7c7a1222d2
Fix saml-assertion parsing in assume-role-with-saml (#3523)
* Retrieve SAML Attribute by Name instead of relying on order which is too fragile

* Handle case when SAML Attribute SessionDuration is not provided, as it is not a required attribute from SAML response

When session duration not provided, AWS consider by default a duration of one hour as cited in the following documentation:
"If this attribute is not present, then the credential last for one hour (the default value of the DurationSeconds parameter of the AssumeRoleWithSAML API)."
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml_assertions.html#saml_role-session-duration

Traceback was:
[...]
  File "/Users/benjamin.brabant/Projects/PERSO/moto/moto/sts/responses.py", line 79, in assume_role_with_saml
    role = sts_backend.assume_role_with_saml(
  File "/Users/benjamin.brabant/Projects/PERSO/moto/moto/sts/models.py", line 99, in assume_role_with_saml
    role = AssumedRole(**kwargs)
TypeError: __init__() missing 1 required positional argument: 'duration'

* Process saml xml namespaces properly instead of relying on textual prefix that can vary between identity providers

* Handle when SAML response AttributeValue xml tag contains attributes that force xmltodict to build a dictionary as for complex types instead of directly returning string value

Leverage force_cdata option of xmltodict parser that always return a complex dictionary even if xml tag contains only text and no attributes.

* Improve existing test_assume_role_with_saml to be coherent with other assume_role_with_saml tests and remove dead code at the same time
2020-12-08 09:08:40 +00:00
Matěj Cepl
ea489bce6c Finish porting from nose to pytest. 2020-11-10 08:25:05 +01:00
Matěj Cepl
77dc60ea97 Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of
failures is left to the next commit.
2020-11-10 08:23:44 +01:00
Erik Hovland
88494c58f9 Add a test for assume_role_with_saml.
Add a test with SAML assertion to test the assume_role_with_saml method
in the STSBackend.
2020-04-16 11:47:30 -07:00
Fabio Dias
fd9ac4b9a5 ACCOUNT_ID moved to moto.core, MOTO_ACCOUNT_ID env var override 2019-12-16 21:05:29 -05:00
Asher Foa
96e5b1993d Run black on moto & test directories. 2019-10-31 10:36:05 -07:00
acsbendi
addb631081 Skip checking the expiration of AssumedRole in server mode. 2019-08-22 11:06:42 +02:00
acsbendi
3012740699 Fixed AssumedRole ARN. 2019-08-21 19:47:12 +02:00
acsbendi
6bdbd0dbc8 Fixed a broken test case and parameterized account ID in STS tests. 2019-08-21 13:17:58 +02:00
Bendegúz Ács
24dcdb7453
Merge branch 'master' into get-caller-identity 2019-08-21 12:36:40 +02:00
acsbendi
d931204266 Implemented get-caller-identity returning real data depending on the access key used. 2019-08-21 12:20:35 +02:00
acsbendi
d9cb1f2d35 Implemented returning random assumed role ID. 2019-08-21 10:45:36 +02:00
Grégory Bataille
67c8ea0352 fixes #2075 - STS should raise on too long policy for federation token 2019-07-20 08:41:52 +02:00
Carlos Aguado
e54f74776b Implement assume_role_with_web_identity
The AssumeRoleWithWebIdentity is a similar endpoint to STS's AssumeRole
where the authentication element is a JWT id_token from a configured OP.
This commit implements the functionality and relies on the same result
generated for the regular AssumeRole.
2019-07-16 13:27:47 +10:00
acsbendi
ab0d23a0ba AssumeRole returns randomly generated credentials. 2019-07-08 16:32:25 +02:00
Steve Pulec
f37bad0e00 Lints. 2017-02-23 21:37:43 -05:00
Steve Pulec
81836b6981 Get standalone server mode working for all tests. 2017-02-23 19:43:48 -05:00
Steve Pulec
fde721bed7 Testing new version of decorator. 2017-02-15 22:35:45 -05:00
Jesse Szwedko
f68b2963db sts: Implement get_caller_identity (#806)
Return a canned response

Signed-off-by: Andrew Harris <andrew.harris@getbraintree.com>
2017-01-18 22:59:04 -05:00
Steve Pulec
1a015d0e39 Cleanup some incorrect date formats. 2014-11-29 23:34:40 -05:00
David Baumgold
4201e6b430 from __future__ import unicode_literals 2014-08-27 11:33:55 -04:00
Konstantinos Koukopoulos
8e541ae9f8 add unit tests for get_federation_token 2014-03-20 18:46:03 +02:00
Steve Pulec
59fe1abfdf Cleanup flake8 2013-08-03 17:21:25 -04:00
Steve Pulec
212d9c7abe core sts endpoints completed 2013-05-24 17:22:34 -04:00