Skip to content
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

Create/update user account after login with external authentication server #12203

Closed
hikalkan opened this issue Apr 7, 2022 · 0 comments · Fixed by #12692
Closed

Create/update user account after login with external authentication server #12203

hikalkan opened this issue Apr 7, 2022 · 0 comments · Fixed by #12692

Comments

@hikalkan
Copy link
Member

hikalkan commented Apr 7, 2022

Consider this scenario: Our client application (can be Angular, Blazor WASM or tiered MVC UI) uses OpenIdConnect flow to login to the application, but not uses our own backend. For example, it uses a Keycloak server. In this case, the user is redirected to Keycloak, enters username and password, and redirected back to the client application. Our backend has no knowledge on this process, and there is a possibility that the user's account is not available in our local database (in the Identity module's Users table). In this case, we would like to create this user as an external user in our local database. In this way, we can see this user in the Users page and set necessary permissions and make other user-related operations in our system. The user will continue to use the external auth server to login, but we will have her profile information (like Id, Username, Email, Name, Surname) in our local database.

For this purpose;

  • Add REST API endpoint (and corresponding application service method) to the Identity module to create/update current user from external login provider. This endpoint will get the external provider name to be more generic (LDAP, OpenIdConnect, etc.). The endpoint should be authorized ([Authorize]) and work only with the current user for security (doesn't get user id as parameter!). This endpoint will query the external auth server to obtain user information, create or update the user in the local database.
  • The REST API will be called by the client application, just after the authentication flow (typically OpenId Connect or resource owner password flow) completed, but before the first request is done. For MVC UI, as I can see, this can be done just in the options.Events.OnUserInformationReceived option of the AddAbpOpenIdConnect method. But, we should check if there is a better way. For other UI options, we should find a proper point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment