Identiyserver4 how to handle 2 users in the same browser? - c#

Scenario:
Identityserver4 + aspnet core identity and one aspnet core mvc client
Questions:
How to manage 2 users logging into the same browser at the same time? Do I have to make sure that only one user is logged in at a time or can I use several users at the same time?

you can use Facebook login scenario.
you can save usernames into a cookie and show them a list of logged in users. after clicking on it a password will appear.

Related

ASPNET MVC authentication for multiple domains websites

I have two websites:
The first one is an ASP.NET MVC website on .Net framework 4.7.2
The second one is an ASP.NET MVC Core Website on .Net Core 6
Important to note, these 2 websites are on different domains.
Actually, you can sign in on the first one by email, a Google account or a Facebook account.
I need to be able to sign in the second one (these 2 sites share the same client database).
Of course, if I am logged on the first one, I need to be logged on the second one, and vice versa.
I am looking for a free and "simple" solution.
I don't want to use ASP.NET Identity.
I suppose that I need a 3rd website which will manage the login/logout?
I found this interesting article https://www.codeproject.com/Articles/106439/Single-Sign-On-SSO-for-cross-domain-ASP-NET-applic but it's outdated : it uses asp.net webforms.
Any advice?
You can use Token Authorization from one application User being logged in can click on a redirect button to another application
from clicking on link the first application will make a JWT token or any encrypted user values using Symmertic Algo. Then then route on Another (Second) Application
will Verify the JWT token or any encrypted user values to login In the User for Antoher Application and set the desired session in that application. you can also maintain the logs for logining in user in Database.

How to use Windows authentication as an alternative to password login? ASP.NET Core

I want to implement the following functionality: I have a website I'm creating in ASP.NET Core 6 and it will be both accessible from inside and outside of the server's network.
When accessed from the outside, I only want to enable password login. But when accessed from the intranet, I want to have a button on the login page that says "Log in with Active Directory". I have a Login table in the database that has a column that has Active Directory credentials in it. So when the user presses this button, I want to lookup in the database whether the AD user is in the database, and if yes, I want to store cookies detailing which user has logged in, and from that point on I only want to use CookieAuthentication.
I have been researching this topic for only God knows how long, and haven't been able to find what I need. Negotiate auth is not good for me (by itself) because I want to treat all users from the login onwards the same, and because a User can be only authenticated with AD if the credentials are in my Login table.

I authenticated a user from IdS4, how do I use this info in my MVC client?

I've got a user authenticated via IdS4, along with a few claims and a role, now I'm lost about what to with it. The general flow for the user is: Go to my site, log in redirects to IdS4 server. They enter their username/password, and redirect back to my site, along with cookies set.
I've not seen much beyond authentication in the tutorials I've found.
Should/How do I persist the user? Should I set up Identity on my MVC site? I'm just looking for a general idea, I think I can figure out the specifics, at this point my general Googling hasn't turned up much.
Thank you.
You can add ASP.Net Identity to manage users in your client MVC application , or directly use EF Core to store users in database without ASP.Net Identity .
But the problem is why you want to perisit or manage users in your client application ? You are using Identity Server to do authentication and IDS will connect the database/configration file to validate user and fill user claims , if you want to manage users/roles , you can add apis(CURD operations to user database) as protected resource , and your client app acquire access token to access that apis to perform user management . So that user management operations are share to clients which have permission to get api's access token . But if you want to manage specific users which only available to one client , you can mix asp.net identity and IDS4 authentication in client app .

Multiple MVC5 websites using a single website for authentication (ASP.NET Identity v2)

Looking for some guidance on using ASP.NET Identity to provide a single location for logon / authentication across a number of sites (that are all subdomains of a common domain).
The current setup is that I have 2 websites:
site1.example.com
site2.example.com
They present different views of the system to users, and they share the same backend database, and therefore the same ASP.NET Identity tables. Logging on via either site logs on via the same db.
What I want to do is unify the logon process via a third site:
auth.example.com
The idea being that the user visits site1.example.com, clicks a login button, is redirected to auth.example.com, performs the log in, and is redirected back to site1.example.com.
If they then navigated to site2.example.com, it would be nice if they were seen to be authenticated already.
What you seem to be looking for is single sign on. https://github.com/thinktecture/Thinktecture.IdentityServer.v3 Is the one that I like and it is open source. I think is supports ASP.NET Identity as a user service as well.

2 login areas managed by forms authentication

I am developing an asp.net mvc4 application. It has 2 secure areas which users can access. For each area, a different role is required for the user to be in. Its not possible for a user to be in both roles.
The site has 2 separate login pages. I am working with forms authentication to manage the user being logged in and what role they are in.
As the user has 2 seperate login pages, I need the following functionality:
If the users attempts to access area A of the site and not in the necessary, they should be redirect to login page A.
If the users attempts to access area B of the site and not in the necessary, they should be redirect to login page B.
Out of the box, I am not sure if this is possible with forms auth. Could someone explain to me if it is and how it might be achieved?

Categories