Skip to content

Conversation

mongoKart
Copy link
Collaborator

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-38861
Staging - https://preview-mongodbmongokart.gatsbyjs.io/pymongo/docsp-38861-oidc/security/authentication/

Self-Review Checklist

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

Copy link
Collaborator

@jordan-smith721 jordan-smith721 left a comment

Choose a reason for hiding this comment

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

Nice work on this! A few fixes but otherwise LGTM

The MONGODB-OIDC authentication mechanism requires MongoDB v7.0 or later running
on a Linux platform.

{+driver-short+} supports OIDC authentication for *workload identities*. A workload
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{+driver-short+} supports OIDC authentication for *workload identities*. A workload
{+driver-short+} supports OIDC authentication for **workload identities**. A workload

export AWS_WEB_IDENTITY_TOKEN_FILE=<absolute path to file containing OIDC token>

Then, define a class that inherits from the ``OIDCCallback`` class. This class must
implement one method, ``fetch()``, that returns the OIDC token in the form of an
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should also fix the Vale issue

Suggested change
implement one method, ``fetch()``, that returns the OIDC token in the form of an
implement a ``fetch()`` method, which returns the OIDC token in the form of an


You can set these options in two ways: by passing arguments to the
``MongoClient`` constructor or through parameters in your connection string.
After you set the preceding environment variable,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this line was supposed to be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch. there was so much copy/pasting for this ticket

Comment on lines +4 to +6
properties = {"ENVIRONMENT": "azure", "TOKEN_RESOURCE": "<audience>"}
client = MongoClient(
"mongodb://<hostname>:<port>",
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: Space this out for readability since the example is focused on the client (applies to all code examples)

Suggested change
properties = {"ENVIRONMENT": "azure", "TOKEN_RESOURCE": "<audience>"}
client = MongoClient(
"mongodb://<hostname>:<port>",
properties = {"ENVIRONMENT": "azure", "TOKEN_RESOURCE": "<audience>"}
client = MongoClient(
"mongodb://<hostname>:<port>",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added highlighting

python3 -m pip install azure-identity

Next, define a class that inherits from the ``OIDCCallback`` class. This class must
implement one method, ``fetch()``, that returns the OIDC token in the form of an
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
implement one method, ``fetch()``, that returns the OIDC token in the form of an
implement a ``fetch()`` method, which returns the OIDC token in the form of an

you can read the OIDC token from the standard service-account token-file location.

First, define a class that inherits from the ``OIDCCallback`` class. This class must
implement one method, ``fetch()``, that returns the OIDC token in the form of an
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
implement one method, ``fetch()``, that returns the OIDC token in the form of an
implement a ``fetch()`` method, which returns the OIDC token in the form of an

properties = {"OIDC_CALLBACK": MyCallback()}
uri = ("mongodb://<hostname>:<port>/?"
"&authMechanism=MONGODB-OIDC"
"&authMechanismProperties=properties")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you pass properties in the connection string this way?

Copy link
Member

Choose a reason for hiding this comment

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

No, you cannot pass the callback in the connection string

Copy link
Member

@blink1073 blink1073 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 d0a68ae into mongodb:master Apr 24, 2024
@mongoKart mongoKart deleted the docsp-38861-oidc branch April 24, 2024 17:06
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