-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
OIDC name for gitlab and authelia #746
OIDC name for gitlab and authelia #746
Conversation
app/server/lib/OIDCConfig.ts
Outdated
// display_name is provided by Authelia for example. | ||
userInfo.display_name || | ||
// name is provided by Gitlab for example. | ||
userInfo.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.
Would it be important to fall back to a string (and not, say, undefined
)? If none of these options are available, one more reasonable fallback would be email.split("@", 1)[0]
.
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.
Isn't it already handled? If I don't provide any name, the left part of the email seem to be used. The magic seems to be operated here:
grist-core/app/gen-server/lib/HomeDBManager.ts
Lines 690 to 696 in 37dc1f8
if (!user.name) { | |
// Set the user's name if our provider knows it. Otherwise use their username | |
// from email, for lack of something better. If we don't have a profile at this | |
// time, then leave the name blank in the hopes of learning it when the user logs in. | |
user.name = (profile && (profile.name || email.split('@')[0])) || ''; | |
needUpdate = true; | |
} |
b432af3
to
2f080d1
Compare
@dsagal Thanks for your review! I answered to your comments :) I also changed a bit of strategy, I allow customizing the administrator the user properties to read in |
app/server/lib/OIDCConfig.ts
Outdated
envVar: 'GRIST_OIDC_SP_PROFILE_NAME_ATTR', | ||
}); | ||
|
||
this._emailPropertyKey = section.flag('emailPropertyKey').readString({ |
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.
With defaultValue
, you should be able to change to requireString
, and the result would have type string
(so you wouldn't need the ?
in declaration, or !
in usage).
app/server/lib/OIDCConfig.ts
Outdated
|
||
private _extractName(userInfo: UserinfoResponse): string|undefined { | ||
if (this._namePropertyKey) { | ||
return userInfo[ this._namePropertyKey ] as string|undefined; |
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.
Same here: String(userInfo[this._namePropertyKey])
would be safer (in case the actual value happens to be of some other type).
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 rather propose userInfo[ this._namePropertyKey as any ]?.toString()
so if the value is undefined/null, it is correctly handled here:
grist-core/app/gen-server/lib/HomeDBManager.ts
Lines 690 to 696 in 37dc1f8
if (!user.name) { | |
// Set the user's name if our provider knows it. Otherwise use their username | |
// from email, for lack of something better. If we don't have a profile at this | |
// time, then leave the name blank in the hopes of learning it when the user logs in. | |
user.name = (profile && (profile.name || email.split('@')[0])) || ''; | |
needUpdate = true; | |
} |
Thanks again for your review @dsagal, I have taken them into account! |
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.
Thanks! One more request please, the rest looks good.
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.
Thank you!
@fflorent , there seems to be a merge conflict because of your other change to OIDC. Could you rebase? |
Some Idp like Gitlab do not provide end_session_endpoint In such case, we just redirect to the logout page.
49b4908
to
f224d9f
Compare
@dsagal @georgegevoian Done :) |
Context
given_name
orfamily_name
attributes in userinfoend_session_endpoint
, which led to an ugly error when disconnectingSolutions
display_name
orname
as alternative attributes for thegiven_name
+family_name
pair;