diff --git a/EnvelopeGenerator.Application/Contracts/IJWTService.cs b/EnvelopeGenerator.Application/Contracts/IJWTService.cs deleted file mode 100644 index 138b8643..00000000 --- a/EnvelopeGenerator.Application/Contracts/IJWTService.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.IdentityModel.Tokens; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using System.Security.Cryptography; - -namespace EnvelopeGenerator.Application.Contracts -{ - public interface IJWTService - { - public static SymmetricSecurityKey GenerateSecurityKey(int byteSize = 32) - { - using var rng = RandomNumberGenerator.Create(); - var randomBytes = new byte[byteSize]; - rng.GetBytes(randomBytes); - var securityKey = new SymmetricSecurityKey(randomBytes); - - return securityKey; - } - - string GenerateToken(TClaimValue claimValue); - - JwtSecurityToken? ReadSecurityToken(string token); - } -} \ No newline at end of file diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestAuthController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestAuthController.cs deleted file mode 100644 index 07f838cf..00000000 --- a/EnvelopeGenerator.Web/Controllers/Test/TestAuthController.cs +++ /dev/null @@ -1,42 +0,0 @@ -using EnvelopeGenerator.Application.Contracts; -using EnvelopeGenerator.Application.Services; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System.Security.Claims; - -namespace EnvelopeGenerator.Web.Controllers.Test -{ - [ApiController] - [Route("api/test/[controller]")] - public class TestAuthController : ControllerBase - { - private readonly IJWTService _authService; - - public TestAuthController(IJWTService authService) - { - _authService = authService; - } - - [HttpPost] - public IActionResult ProvideToken([FromQuery] string value) - { - var token = _authService.GenerateToken(value); - return Ok(token); - } - - [HttpGet] - public IActionResult GetSecurityToken([FromQuery] string token) - { - var sToken = _authService.ReadSecurityToken(token); - return Ok(sToken); - } - - [HttpGet("Username")] - [Authorize] - public IActionResult Getname() - { - var username = User.Claims?.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value; - return Ok(username); - } - } -} \ No newline at end of file