Closed kgilpin closed 6 years ago
aws
to prod
. I think its purpose is more clear that way.role: !group conjur/authn-iam/prod/clients
is granted to the host, not to the layer. myapp/aws/011915987442:assumed-role/MyApp-InstanceProfile
to myapp/arn:aws:sts::011915987442:MyApp
.Maybe I am misunderstanding something, but why would "assumed-role" be part of the role name, and why would "-InstanceProfile" be part of the role name? Wouldn't the role name just be a simple logical name that describes the role, such as "MyApp"?
Maybe “arn:aws:sts::” should be assumed, simplifying the host to “!host 011915987442/MyApp”
Loving this concept. I was working on a proof of concept lambda using the Conjur API the other day and was wishing I could use an IAM role for auth. I need to learn enough about operating AWS to create a demo for this authenticator as soon as it's written.
I like the suggestion of removing "arn:aws:sts::" to simplify policy... and at the end also simplifies validation... as the hostname needs to be passed (login role) as part of the conjur API authenticate call, and the authentication framework already validates that the webservice has authenticate permissions on the role... in the authentication validation I reconstruct a hostname by using the information received from the getCallerIdentity and match it against the login role passed.
I will update the description in the policy above to adjust to it.
I did a quick test, and it worked fine from an EC2 instance.
@kgilpin @jvanderhoof @Daniel-Warner-X
Feature Overview The Conjur IAM Authenticator allows an AWS resource to use its AWS IAM role to authenticate with Conjur. This approach enables EC2 instances and Lambda functions to access credentials stored in Conjur without a pre-configured Conjur identity.
Setup To enable an IAM Authenticator called
prod
, we'll set the following environment variable when we start Conjur:In this context,
prod
is the called theservice ID
. Multiple authenticators can be configured with different service IDs. Each one implements a separate "zone" of authentication.After Conjur is started, we'll create a policy to enable our
prod
IAM Authenticator:Next, let's create an application policy to provide a database username and password to an AWS services. The IAM role in this example is
011915987442:MyApp
:Important: Note above host has an ID composed of a prefix/namespace followed by the AWS account ID followed by the name of the AWS IAM role. The AWS Account ID and name of the role is extracted from the getCallerIdentity by the authenticator
Finally, let's give our
myapp
host permission to authenticate using the IAM Authenticator:Workflow
Now that the IAM Authenticator has been configure and we've permitted an IAM role to authenticate, let's look at the authentication flow of an EC2 instance or Lambda function.
The instance or function starts, assuming the IAM role it was provided.
From the instance of function, generate a signed request to the STS service, to get the identify of the requestor. This request is signed using the instance or function's access key. The signed request is valid for five minutes. Below is an example of how a signed request would be generated (using Ruby):
3) Using the signed request, the instance or function authenticates with Conjur using the following:
When Conjur receives this authentication request, it performs the following:
Validates the host
myapp/011915987442/MyApp
has permission toauthenticate
using theprod
IAM Authenticator.Extracts the signed request from the POST body.
Creates a request to the AWS STS service, using the provided signed request as its header.
If the STS request is successful, the requesting instance or function's IAM role is returned. The role is Validated against the requesting role. If the two roles match, an authentication token is returned. Below is an example of a successful STS response:
Authentication may fail for a number of reasons. In each case, a 401 Unauthorized response will be returned.
Reasons for failing authentication include:
See also
Previous (deprecated) design: #536