feature, preparar el endpoint para extraer el zip de archivos sin procesar, agregando el funcionamiento de refresh tokens
parent
b33303c85d
commit
c1f22a2199
@ -0,0 +1,5 @@ |
||||
namespace CORRESPONSALBackend.Contracts.Auth{ |
||||
public interface IAuthService{ |
||||
public Task<string> RefreshAgenteFacturacionToken(); |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
using System.IdentityModel.Tokens.Jwt; |
||||
using System.Security.Claims; |
||||
using System.Security.Cryptography; |
||||
using System.Text; |
||||
using CORRESPONSALBackend.Contracts.Auth; |
||||
using CORRESPONSALBackend.Contracts.Utils; |
||||
using CORRESPONSALBackend.DTO; |
||||
using CORRESPONSALBackend.Models.Utils; |
||||
using Microsoft.IdentityModel.Tokens; |
||||
|
||||
namespace CORRESPONSALBackend.Services.Auth{ |
||||
public class AuthService : IAuthService |
||||
{ |
||||
private readonly IFileManagerRepository _Repo; |
||||
|
||||
private readonly IFilePaths4ProcessRepository _RepoRelativePath; |
||||
private readonly IConfiguration _config; |
||||
private readonly string RootPathCorresponsales; |
||||
public AuthService(IFileManagerRepository Repo, IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config){ |
||||
_Repo = Repo; |
||||
_RepoRelativePath = RepoRelativePath; |
||||
_config = config; |
||||
RootPathCorresponsales = _config.GetValue<string>("AllFiles"); |
||||
} |
||||
public async Task<string> RefreshAgenteFacturacionToken(){ |
||||
var claims = new List<Claim> |
||||
{ |
||||
new Claim(JwtRegisteredClaimNames.Sub, _config["Jwt:Subject"]), |
||||
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), |
||||
new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString()) |
||||
}; |
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); |
||||
var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); |
||||
var token = new JwtSecurityToken( |
||||
_config["Jwt:Issuer"], |
||||
_config["Jwt:Audience"], |
||||
claims, |
||||
expires: DateTime.UtcNow.AddHours(25), |
||||
//expires: DateTime.UtcNow.AddMinutes(5), |
||||
signingCredentials: signIn); |
||||
|
||||
var _token = new JwtSecurityTokenHandler().WriteToken(token); |
||||
|
||||
return _token; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue