Bug #69106
openAssumeRoleWithWebIdentity inconsistent with AWS
0%
Description
I have been trying to get a GitLab CI pipeline working using AssumeRoleWithWebIdentity and GitLab's OpenID Connect (OIDC) Authentication Using ID Tokens (https://docs.gitlab.com/ee/ci/secrets/id_token_authentication.html).
In AWS one creates an OpenID Connect Identity Provider in IAM, configures a role to assume with a relevant Assume Role policy and some attached policies, then with a few magic environment variables you can assume the role transparently to perform AWS REST API calls. I figured I would do the same with Ceph RGW.
My first problem arose because I was sending the ID Token (WebIdentityToken POST parameter) with a newline on the end (%0A). Amazon STS clearly transparently trims that as a similar pipeline works fine in AWS. Once I worked out what was happening this was trivial to resolve ('echo -n' instead of just 'echo' in the script). This produced an "Invalid JWT token" error at log level 5.
My second problem is currently insurmountable: RGW's STS looks at different properties of the JWKS keys than STS, and GitLab doesn't supply the x5c property which is optional in RFC7517. This results in a "x5c not present" error at log level 0.
RGW's STS requires the x5c object, obtains the certificates from it, then compares those against the configured thumbprints: https://github.com/ceph/ceph/blob/fcf5b2fff2ff20c45994d4853e7181390d4b434d/src/rgw/rgw_rest_sts.cc#L449
In AWS, the x5c doesn't appear to be used at all: instead, the thumbprints are checked against the certificate on the host from which the keys are obtained, for example if the jwks_url is https://gitlab.com/oauth/discovery/keys then the thumbprints are checked against the certificates in the https://gitlab.com chain for HTTPS: https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateOpenIDConnectProvider.html#API_CreateOpenIDConnectProvider_RequestParameters
So rather than looking at the SSL/TLS certificates like AWS, STS wants x5c certificates in the JWKS and fails if it's not present.
Keycloak provides these x5c certificates in its JWKS, but GitLab and other OpenID Connect providers such as Kubernetes (which could enable using IRSA - IAM Roles for Service Accounts - with RGW) don't.
Would you consider changing this behaviour? I'm conscious that this would be a change in behaviour in RGW - even though it would more closely match the original AWS API that RGW is trying to mimic. If the idea is agreeable I may have a stab at writing the code myself.
CB Updated by Chris Boot almost 2 years ago
I've done some more digging and found related issues, though they don't seem to acknowledge the difference in how RGW's and AWS's STS works:
JI Updated by J. Eric Ivancich almost 2 years ago
- Assignee set to Pritha Srivastava
CB Updated by Casey Bodley almost 2 years ago
- Tags (freeform) set to sts
PS Updated by Pritha Srivastava almost 2 years ago ยท Edited
There is a PR here which tries to address these issues: https://github.com/ceph/ceph/pull/60985. Maybe you can help review and enhance it? (Apologies for the delayed response)
AW Updated by Alex Wojno almost 2 years ago
@chris boot , I have a draft PR open that seems to address the same issue you were having with the x5c. Given you are familiar with the STS logic, do you mind taking a look to see if it applies to your problem? https://github.com/ceph/ceph/pull/60985
CB Updated by Chris Boot almost 2 years ago
Alex Wojno wrote in #note-5:
@chris boot , I have a draft PR open that seems to address the same issue you were having with the x5c. Given you are familiar with the STS logic, do you mind taking a look to see if it applies to your problem? https://github.com/ceph/ceph/pull/60985
I'm afraid your PR doesn't really solve this bug, which is more about the difference with how RGW works compared to AWS, rather than just the x5c requirement. See https://tracker.ceph.com/issues/69106#note-5.
JI Updated by J. Eric Ivancich almost 2 years ago
- Status changed from New to In Progress
- Pull request ID set to 60985
PS Updated by Pritha Srivastava almost 2 years ago
Attempting to solve this for n&e (for the time being) here: https://github.com/ceph/ceph/pull/61796/commits/5a172f8e8e8637929a3069effd5325b855663185. The same can be used for all key types.