Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRIVERS-2836 OIDC: Clarify that TOKEN_RESOURCE must be url-encoded #1569

Merged
merged 11 commits into from
Apr 29, 2024

Conversation

blink1073
Copy link
Member

Please complete the following before merging:

  • Update changelog.
  • Make sure there are generated JSON files from the YAML test files.
  • Test changes in at least one language driver.
  • Test these changes against all server versions and topologies (including standalone, replica set, sharded
    clusters, and serverless).

@blink1073 blink1073 requested a review from a team as a code owner April 24, 2024 11:22
@blink1073 blink1073 requested review from comandeo-mongo, sanych-sun and katcharov and removed request for a team and comandeo-mongo April 24, 2024 11:22
@blink1073
Copy link
Member Author

Tested with mongodb/mongo-python-driver#1616

@blink1073 blink1073 closed this Apr 24, 2024
@blink1073 blink1073 reopened this Apr 24, 2024
source/auth/auth.md Outdated Show resolved Hide resolved
source/auth/tests/legacy/connection-string.json Outdated Show resolved Hide resolved
source/auth/auth.md Show resolved Hide resolved
blink1073 and others added 2 commits April 24, 2024 15:29
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
@@ -1224,7 +1224,8 @@ in the MONGODB-OIDC specification, including sections or blocks that specificall
- TOKEN_RESOURCE\
The URI of the target resource. If `TOKEN_RESOURCE` is provided and `ENVIRONMENT` is not one of
`["azure", "gcp"]` or `TOKEN_RESOURCE` is not provided and `ENVIRONMENT` is one of `["azure", "gcp"]`, the driver
MUST raise an error.
MUST raise an error. Drivers MUST ensure that `TOKEN_RESOURCE` is url-encoded, such as by using a regex for special
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to have plain value here, because if some driver decide to use Azure/GCP/other SDK to pass the value - most likely SDK will do encoding on it's end. The fact that the value is being used as a url query parameter - this is implementation details and might be vary (if some other provider will use POST and pass the value in request body).

Copy link
Member

Choose a reason for hiding this comment

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

But then in the Azure and GCP section we have to require driver to encode the value as it being used as a query parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@blink1073 blink1073 requested a review from a team as a code owner April 24, 2024 20:50
@blink1073 blink1073 requested review from alcaeus and removed request for a team April 24, 2024 20:50
"mechanism": "MONGODB-OIDC",
"mechanism_properties": {
"ENVIRONMENT": "azure",
"TOKEN_RESOURCE": "a%24b"
Copy link
Member

Choose a reason for hiding this comment

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

Should we expect a$b here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because it is azure and we would have encoded it.

source/auth/auth.md Outdated Show resolved Hide resolved
source/auth/tests/legacy/connection-string.yml Outdated Show resolved Hide resolved
source/auth/auth.md Show resolved Hide resolved
@blink1073
Copy link
Member Author

@sanych-sun @katcharov I've updated the description and tests based on feedback

@blink1073
Copy link
Member Author

Updated tests in mongodb/mongo-python-driver#1620

Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

The latest revision looks good to me. Will implement the changes and verify if tests are working as expected for CSHARP Driver. If everything works well - will LGTM it later today.

ENVIRONMENT: azure
TOKEN_RESOURCE: 'mongodb://test-cluster'
- description: should accept an un-encoded TOKEN_RESOURCE (MONGODB-OIDC)
uri: mongodb://user@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:mongodb://test-cluster
Copy link
Member

Choose a reason for hiding this comment

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

Is this Uri valid? Should we have : in the mongodb://test-cluster encoded as %3A? Having more then one value separator confuses our parser. And it's kind of ambiguous:
TOKEN_RESOURCE:mongodb://test-cluster
should it be parsed as TOKEN_RESOURCE=mongodb://test-cluster or TOKEN_RESOURCE:mongodb=//test-cluster

Copy link
Contributor

Choose a reason for hiding this comment

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

This usage is against the advice we give to users in the spec, but I think we should optimistically decode this (like this in Java), rather than failing. Although it is indeed ambiguous, I think we will never put a : in the name of any property (precisely because it is a separator).

Copy link
Member

Choose a reason for hiding this comment

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

Yep, can do the same, just want to double check if we see this as expected behavior.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

One minor note, LGTM other than that.

source/auth/auth.md Outdated Show resolved Hide resolved
Co-authored-by: Andreas Braun <git@alcaeus.org>
Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

LGTM

source/auth/auth.md Outdated Show resolved Hide resolved
source/auth/auth.md Outdated Show resolved Hide resolved
blink1073 and others added 2 commits April 29, 2024 11:42
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
Copy link
Contributor

@katcharov katcharov left a comment

Choose a reason for hiding this comment

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

LGTM, with one comment

source/auth/auth.md Outdated Show resolved Hide resolved
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
@blink1073 blink1073 merged commit c59c932 into mongodb:master Apr 29, 2024
3 checks passed
@blink1073 blink1073 deleted the DRIVERS-2836-2 branch April 29, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants