0

I have a test application developed for my collage project. with below table structure

tbl_UserMaster (userid int, username string, password string)

where I made users to authenticate with username and password. And use application features.

Now, Our teacher assigned us task to authenticate using

MicrosoftAccount and Facebook

After much search and refer to various sources I am able to integrate both the login using asp.net core's AddAuthentication(options)

Now, we are given a new task to create a page that will associate SSO logins and database users. So, it would be upto user to login with SSO or Username and password.

And here I got stuck on how to associate both of them. I have created table as below

tbl_UserMasterSSO (ssoID int, ProviderName string, NameIdentifier string, userid int(fk_tbl_UserMaster))

But, I don't have idea about how to, when user is already login with cookies then how to make them login with external provider and get NameIdentifier and associate with tbl_UserMaster's userid.

Requesting Experts to suggest an article or solution from where I can integrate the sample code to finish the task assigned.

Sadiqabbas Hirani
  • 357
  • 1
  • 5
  • 13
  • Well, in that case you have to use [identity extesion](https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Extensions.Core/src/IdentityServiceCollectionExtensions.cs). Please have a look on [this thread as well](https://stackoverflow.com/questions/47433269/multiple-identities-in-asp-net-core-2-0). Hope that would guide you accordingly. But note that you cannot have multipole identidy provider at the same time. It will lead you [authentication exception](https://stackoverflow.com/questions/70417909/application-without-identity-but-added-later-now-secondary-authentication-is-not) – Md Farid Uddin Kiron Feb 08 '22 at 09:43
  • Is there any progress you were able to made on the context? – Md Farid Uddin Kiron Feb 09 '22 at 09:46
  • no sir. Actually I need to implement solution like this stack over flow type website. already logged in used can attach their google/Github account with their existing username/password normal account. – Sadiqabbas Hirani Feb 09 '22 at 14:11
  • what i mean to say is https://stackoverflow.com/users/login-add – Sadiqabbas Hirani Feb 09 '22 at 14:34
  • In that case did you checked `github auth` steps of implementations? Please have a look [github official docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github) same goes for `google auth` as well. Finally these option should be then displayed as your login option beside `user` and `password` base authentication. – Md Farid Uddin Kiron Feb 11 '22 at 01:28

0 Answers0