Skip to content

DOCSP-34479 - OIDC #537

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

Merged
merged 11 commits into from
Apr 30, 2024
Merged

DOCSP-34479 - OIDC #537

merged 11 commits into from
Apr 30, 2024

Conversation

mongoKart
Copy link
Contributor

@mongoKart mongoKart commented Apr 25, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-34479
Staging - https://preview-mongodbmongokart.gatsbyjs.io/java/docsp-34479-oidc/fundamentals/enterprise-auth/#mongodb-oidc

Self-Review Checklist

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

.. code-block:: java

MongoCredential credential = MongoCredential.createOidcCredential("<username>")
.withMechanismProperty("ALLOWED_HOSTS", allowedHosts)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't information on this property anywhere, beyond it being a List<String>; I'm guessing it's new as part of the OIDC work. It would be good if we could provide some info on it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is new, and important, but is only used when a human callback is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do we want users to know about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

found in auth spec


MongoCredential credential = new Credential()
.withMechanismProperty("ALLOWED_HOSTS", allowedHosts)
.withMechanismProperty("OIDC_CALLBACK", (context) -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does this context object look like?

Copy link
Collaborator

Choose a reason for hiding this comment

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


.. code-block:: java

MongoClient mongoClient = MongoClients.create("mongodb://<username>@<hostname>:<port>/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:<resource>");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something will need to be said about URI-encoding the resource, once the issue is resolved in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the PyMongo docs and used "percent-encoded" on line 666 above.

@mongoKart mongoKart marked this pull request as ready for review April 25, 2024 20:23
@mongoKart mongoKart requested a review from katcharov April 25, 2024 20:26
Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

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

Looks good, just a few suggestions + question!


.. _mongodb-oidc:

``MONGODB-OIDC``
Copy link
Contributor

Choose a reason for hiding this comment

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

S: since the other authentication mechanisms aren't monospaced, I think this header format should align with those

Suggested change
``MONGODB-OIDC``
MONGODB-OIDC

(IMDS), you can authenticate to MongoDB by using the {+driver-short+}'s built-in Azure
support.

You can specify Azure IMDS OIDC authentication on a ``MongoClientSettings`` object either by
Copy link
Contributor

Choose a reason for hiding this comment

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

I: it looks like the MongoCredential code snippet uses a MongoClientSettings object, but the Connection String code does not. Maybe this should say "MongoClient object" instead?

Suggested change
You can specify Azure IMDS OIDC authentication on a ``MongoClientSettings`` object either by
You can specify Azure IMDS OIDC authentication on a ``MongoClient`` object either by

you can authenticate to MongoDB by using {+driver-short+}'s built-in GCP
support.

You can specify GCP IMDS OIDC authentication on a ``MongoClientSettings`` object either by
Copy link
Contributor

Choose a reason for hiding this comment

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

I: same comment as above about MongoClientSettings

Suggested change
You can specify GCP IMDS OIDC authentication on a ``MongoClientSettings`` object either by
You can specify GCP IMDS OIDC authentication on a ``MongoClient`` object either by

callback to retrieve an OIDC token, call the ``withMechanismProperty()`` method on
your ``MongoCredential`` object to set the following options:

- ``"ALLOWED_HOSTS"``: The list of allowed hostnames or IP addresses for MongoDB
Copy link
Contributor

Choose a reason for hiding this comment

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

I: add a period

Suggested change
- ``"ALLOWED_HOSTS"``: The list of allowed hostnames or IP addresses for MongoDB
- ``"ALLOWED_HOSTS"``: The list of allowed hostnames or IP addresses for MongoDB.

Comment on lines 413 to 414
``["*.mongodb.net", "*.mongodb-qa.net", "*.mongodb-dev.net", "*.mongodbgov.net",
"localhost", "127.0.0.1", "::1"]``.
Copy link
Contributor

Choose a reason for hiding this comment

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

S: looks like this value is cut off on the staging site and requires some horizontal scroll. Maybe adding a newline after "*.mongodb-dev.net" could fix it:

Suggested change
``["*.mongodb.net", "*.mongodb-qa.net", "*.mongodb-dev.net", "*.mongodbgov.net",
"localhost", "127.0.0.1", "::1"]``.
``["*.mongodb.net", "*.mongodb-qa.net", "*.mongodb-dev.net",
"*.mongodbgov.net", "localhost", "127.0.0.1", "::1"]``.

Copy link
Contributor Author

@mongoKart mongoKart Apr 26, 2024

Choose a reason for hiding this comment

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

good call. i don't think you can split a monospace string across lines, so i changed the wording.

matching subdomains. This property defaults to
``["*.mongodb.net", "*.mongodb-qa.net", "*.mongodb-dev.net", "*.mongodbgov.net",
"localhost", "127.0.0.1", "::1"]``.
- ``"OIDC_CALLBACK"``: The method that retrieves the OIDC token. This method must accept
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: is "OIDC_CALLBACK" a method? Or an option/parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an authentication mechanism property that works with the OIDC auth mechanism. The whole thing is like a key-value pair, where "OIDC_CALLBACK" is the key and the callback method is the value.


.. important::

The MONGODB-OIDC authentication mechanism requires MongoDB v7.0 or later running
Copy link
Contributor

Choose a reason for hiding this comment

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

S: I'd use {+mdb-server+} here

Suggested change
The MONGODB-OIDC authentication mechanism requires MongoDB v7.0 or later running
The MONGODB-OIDC authentication mechanism requires {+mdb-server+} v7.0 or later running

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good thought. this content was taken from pymongo, which doesn't have that constant.

@mongoKart mongoKart requested a review from norareidy April 26, 2024 16:12
Copy link
Collaborator

@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.

Some of the comments might apply to other languages as well.

Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

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

LGTM!

@mongoKart mongoKart requested a review from katcharov April 29, 2024 20:38
Copy link
Collaborator

@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!

@mongoKart mongoKart merged commit a1ec3d1 into mongodb:master Apr 30, 2024
@mongoKart mongoKart deleted the docsp-34479-oidc branch April 30, 2024 13:14
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.

3 participants