Skip to content

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

Merged
blink1073 merged 11 commits into
mongodb:masterfrom
blink1073:DRIVERS-2836-2
Apr 29, 2024
Merged

DRIVERS-2836 OIDC: Clarify that TOKEN_RESOURCE must be url-encoded#1569
blink1073 merged 11 commits into
mongodb:masterfrom
blink1073:DRIVERS-2836-2

Conversation

@blink1073

Copy link
Copy Markdown
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, katcharov and sanych-sun and removed request for a team and comandeo-mongo April 24, 2024 11:22
@blink1073

Copy link
Copy Markdown
Member Author

Tested with mongodb/mongo-python-driver#1616

@blink1073 blink1073 closed this Apr 24, 2024
@blink1073 blink1073 reopened this Apr 24, 2024
Comment thread source/auth/auth.md Outdated
Comment thread source/auth/tests/legacy/connection-string.json Outdated
Comment thread source/auth/auth.md
Steven Silvester and others added 2 commits April 24, 2024 15:29
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
Comment thread source/auth/auth.md Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread source/auth/tests/legacy/connection-string.yml Outdated
Comment thread source/auth/auth.md Outdated
Comment thread source/auth/tests/legacy/connection-string.yml Outdated
Comment thread source/auth/auth.md
Comment thread source/auth/tests/legacy/connection-string.yml Outdated
@blink1073 blink1073 requested a review from katcharov April 26, 2024 00:56
@blink1073

Copy link
Copy Markdown
Member Author

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

@blink1073

Copy link
Copy Markdown
Member Author

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

@sanych-sun sanych-sun left a comment

Copy link
Copy Markdown
Member

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

@sanych-sun sanych-sun Apr 26, 2024

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@alcaeus alcaeus left a comment

Copy link
Copy Markdown
Member

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.

Comment thread source/auth/auth.md Outdated
Co-authored-by: Andreas Braun <git@alcaeus.org>
@blink1073 blink1073 requested a review from sanych-sun April 29, 2024 12:35

@sanych-sun sanych-sun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread source/auth/auth.md Outdated
Comment thread source/auth/auth.md Outdated
Comment thread source/auth/tests/legacy/connection-string.json
Steven Silvester and others added 2 commits April 29, 2024 11:42
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>

@katcharov katcharov left a comment

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.

LGTM, with one comment

Comment thread source/auth/auth.md Outdated
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
@blink1073 blink1073 merged commit c59c932 into mongodb:master Apr 29, 2024
@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.

4 participants