123456789101112131415161718192021222324252627282930 |
- using iTextSharp.text.log;
- using Microsoft.AspNetCore.Authentication;
- using Microsoft.AspNetCore.Authentication.JwtBearer;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- namespace SMP.Common.Auth
- {
- public class BasicAuthenticationMiddleware
- {
- private readonly RequestDelegate _next;
- public BasicAuthenticationMiddleware(RequestDelegate next)
- {
- _next = next;
- }
- public async Task Invoke(HttpContext httpContext, IAuthenticationService authenticationService)
- {
- var authenticated = await authenticationService.AuthenticateAsync(httpContext, JwtBearerDefaults.AuthenticationScheme);
- //authenticated.Principal.Claims.
- //_logger.LogInformation("Access Status:" + authenticated.Succeeded);
- if (!authenticated.Succeeded)
- {
- await authenticationService.ForbidAsync(httpContext, JwtBearerDefaults.AuthenticationScheme, new AuthenticationProperties { });
- return;
- }
- await _next(httpContext);
- }
- }
- }
|