Desktop and Application Streaming
Enabling identity federation with Duo Single Sign-On and Amazon AppStream 2.0
Amazon AppStream 2.0 supports identity federation to AppStream 2.0 stacks through Security Assertion Markup Language 2.0 (SAML 2.0). This blog provides guidance on how to configure Duo Single Sign-On as an identity provider for AppStream 2.0.
If you don’t have an identity provider, you can use AWS Single Sign-On. Review the AppStream 2.0 administration guide on how to configure AWS SSO and other AppStream 2.0 supported third-party SAML 2.0 identity provider solution.
Overview of the Solution
This post shows how to configure Duo Single Sign-On with Amazon AppStream 2.0 so users can access their assigned stacks and applications. The steps to proceed through this post are:
- Create Duo SAML 2.0 application and download the metadata
- Create the SAML 2.0 identity provider (IdP)
- Configure an AWS Identity and Access Management (IAM) policy
- Create an IAM role
- Configure a Duo application
- Add the SAML application to Duo Central
- Test the application
- Use attribute-based application entitlement (optional)
Walkthrough
This walkthrough will guide you through the steps needed to authenticate to an Amazon AppStream 2.0 stack with Duo Single Sign-On.
Prerequisites
This post assumes you have the following:
- Setup Amazon AppStream 2.0 or a pre-existing stack and fleet.
- Enable Duo Single Sign-on for your Duo account and configure a working authentication source. Review the steps on the Duo documentation to enable Duo Single Sign-on and Authenticator source.
Step 1: Create Duo SAML 2.0 application and download the metadata
In this step, create a generic duo application for AppStream 2.0. You will download the metadata to be used in a later step.
- Sign in to the Duo Admin Account console.
- On the left panel, navigate to Applications.
- Select Protect an Application.
- Search for Custom to find Generic Service Provider and select Protect.
- In the Downloads section, choose Download XML. Save the metadata file.
Step 2: Create the SAML 2.0 identity provider (IdP)
Next, create an identity provider in the AWS Management console using the metadata from step 1.
- Navigate to the IAM console.
- Choose Identity providers in the navigation pane.
- Choose Add provider.
- For the Provider type, choose SAML.
- For the Provider name, type something meaningful to you, such as ProviderName.
- Choose Choose file and select the metadata document that you downloaded in step 1.
- Choose Add provider.
- Select the created provider from the list.
- On the summary page, copy the value for the Provider ARN. The ARN is in the following format: arn:aws:iam::AccountID:saml-provider/ProviderName
Step 3: Configure an AWS Identity and Access Management (IAM) policy
Next, create a policy with permissions to the AppStream 2.0 stack. This makes sure that users have only the permission to stream applications from a specific stack.
- In the IAM console, choose Policies, then Create Policy.
- Choose the JSON tab.
- Replace the contents of the sample policy with the below code.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "appstream:Stream", "Resource": "arn:aws:appstream:<region_code>:<account_id>:stack/<stack_name>", "Condition": { "StringEquals": { "appstream:userId": "${saml:sub}" } } } ] }
- Update the policy with the following changes:
-
- Replace <region_code> with your Region code. Use one of the following values based on the AWS Region your AppStream 2.0 stack is in.
- Replace <account_id> with your account id without spaces or dashes.
- Replace <stack_name> with your case-sensitive AppStream 2.0 stack name.
For more information, see the Setting Up SAML page in the AppStream 2.0 Admin Guide.
- After you’ve specified the policy, choose Next: Tags.
- Add any optional tags. Choose Next: Review.
- For the Name, enter a descriptive name, such as AppStream2_ExampleStack.
- For the Description, enter an optional description.
- Choose Create policy and you should see a notification that it has been created.
Step 4: Create an IAM role
Next, create the role that your Duo users assume when federating to AppStream 2.0.
- In the IAM console, choose Roles then Create role.
- For the Trusted entity type, choose SAML 2.0 federation.
- Under SAML provider, choose the SAML IdP that you created earlier.
- Do not choose either of the two SAML 2.0 access level methods for AppStream 2.0.
- For the Attribute, choose SAML:aud and Value enter https://signin.aws.amazon.com/saml
- Do not add any conditions.
- Choose Next.
- Select the box next to the IAM policy you created in Step 3. Choose Next.
- Enter a Role Name and Role Description that identifies the role, and choose Create Role.
- Find and select the newly created role from the list.
- Copy the Role ARN from the summary page. The ARN is required to configure claims rules later in this post. The ARN is in the following format: arn:aws:iam::AccountID:role/RoleName
Step 5: Configure a Duo application
With the IAM role created, we can now complete the setup in Duo.
- Sign in to your Duo console.
- In the navigation pane, choose Applications.
- Select Protect an Application.
- Search for Custom to find Generic Service Provider and select the Protect.
- Fill the information with the following details below:
Under Service Provider
Entity ID | urn:amazon:webservices |
Assertion Consumer Service (ACS) URL | https://signin.aws.amazon.com/saml |
Default Relay State | Enter your AppStream 2.0 Relay state. The Relay State is unique to your account, AWS Region, and AppStream 2.0 stack. For more information, visit Configure the Relay State of Your Federation. |
Under SAML Response
NameID format | urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress |
NamedID attribute | userPrincipalName |
Under Create attributes
We need to create two additional SAML attributes RoleSessionName and Role.
Name | Value |
https://aws.amazon.com/SAML/Attributes/RoleSessionName | userPrincipalName |
https://aws.amazon.com/SAML/Attributes/Role | This is the IAM Role ARN created in step 3, followed by a comma and then the IAM Provider ARN created in step 1.For our example, this would look like: arn:aws:iam::012345678910:role/RoleName,arn:aws:iam::012345678910:saml-provider/ProviderName |
- In the Settings section, enter a Name.
- Choose Save.
Step 6: Add the SAML application to Duo Central
Ensure that Duo Central is configured and the status is Online. See the Duo article on Configuring Duo Central.
- Navigate to the Duo admin console.
- Choose Single Sign-On.
- Choose Duo Central, then Add tile.
- In the What do you want to add to Duo Central dialog box, choose Add application tile.
- Select the box next to the name of the AppStream 2.0 application created in step 4.
- Choose Add tile.
Step 7: Test the application
To test the application, Browse the subdomain login URL copied from the Duo Central page. In our example https://<subdomain>.login.duosecurity.com/ and choose the application tile for AppStream 2.0.
Step 8: Use attribute-based application entitlement (optional)
Attribute-based application entitlements match a supported SAML attribute to a value when the user authenticates. Application entitlements don’t restrict what a user can access on the streaming instance. In application view, it limits what is shown on the application catalog.
These optional steps show you how to configure Duo to add a principal tag as a SAML attribute to the SAML assertion. The tag is based on a user’s department attribute for application entitlements.
- Update the IAM role to include sts:TagSession permission. For more information visit create a SAML 2.0 federation IAM role in the AppStream 2.0 administration guide.
- Update the Duo Application to include a department attribute. For more information on the principal tags supported by application entitlement see create application entitlements in the AppStream 2.0 administration guide.
- Navigate to the Duo Admin console.
- In the navigation pane, choose Applications.
- Select Protect an Application.
- Choose the application created in step 5.
- Under SAML Response, navigate to Map attributes and enter the following values:
- IdP Attribute: department
- SAML Response Attribute: https://aws.amazon.com/SAML/Attributes/PrincipalTag:department
- Update the Default Relay State to the following:
https://relay-state-region-endpoint?accountId=aws-account-id-without-hyphens - Choose Save.
- Update the AppStream 2.0 stack to use the principal tag to hide applications from the application catalog.
-
- Navigate to the AppStream 2.0 console.
- In the navigation pane, choose Stacks.
- Choose the stack associated with the fleet that contains the applications to limit.
- Under Application Entitlements, choose Create.
- Enter the following for the department attribute:
-
-
- Name: department-Finance
- Attribute Name: department
- Attribute Value: Finance
- Under Applications, choose each of the applications for finance department.
-
- Update the users attribute by setting the department attribute value to Finance. Follow the steps in step 7 to test your application. Your test user should only have the application with a matching application entitlement on the application catalog page.
Clean up resources
There is no additional cost to use SAML 2.0. For additional information on pricing, refer to the Amazon AppStream 2.0 pricing.
You can stop running your fleet to avoid unintended charges. Follow the instructions on clean up resources in the AppStream 2.0 administration guide to stop any unused running fleet and delete the associated stack.
Conclusion
In this post, we enabled federation with Duo Single Sign-On and Amazon AppStream 2.0. Duo metadata is unique per application. If multiple applications are configured, each will need its own respective IAM identity provider. For more information on setting up SAML 2.0 for AppStream 2.0, refer to the AppStream 2.0 Administration Guide.