Esempio n. 1
0
 public JwtService(
     IOptions <JwtConfig> jwtConfig,
     IJwtSessionService jwtSessionService,
     ILogger <IJwtService> logger
     )
 {
     this.JwtConfig         = jwtConfig.Value;
     this.JwtSessionService = jwtSessionService;
     this.Logger            = logger;
 }
Esempio n. 2
0
        public async Task InvokeAsync(HttpContext context, CurrentLoginInfo currentLoginInfo, IJwtSessionService jwtSessionService)
        {
            var session = currentLoginInfo.Session ?? string.Empty;

            if (!string.IsNullOrWhiteSpace(session) && !jwtSessionService.ContainsKey(session))
            {
                context.Response.Clear();
                context.Response.StatusCode = StatusCodes.Status401Unauthorized;
            }
            else
            {
                await Next(context);
            }
        }