Skip to content

aws: Implementation of IAM Roles anywhere support in aws request signing (https://docs.aws.amazon.com/rolesanywhere/latest/userguide/introduction.html)#37193

Closed
nbaws wants to merge 33 commits intoenvoyproxy:mainfrom
nbaws:roles_anywhere
Closed

Conversation

@nbaws
Copy link
Copy Markdown
Contributor

@nbaws nbaws commented Nov 17, 2024

Commit Message: aws: Implementation of IAM Roles anywhere support in aws request signing
Additional Description: Creates an additional x509 credential type and adds custom signing support for IAM Roles Anywhere
Risk Level: Low
Testing: Unit
Docs Changes: doc update and sample config included
Release Notes: changelog update
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

nbaws added 16 commits November 3, 2024 10:06
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
@nbaws nbaws requested a review from mattklein123 as a code owner November 17, 2024 23:22
@nbaws nbaws marked this pull request as draft November 17, 2024 23:22
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #37193 was opened by nbaws.

see: more, trace.

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update initialisation

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

make tests compile

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

refactor

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

builds ok

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

add test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

cleanup

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

cleanup

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

signing test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

documentation

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

content type

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

revert some configs

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

revert some changes

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

revert some changes

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

revert additional change

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

partial refactor

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

refactor

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

refactor and format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

fix mocks

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

documentation

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

webidentity

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

still one test case broken

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

fixing test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

working expiration

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

more test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

asan

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

ssl init

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

leaks

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

coverage

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

additional test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

additional test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

data source modifications

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

more data source mods

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

test case fix

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

cert signing algorithm

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update headers

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update headers

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

no test leak

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

updated test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update tests

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

test update

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

format

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test case

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

update asn1 time

Signed-off-by: Nigel Brittain <nbaws@amazon.com>

fix test cases

Signed-off-by: Nigel Brittain <nbaws@amazon.com>
@nbaws nbaws marked this pull request as ready for review November 28, 2024 11:22
@nbaws
Copy link
Copy Markdown
Contributor Author

nbaws commented Nov 28, 2024

@suniltheta if you have bandwidth

nbaws and others added 3 commits November 28, 2024 22:23
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Copy link
Copy Markdown
Contributor

@suniltheta suniltheta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't go through all the files. Would it be possible to break the PR into multiple smaller chunks?

There are several functions, for example functions inside source/extensions/common/aws/signer_base_impl.cc or pemToAlgorithmSerialExpiration which are tricky to review since I don't have context on how it should be written. If you are able to break down the PR into individual pieces you can link in code comments from the docs what that piece of function is trying to solve based on the guidance given in https://docs.aws.amazon.com/rolesanywhere/latest/userguide/authentication-sign-process.html or other docs page.

I see we have two new high level CredentailsProvider class IAMRolesAnywhereX509CredentialsProvider & IAMRolesAnywhereCredentialsProvider. Would it be possible to add docs comments to explain what each of these classes are doing? If you happen to have a short doc, will help with the getting the context.


string role_session_name = 7;

google.protobuf.Duration session_duration = 8 [(validate.rules).duration = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this take a default value if not specified?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not specified there will be no duration sent, and the service will choose the duration. From https://docs.aws.amazon.com/rolesanywhere/latest/userguide/authentication-create-session.html:

durationSeconds
The duration, in seconds, of the role session. The value is optional and can range from 900 seconds (15 minutes) up to 43200 seconds (12 hours).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If durationSeconds is provided in the CreateSession (IAM Roles Anywhere credentialing API) request, the duration of the resulting session will be min(durationSeconds, profileDurationSeconds), where profileDurationSeconds is the durationSeconds value on the profile used in the request. Otherwise, if durationSeconds isn't provided in the request, profileDurationSeconds is used. Note that all of this just determines the value for durationSeconds that IAM Roles Anywhere sends in the AssumeRole request to STS (which the service will do internally). So if the maxSessionDuration on the role doesn't allow for the duration obtained through the described process, you'll receive a 403.

See: https://docs.aws.amazon.com/rolesanywhere/latest/userguide/authentication-create-session.html#credentials-object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the proto constraint should enforce the sizing in config, however it's entirely optional for the user to provide here. we should have 403 covered in test cases, but i will double check what is logged so it is possible to troubleshoot it

@nbaws
Copy link
Copy Markdown
Contributor Author

nbaws commented Dec 1, 2024

Couldn't go through all the files. Would it be possible to break the PR into multiple smaller chunks?

There are several functions, for example functions inside source/extensions/common/aws/signer_base_impl.cc or pemToAlgorithmSerialExpiration which are tricky to review since I don't have context on how it should be written. If you are able to break down the PR into individual pieces you can link in code comments from the docs what that piece of function is trying to solve based on the guidance given in https://docs.aws.amazon.com/rolesanywhere/latest/userguide/authentication-sign-process.html or other docs page.

I see we have two new high level CredentailsProvider class IAMRolesAnywhereX509CredentialsProvider & IAMRolesAnywhereCredentialsProvider. Would it be possible to add docs comments to explain what each of these classes are doing? If you happen to have a short doc, will help with the getting the context.

TY for your look through. I will add additional comments, and also carve off this code into its own source file so it is easier to understand. I will also add design documentation as per your suggestion.

nbaws added 3 commits December 4, 2024 01:42
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
nbaws added 4 commits December 4, 2024 02:09
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
@nbaws
Copy link
Copy Markdown
Contributor Author

nbaws commented Dec 4, 2024

@suniltheta I've refactored so this has less impact on existing source files. Fundamental code is the same and I've added a small design doc here: #37440
Inline documentation can also be found in source/extensions/common/aws/iam_roles_anywhere_credentials_provider_impl.h

Please let me know if you'd like any more detail here.

Copy link
Copy Markdown

@13ajay 13ajay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't gone through the entire PR yet, but I have gone through some of it. I'll add comments on the rest when I get around to it.


string role_session_name = 7;

google.protobuf.Duration session_duration = 8 [(validate.rules).duration = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If durationSeconds is provided in the CreateSession (IAM Roles Anywhere credentialing API) request, the duration of the resulting session will be min(durationSeconds, profileDurationSeconds), where profileDurationSeconds is the durationSeconds value on the profile used in the request. Otherwise, if durationSeconds isn't provided in the request, profileDurationSeconds is used. Note that all of this just determines the value for durationSeconds that IAM Roles Anywhere sends in the AssumeRole request to STS (which the service will do internally). So if the maxSessionDuration on the role doesn't allow for the duration obtained through the described process, you'll receive a 403.

See: https://docs.aws.amazon.com/rolesanywhere/latest/userguide/authentication-create-session.html#credentials-object

Signed-off-by: Nigel Brittain <nbaws@amazon.com>
@nbaws
Copy link
Copy Markdown
Contributor Author

nbaws commented Dec 10, 2024

/retest

nbaws and others added 5 commits December 10, 2024 14:33
Signed-off-by: Nigel Brittain <108375408+nbaws@users.noreply.github.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Signed-off-by: Nigel Brittain <nbaws@amazon.com>
@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Jan 10, 2025
@github-actions
Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot closed this Jan 18, 2025
mattklein123 pushed a commit that referenced this pull request Apr 5, 2025
Commit Message: aws: Implementation of IAM Roles anywhere support in aws
request signing
Additional Description:
Part 1 of patch to implement IAM Roles anywhere capability. Adds the
x509 credential type and the x509 signing base library.

Design brief: #37440
Previous PR: #37193


(https://docs.aws.amazon.com/rolesanywhere/latest/userguide/introduction.html)

Risk Level: Negligible - code currently unlinked
Testing: Unit
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

---------

Signed-off-by: Nigel Brittain <nbaws@amazon.com>
agrawroh pushed a commit to agrawroh/envoy that referenced this pull request Apr 9, 2025
Commit Message: aws: Implementation of IAM Roles anywhere support in aws
request signing
Additional Description:
Part 1 of patch to implement IAM Roles anywhere capability. Adds the
x509 credential type and the x509 signing base library.

Design brief: envoyproxy#37440
Previous PR: envoyproxy#37193


(https://docs.aws.amazon.com/rolesanywhere/latest/userguide/introduction.html)

Risk Level: Negligible - code currently unlinked
Testing: Unit
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

---------

Signed-off-by: Nigel Brittain <nbaws@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants