-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃泜 fix: OIDC Username Array Edge Case #2394
Conversation
`username` is generally based on email, rather than `given_name`. The challenge with `given_name` is that it can be a multi-value array (ex: "Nick, Fullname"), which completely breaks the system with: ``` LibreChat | ValidationError: User validation failed: username: Cast to string failed for value "[ 'Nickname', 'Firstname' ]" (type Array) at path "username" LibreChat | at Document.invalidate (/app/node_modules/mongoose/lib/document.js:3200:32) LibreChat | at model.$set (/app/node_modules/mongoose/lib/document.js:1459:12) LibreChat | at model.set [as username] (/app/node_modules/mongoose/lib/helpers/document/compile.js:205:19) LibreChat | at OpenIDConnectStrategy._verify (/app/api/strategies/openidStrategy.js:127:27) LibreChat | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) ```
email can be undefined for some using OIDC. I made a change so that this way, |
Also, I think it would be better to handle the edge case of an array now that I think about. Joining the array to a string. |
@danny-avila Hi - I think it may make sense to flip these around: from:
to:
Usernames generally are expected to be "continuous" and looking at a couple of directories of 10K+ users, "given_name" seems to container things like |
Oh nice! (just saw this comment). Perfect, thanks! If you can, please look at the |
* Patch for OpenID username `username` is generally based on email, rather than `given_name`. The challenge with `given_name` is that it can be a multi-value array (ex: "Nick, Fullname"), which completely breaks the system with: ``` LibreChat | ValidationError: User validation failed: username: Cast to string failed for value "[ 'Nickname', 'Firstname' ]" (type Array) at path "username" LibreChat | at Document.invalidate (/app/node_modules/mongoose/lib/document.js:3200:32) LibreChat | at model.$set (/app/node_modules/mongoose/lib/document.js:1459:12) LibreChat | at model.set [as username] (/app/node_modules/mongoose/lib/helpers/document/compile.js:205:19) LibreChat | at OpenIDConnectStrategy._verify (/app/api/strategies/openidStrategy.js:127:27) LibreChat | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) ``` * Update openidStrategy.js * refactor(openidStrategy): add helper function for stringy username --------- Co-authored-by: Danny Avila <danny@librechat.ai>
Pull Request Template
Summary
username
is generally based on email, rather thangiven_name
. The challenge withgiven_name
is that it can be a multi-value array (ex: "Nick, Fullname"), which completely breaks the system with:Change Type
Testing
Lots of testing in dev and production. See dev channel in Discord for more info.
Test Configuration:
Checklist
Please delete any irrelevant options.
My code adheres to this project's style guidelines
I have performed a self-review of my own code
My changes do not introduce new warnings
Local unit tests pass with my changes