- Notifications
You must be signed in to change notification settings - Fork 246
DRIVERS-2415 Implement OIDC SASL mechanism #1365
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
Conversation
source/auth/auth.rst Outdated
| PRINCIPAL_NAME | ||
| Drivers MUST allow the user to specify a principal name, which | ||
| is required by the server when more than one Identity Provider | ||
| is configured. |
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.
It’s a surprise that we expect PRINCIPAL_NAME as an auth mechanism property instead of passing it in the username. Is there a specific reason for this? As I understand it, it fulfills the same role as the username, and in particular also matches the role of the username for similar auth mechanisms like Kerberos or LDAP.
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 thought it might be misleading to use the username field, since the server is actually creating a derived username for this session.
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 guess the question then is about the semantics of the username field, whether it is “This is the identity I am attempting to authenticate as” or “This is the username string that the database uses and reports”. I would maybe still lean towards interpreting it as the former, although I see your point about this differing from the DB username.
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.
@sgolemon do you have any feelings on this? I'm vaguely reminded of how during LDAP authentication we map the presented authentication name into a name which the LDAP server will recognize through the UserToDNMapping.
I'm also leaning heavily toward the username in mongodb://[username:password@]host1 is "This is the identity I am attempting to authenticate as" as Anna said
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 do have feelings! My assumption was that the principal name hint would and should be the username, and not a custom property as that seems like "least surprise" from an end-developer point of view. It's true that the derived principal name may differ (depending on IDP and MongoDB configurations), but from the application point of view the synthesized principal name is an implementation detail and all we get by placing the hint into mechanism properties and prohibiting the username field is a little confusion about why it's not in the usual spot.
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.
From my understanding of the server technical design and implementation, the principal name is by default the "sub" field of the jwt token, which if the IdP uses pairwise identifiers is obfuscated by a salt.
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.
So in that case it feels even less like a user name.
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.
@blink1073 On today's initiative sync we briefly touched on this, and the sentiment was to use the username field like we would for LDAP and Kerberos. Unless there are concerns with it that haven't been brought up so far, this shouldn't be an auth mechanism property.
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.
Okay fair, I will update the spec and connection string tests.
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.
Done
source/auth/auth.rst Outdated
| If the driver implements a global cache, the cache keys MUST include the | ||
| principal name if given, and a hash of the callback function, if possible | ||
| in the driver's language. A global cache should be preferred, to prevent | ||
| multiple browser interactions in the case of an authentication code | ||
| workflow. |
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.
Two things:
- In the devtools products, we won’t really be able to make use of this feature since we’ll need to maintain a cache across MongoClient instances in different processes. I could imagine that other products, if there are any, that use browser flows, would run into similar issues at some point. Consequently, I don’t know if adding global mutable state is worth it here – definitely not a blocker though!
- The cache key should probably include some form of cluster identifier, since the principal name may refer to different things for different clusters. Right now, on our side we’re planning to use the
client_idprovided in the initial SASL response for this.
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.
If we rely on a value from server step 1, we cannot skip client step 1 on subsequent calls.
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.
After thinking about this more, we'll forgo skipping client step 1 to be more conservative.
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.
The cache key should probably include some form of cluster identifier, since the principal name may refer to different things for different clusters. Right now, on our side we’re planning to use the client_id provided in the initial SASL response for this.
@addaleax , if we need to determine what cluster provided a cached value, is it easier to add a host address to a cache key instead tracking a client_id? It would be good to build a cache key based on initial client configuration and not on something dynamic. Also it will allow skipping step 1.
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.
Right, that’s a good point – I don’t mind using the host address as a key here if that’s easy enough. I’m not sure how common it would be to use the same client id for multiple clusters anyway.
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.
Updated
Co-authored-by: Anna Henningsen <github@addaleax.net>
source/auth/auth.rst Outdated
| Azure | ||
| _____ | ||
| | ||
| When the DEVICE_NAME mechanism property is set to "azure", the driver MUST |
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 think we need to clear cache (inside azure) too in case of failure?
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.
Done
Co-authored-by: Anna Henningsen <github@addaleax.net>
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.
Just re-affirming my LGTM
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.
LGTM
Co-authored-by: Durran Jordan <durran@gmail.com>
Please complete the following before merging: