0

In my ASP.NET MVC 5 application, we already have users defined in AspNetUsers. Currently, once the user is logged, the ASP.NET MVC 5 application is using the user identity/claims to do a bunch of things inside the application. Users cannot register themselves. We must manually create the users before they can login. This is a restricted website.

Now I need to add Auth0 authentication but still need to circle back to the data defined for the user in the AspNetUsers table to retrieve additional information stored in it. When the user visits my web application, he will be pre-authenticated by Auth0 because my web application is part of a greater process where I am only one of the cogs.

Here is what I want to do:

  • When a user reaches my website with an authenticated cookie from Auth0, I must associate this Auth0 user with the same user in the AspNetUsers table using the email found in the Auth0 cookie. There are additional data located in my local AspNetUsers table that must be added to the claims of the Auth0 cookie.
  • If the user is not having an authenticated Auth0 cookie, he must be redirected to the normal login page of my web application that will use the local database to authenticate him. He should not be redirected to Auth0 for authentication.

In summary, if the user has a valid Auth0 cookie, I must match him with an existing user in AspNetUsers table in my local database to load up additional data, else he must be redirected to the default login page of my web application.

I already have the credentials (Domain, ClientId, ClientSecret, etc.) needed to interact with Auth0.

Any insight to achieve this would be greatly appreciated.

I tried the sample code provided by Auth0 without success. The callback I provide Auth0 is never called and they have no sample code that shows how to do this.

I searched the web to find an example that would use Auth0 and a local database to store user-specific data without success.

I also posted a scaled-down version of this message to Auth0 community forum but I have yet to receive any answer (over 1 month ago)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0