authentication fix

master
Tudor Stanciu 2020-12-20 12:33:16 +02:00
parent 5b2b5bbab9
commit 5b6da4d1d5
3 changed files with 10 additions and 12 deletions

View File

@ -16,8 +16,8 @@ namespace IdentityServer.Api.Controllers
_mediator = mediator;
}
[HttpPost("authenticate/{userName}/{password}")]
public async Task<IActionResult> AuthenticateUser([FromRoute] AuthenticateUser authenticateUser)
[HttpPost("authenticate")]
public async Task<IActionResult> AuthenticateUser([FromQuery] AuthenticateUser authenticateUser)
{
var result = await _mediator.Send(authenticateUser);
@ -27,8 +27,8 @@ namespace IdentityServer.Api.Controllers
return BadRequest();
}
[HttpPost("authorize/{token}")]
public async Task<IActionResult> AuthorizeToken([FromRoute] AuthorizeToken authorizeToken)
[HttpPost("authorize")]
public async Task<IActionResult> AuthorizeToken([FromQuery] AuthorizeToken authorizeToken)
{
var result = await _mediator.Send(authorizeToken);

View File

@ -6,11 +6,5 @@ namespace IdentityServer.Application.Commands
{
public string UserName { get; set; }
public string Password { get; set; }
public AuthenticateUser(string userName, string password)
{
UserName = userName;
Password = password;
}
}
}

View File

@ -27,8 +27,12 @@ namespace IdentityServer.Application.Stores
public TokenValidation ValidateToken(string token)
{
var lastIndexOfSeparator = token.LastIndexOf('-') + 1;
var userIdString = token.Substring(lastIndexOfSeparator, token.Length - lastIndexOfSeparator);
var lastIndexOfSeparator = token.LastIndexOf('-');
if (lastIndexOfSeparator == -1)
return InvalidToken;
var indexOfNextCharacterAfterSeparator = lastIndexOfSeparator + 1;
var userIdString = token.Substring(indexOfNextCharacterAfterSeparator, token.Length - indexOfNextCharacterAfterSeparator);
if (!int.TryParse(userIdString, out int userId))
return InvalidToken;