Skip to content

Unable to use RDS IAM Authentication with SSO + external IdP

0

Hi there!

I'm trying to use RDS Authentication to allow users to connect to our databases via DBeaver or PgAdmin for example using SSO, but I'm getting the "PAM authentication failed for your user" error in all my attempts.

Here are the details:

  • Database is Postgres, feature is already enabled.
  • I'm using SSO with external identity provider (Azure AD), SAML 2.0 auth method, SCIM provisioning method.
  • I've added the policy below to the Organization, with all the accounts under/including the root as target:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "rds-db:connect",
      "Resource": "*"
    }
  ]
}
  • Created the IAM policy below and attached to the SSO group permission set as a customer managed policy. The usernames in SSO are the user's email and I included only one in the policy for initial testing. I couldn't use a dummy email so I went with emailgoeshere in order to be able to post here.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowRDSConnect",
            "Effect": "Allow",
            "Action": "rds-db:connect",
            "Resource": [
                "arn:aws:rds-db:us-east-1:44444444444:dbuser:db-BUNCHOFLETTERS/emailgoeshere"
            ]
        }
    ]
}
  • I have also tried enabling dynamic permissions and tweaking the policy following the top answer to this post. = replaced "emailgoeshere" with "${aws:username}". My attributes for access control section looks like this:
 Key: username
 Value: ${path:userName}
  • Created the user following the doc:
CREATE USER "emailgoeshere" WITH LOGIN; 
GRANT rds_iam TO "emailgoeshere";

Today I created an IAM user, attached the same policy to an IAM group and managed to successfully connect to the database, but no luck with SSO.

Does anyone have any pointers on this issue or managed to use the feature in a similar scenario?

1 Answer
0

It seems the issue you're experiencing is related to the integration of RDS IAM Authentication with SSO and an external identity provider (Azure AD in your case). This setup can be complex, and there are a few things to consider:

  1. IAM database authentication is designed to work with IAM users and roles, but it may not directly support external identity providers through SSO. The successful connection with an IAM user suggests that the RDS IAM Authentication itself is working correctly.

  2. When using SSO with an external IdP, the identity of the user is managed by the external system, which may not translate directly to the IAM identity expected by RDS IAM Authentication.

  3. The "PAM authentication failed" error typically indicates that the database is not recognizing the authentication token or the user identity.

To address this issue, you might consider the following approaches:

  1. Instead of directly using SSO credentials, you could set up a process where SSO users assume an IAM role that has the necessary permissions for RDS IAM Authentication. This extra step might bridge the gap between SSO and RDS IAM Auth.

  2. Ensure that the SSO user's identity (email in your case) exactly matches the database username you've created. Any mismatch here could cause authentication failures.

  3. Double-check that the ARN in your IAM policy correctly matches your database instance identifier. The format should be: arn:aws:rds-db:region:account-id:dbuser:db-resource-id/database-username

  4. If you're using the AWS CLI or SDKs to generate the authentication token, make sure you're using the correct credentials - those of the assumed IAM role rather than the SSO user directly.

  5. Consider using AWS Secrets Manager or AWS Systems Manager Parameter Store to manage database credentials as an alternative if RDS IAM Authentication with SSO proves too challenging to implement.

If these approaches don't resolve the issue, you may need to reach out to AWS Support for further assistance, as the interaction between SSO, external IdPs, and RDS IAM Authentication can be complex and may require deeper investigation.

Sources
RDS IAM Auth + SSO Users | AWS re:Post
Database authentication with Amazon RDS - Amazon Relational Database Service
Cannot connect to RDS Postgres using the IAM Authentication | AWS re:Post

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.