Van normális bejelenkezési ablak
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
@@ -8,11 +9,12 @@ namespace WorkFlowCheck.Web.Middleware
|
||||
public class JwtMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private const string _secretKey = "super_secret_key";
|
||||
public readonly IConfiguration _configuration;
|
||||
|
||||
public JwtMiddleware(RequestDelegate next)
|
||||
public JwtMiddleware(RequestDelegate next,IConfiguration configuration)
|
||||
{
|
||||
_next = next;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
@@ -26,12 +28,14 @@ namespace WorkFlowCheck.Web.Middleware
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
|
||||
private bool ValidateToken(string token, out Claim[] claims)
|
||||
{
|
||||
var jwtSettings = _configuration.GetSection("Jwt");
|
||||
var secretKey = jwtSettings["SecretKey"];
|
||||
|
||||
claims = null;
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
var key = Encoding.UTF8.GetBytes(_secretKey);
|
||||
var key = Encoding.UTF8.GetBytes(secretKey);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -52,5 +56,6 @@ namespace WorkFlowCheck.Web.Middleware
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,5 +94,6 @@ namespace WorkFlowCheck.Web.Middleware
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user