Reputation: 1340
SPA
and asp.net core 3.1
as backend for APIMicrosoft.AspNetCore.SpaServices.Extensions
nuget package so, among others, SPA files will be served from a folder (wwwroot/dist) when users access .net core[Authorize]
attributeAxios
and pass a bearer token to the back end APII want to implement OAuth2
/Oidc
authorization code with pkce using the identityserver4
hosted on another system.
A request for the landing page should forward the user to identityserver4 for the login/password prompt and redirect back after completing all the steps with a token.
Ideally I want the .net core handle all the oauth/oidc steps and don't want to deal with it using oidc-client
javascript client in SPA. Any suggestion on how I can accomplish this? Thanks
Upvotes: 0
Views: 2559
Reputation: 29291
Well there are two standard models here and you need to choose one of them, depending on factors you care most about:
OPTION 1: SPA SCENARIO
It is not standard for a resource server to handle the authentication flow for a client - instead a client should authenticate, then call the resource server.
OPTION 2: WEB BACK END SCENARIO
People most commonly choose this option when they want to keep tokens out of the browser's Javascript code:
ABOUT OIDC CLIENT
Personally I prefer option 1, which I think is closer to overall SPA Goals, such as cross domain hosting and use of content delivery networks. OIDC Client can actually lead to a fairly simple SPA security implementation, as in this Client Side Implementation of mine.
Upvotes: 0