| 1 |
Amazon Web Services |
| 2 |
=================== |
| 3 |
|
| 4 |
`Amazon Web Services <https://aws.amazon.com>`__ allows one to delegate |
| 5 |
authentication through SAML2. |
| 6 |
|
| 7 |
SAML |
| 8 |
---- |
| 9 |
|
| 10 |
- Make sure you have followed the steps |
| 11 |
`here <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-saml.html>`__. |
| 12 |
- Go to https://your.portal.com/saml/metadata and save the resulting |
| 13 |
file locally. |
| 14 |
- In each AWS account, go to IAM -> Identity providers -> Create |
| 15 |
Provider. |
| 16 |
- Select ``SAML`` as the provider type |
| 17 |
- Choose a name (best if kept consistent between accounts), and then |
| 18 |
choose the metadata file you saved above. |
| 19 |
- Looking again at the links on the left side of the page, go to Roles |
| 20 |
-> Create role |
| 21 |
- Choose ``SAML / Saml 2.0 federation`` |
| 22 |
- Select the provider you just configured, click |
| 23 |
``Allow programmatic and AWSManagement Console access`` which will |
| 24 |
fill in the rest of the form for you, then click next. |
| 25 |
- Set whatever permissions you need to and then click ``Review``. |
| 26 |
- Choose a name for the role. These will shown to people when they log |
| 27 |
in, so make them descriptive. We have different accounts for |
| 28 |
different regions of the world, so I put the region into the role |
| 29 |
name so people know which account is which. |
| 30 |
|
| 31 |
|
| 32 |
.. attention:: |
| 33 |
|
| 34 |
If you have only one role, the configuration is simple. If you |
| 35 |
have multiple roles for different people, it is a little trickier. As |
| 36 |
you will see, the SAML attributes are not dynamic, so you have to set |
| 37 |
them in the session when a user logs in or use a custom function. In |
| 38 |
this example, I wanted to avoid managing custom functions on all the |
| 39 |
servers, so the SAML attributes are set in the session. We also use LDAP |
| 40 |
for user information, so I will describe that. In our LDAP tree, each |
| 41 |
user has attributes which are used quite heavily for dynamic groups and |
| 42 |
authorisation. You will want something similar, using whatever attribute |
| 43 |
makes sense to you. For example: |
| 44 |
|
| 45 |
.. code:: |
| 46 |
|
| 47 |
dn: uid=user,ou=people,dc=your,dc=com |
| 48 |
... |
| 49 |
ou: sysadmin |
| 50 |
ou: database |
| 51 |
ou: root |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
- Assuming you use the web interface to manage lemonldap, go to General |
| 56 |
Parameters -> Authentication parameters -> LDAP parameters -> |
| 57 |
Exported variables. Here set the key to the LDAP attribute and the |
| 58 |
value to something sensible. I keep them the same to make it easy. |
| 59 |
- Now go to \*Variables -> Macros*. Here set up variables which will be |
| 60 |
computed based on the attributes you exported above. You will need to |
| 61 |
emit strings in this format |
| 62 |
``arn:aws:iam::account-number:role/role-name1,arn:aws:iam::account-number:saml-provider/provider-name``. |
| 63 |
The parts you need to change are ``account-number``, ``role-name1`` |
| 64 |
and ``provier-name``. The last two will be the provider name and role |
| 65 |
names you just set up in AWS. |
| 66 |
- Perl works in here, so something like this is valid: ``aws_eu_role`` |
| 67 |
-> ``$ou =~ sysadmin ? "arn:aws..." : "arn:..."`` |
| 68 |
- If it easier, split multiple roles into different macros. Then tie |
| 69 |
all the variables you define together into one string concatenating |
| 70 |
them with whatever is in General Parameters -> Advanced Parameters -> |
| 71 |
Separator. Actually click into this field and move around with the |
| 72 |
arrow keys to see if there is a space, since spaces can be part of |
| 73 |
the separator. |
| 74 |
- Remember macros are defined alphanumerically, so you want one right |
| 75 |
at the end, like ``z_aws_roles`` -> |
| 76 |
``join("; ", $role_name1, $role_name2, ...)`` |
| 77 |
- On the left again, click ``SAML service providers``, then |
| 78 |
``Add SAML SP``. |
| 79 |
- Enter a name, click ok, then select it on the left. Select |
| 80 |
``Metadata``, then enter |
| 81 |
\`\ https://signin.aws.amazon.com/static/saml-metadata.xml\ \` in the |
| 82 |
``URL`` field, then click load. |
| 83 |
- Click ``Exported attributes`` on the left, then ``Add attribute`` |
| 84 |
twice to add two attributes. The first field is the name of a |
| 85 |
variable set in the user's session: |
| 86 |
|
| 87 |
- ``_whatToTrace`` -> |
| 88 |
``https://aws.amazon.com/SAML/Attributes/RoleSessionName`` (leave |
| 89 |
the rest) |
| 90 |
- ``z_aws_roles`` (the macro name you defined above) -> |
| 91 |
``https://aws.amazon.com/SAML/Attributes/Role`` (leave the rest) |
| 92 |
|
| 93 |
- On the left, select Options -> Security -> Enable use of IDP |
| 94 |
initiated URL -> On |
| 95 |
- Select General Parameters -> Portal -> Menu -> Categories and |
| 96 |
applications |
| 97 |
- Select a category or create a new one if you need to. Then click |
| 98 |
``New application``. |
| 99 |
- Enter a name etc. For the URL, use |
| 100 |
``https://your.portal.com/saml/singleSignOn?IDPInitiated=1&sp=urn:amazon:webservices`` |
| 101 |
- Display application should be set to ``Enabled`` |
| 102 |
- Go to your portal, click on the link, and check that it works! |