-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
✨ feat: Add custom fields & role assignment to OpenID strategy #5612
base: main
Are you sure you want to change the base?
✨ feat: Add custom fields & role assignment to OpenID strategy #5612
Conversation
Hi @rubentalstra. I closed my pull request because you are right that we both want the same think. I went through the documentation as well and there you say that aws_cognito is available but I see only Microsoft implementation. Is there something I'm missing? |
Hi @geodanchev. it's all good. I can't test aws_cognito so I removed it from the code. but if there is someone who could test it then that would be great. |
What about the documentation pull request |
still need to remove it 😉 |
|
||
const token = requiredRoleTokenKind === 'access' ? tokenset.access_token : tokenset.id_token; | ||
const decodedToken = safeDecode(token); | ||
const tokenBasedRoles = extractRolesFromToken(decodedToken, requiredRoleParameterPath); |
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 variable tokenBasedRoles can be set only once before the if (process.env.OPENID_CUSTOM_DATA) block if you refactor the code slightly. Currently, tokenBasedRoles is being set twice, once inside the if block and once outside of it. This redundancy can be avoided.
const token = requiredRoleTokenKind === 'access' ? tokenset.access_token : tokenset.id_token; | ||
const decodedToken = safeDecode(token); | ||
const tokenBasedRoles = extractRolesFromToken(decodedToken, requiredRoleParameterPath); | ||
const isAdmin = tokenBasedRoles.includes(adminRole); |
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.
Can we have multiple adminRoles that at the end will make the user admin? Or it is not a good idea ?
Summary
Closes: #4670 #4362 #4354
✨ feat: This Pull Request introduces comprehensive OpenID Connect (OIDC) support with enhanced user data handling and role assignment. Key changes include:
.env.example
with new environment variables for OpenID integration.userSchema.js
to support additional fields for storing custom OpenID data.openidDataMapper.js
with provider-specific mappers for Microsoft, AWS Cognito, and Keycloak to effectively fetch and map custom OpenID data.openidStrategy.js
to:package.json
andpackage-lock.json
with the necessary libraries for full OpenID functionality.types.ts
to support custom OpenID data mappings.Change Type
Testing
Checklist