How to Support Multiple Signed in Users in ASP.NET Core?

Viewed 28

I am building a webapp that uses OpenIdConnect to have users sign in, sample can be found here. With MSAL.js, specifically the react implementation, a client can tell what accounts are signed in. This allows you to build a switch account menu, as seen below.

import { useMsal } from "@azure/msal-react";

const { instance, accounts } = useMsal();

accounts menu

I am trying to recreate the same menu, but using server side authentication instead of client side. I can sign in with the example above, and can keep multiple accounts signed in by using:

builder.Services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
    options.Prompt = "select_account";
});

However, I want to get a list of signed in users in the controller. HttpContext.User only holds one user, and its identity/claims. Does ASP.NET Core expose a way to find out what users are signed in, or would I have to handle that manually?

0 Answers
Related