I created an ASP.NET Core Angular application using the latest template on yeoman. I am running IdentityServer4. In IdentityServer4 I created a client for the MVC application.
// OpenID Connect implicit flow client (MVC)
new Client
{
ClientId = "mvc",
ClientName = "MVC Client",
AllowedGrantTypes = GrantTypes.Implicit,
RedirectUris = { "http://localhost:5002/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile
}
}
I used the following documentation to help set this up: http://docs.identityserver.io/en/release/quickstarts/3_interactive_login.html
I added an [Authorize] attribute to the Home controller and everything seems to be working. The user is unable to access the Angular code since the Home Controller instantly redirects to IdentityServer4 for login.
I am a bit confused at what the Hybrid flow is in regards to what I have setup above. http://docs.identityserver.io/en/release/quickstarts/5_hybrid_and_api_access.html
Since I am going to be using the ASP.NET Core Angular template is it really that simple? Just add the MVC app as a client and add an Authorize attribute to the top of the HomeController? I guess why go through all of the hassle in setting up everything in Angular with oidc-client if I can take advantage of ASP.NET Core.
I believe my setup will fail as soon as User Roles gets involved (what user can access what). I would rely on IdentityServer4 to tell me these roles, but I would need access to them in Angular. Maybe this is the answer to my question... Is this what the Hybrid workflow is for?
Here is how my app is structured:
MyApp.Web
MyApp.Api (Api that Angular will call, additionally has an IdentityController for IdentityServer)
MyApp.Auth (Identity Server)
If anyone is completely confused by my question, it would be very beneficial if I could get a recommendation on a good way to setup Authentication/Authorization using IdentityServer4 and an ASP.NET Core Angular app. Taking advantage of the .NET Core side of things so I do not have to do all of the auth purely on the client.
/apiurls and add a login form in angular once the app is loaded, which signs the user in and obtains an bearer token (jwt or opaque token, up to you). Or if you want stay the way you are, make a regular login and expose a token endpoint for refreshing jwt/bearer access tokens - Tseng