ABP Framework version: v7.3.0
UI type: Angular
DB provider: EF Core
Tiered (MVC) or Auth Server Separated (Angular): yes
Exception message and stack trace:
Steps to reproduce the issue:"
- Client Application/Mobile app getting authorized and obtained token from External SSO Application
- API call initiated with the tenant and generated token
How to configure extra authentication to validate this external token in abp api application ? Here is the sample flow diagram.
37 Answer(s)
-
0
TestApp.HttpApi.Host
All APIs are in TestApp.HttpApi.Host, how to access API by external user? Strange thing is when I placed [Authorize(AuthenticationSchemes = "Bearer,jwt2")] in controller attribute api returning data and same thing when I placed in Service not working
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, Nothing is working out.
See I want to switch users based on token claim data emailid, before calling the APIs, I think now that's user switching is not happening, and thats why API authorization is failing.
When I am calling API, lifecycle is somethings like this
- https://localhost:44316/api/app/authors >>>
- AuthorsAppService constructor
- AuthorController constructor
- Task<PagedResultDto<AuthorDto>> GetListAsync(GetAuthorsInput input) in AuthorController
- TokenValidated(TokenValidatedContext context) in JWTToken validator
- Inside here I am trying to switch user but not working
- Response 401 UnAuthorized ** service (AuthorsAppService) layer method not calling at all
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
You can keep testing it and give feedback here.
Working fine, I mapped the role in admin to give permission to access the APIs.
One more question, Is that a good approach to check user availability from db on the token-validated event?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
You can add your code to:
app.Use(async (ctx, next) => { if (ctx.User.Identity?.IsAuthenticated != true) { var result = await ctx.AuthenticateAsync("jwt2"); if (result.Succeeded && result.Principal != null) { // add your logic ctx.User = result.Principal; // add your logic } } await next(); });Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
You can add your code to:
app.Use(async (ctx, next) => { if (ctx.User.Identity?.IsAuthenticated != true) { var result = await ctx.AuthenticateAsync("jwt2"); if (result.Succeeded && result.Principal != null) { // add your logic ctx.User = result.Principal; // add your logic } } await next(); });Production environment _currentTenant is null inside TokenValidated method, locally I am getting the value what could be the reason?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
