-
Notifications
You must be signed in to change notification settings - Fork 52
DOCSP-44256 Add Kubernetes Support for OIDC #950
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,7 +7,7 @@ Enterprise Authentication Mechanisms | |||||
.. contents:: On this page | ||||||
:local: | ||||||
:backlinks: none | ||||||
:depth: 1 | ||||||
:depth: 2 | ||||||
:class: singlecol | ||||||
|
||||||
.. facet:: | ||||||
|
@@ -21,8 +21,8 @@ In this guide, you can find sample code for connection to MongoDB with each | |||||
authentication mechanism available in the MongoDB Enterprise Edition: | ||||||
``Kerberos (GSSAPI/SSPI)``, ``LDAP (PLAIN)``, and ``MONGODB-OIDC``. | ||||||
|
||||||
``Kerberos (GSSAPI/SSPI)`` | ||||||
-------------------------- | ||||||
Kerberos (GSSAPI/SSPI) | ||||||
---------------------- | ||||||
|
||||||
.. note:: | ||||||
The Node.js driver supports Kerberos on UNIX using the MIT Kerberos library | ||||||
|
@@ -102,8 +102,8 @@ The following code sample authenticates to Kerberos for UNIX using ``GSSAPI``. | |||||
`GSSAPI RFC-4652 <https://tools.ietf.org/html/rfc4752>`_, the SASL | ||||||
mechanism. | ||||||
|
||||||
``LDAP (PLAIN)`` | ||||||
---------------- | ||||||
LDAP (PLAIN) | ||||||
------------ | ||||||
|
||||||
The ``PLAIN`` authentication mechanism uses your username and password to | ||||||
authenticate to a Lightweight Directory Access Protocol (LDAP) server. | ||||||
|
@@ -226,12 +226,35 @@ The following code example shows how to set the preceding connection options: | |||||
+ "&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:<audience>"; | ||||||
const client = new MongoClient(uri); | ||||||
|
||||||
Kubernetes | ||||||
~~~~~~~~~~ | ||||||
|
||||||
If your application runs on a Kubernetes cluster, you can authenticate to MongoDB by using | ||||||
the {+driver-short+}'s built-in Kubernetes support. | ||||||
|
||||||
To specify Kubernetes OIDC as the authentication mechanism, set the following | ||||||
options in your connection string: | ||||||
|
||||||
- ``authMechanism``: Set to ``MONGODB-OIDC``. | ||||||
- ``authMechanismProperties``: Set to ``ENVIRONMENT:k8s``. | ||||||
|
||||||
The following code example shows how to set the preceding connection options: | ||||||
|
||||||
.. code-block:: js | ||||||
:emphasize-lines: 3-4 | ||||||
|
||||||
const { MongoClient } = require("mongodb"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
minor, but we should use the modern import syntax in our snippets |
||||||
|
||||||
const uri = "mongodb://<hostname>:<port>/?authMechanism=MONGODB-OIDC" | ||||||
+ "&authMechanismProperties=ENVIRONMENT:k8s"; | ||||||
const client = new MongoClient(uri); | ||||||
|
||||||
Custom Callback | ||||||
~~~~~~~~~~~~~~~ | ||||||
|
||||||
The {+driver-short+} doesn't offer built-in support for all platforms, including | ||||||
Azure Functions and Azure Kubernetes Service (AKS). Instead, you | ||||||
must define a custom callback to use OIDC to authenticate from these platforms. | ||||||
Azure Functions. Instead, you must define a custom callback to use OIDC to | ||||||
authenticate from these platforms. | ||||||
|
||||||
First, define a function that retrieves the access token to use for OIDC authentication. | ||||||
This function must have the following signature: | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't add a comment on the line, but can you change
:depth:
to 2 at the top of the page? That way, the different OIDC options appear in the TOC on the right.