fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.

Home Page:https://fullstackhero.net/dotnet-webapi-boilerplate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Random text being shown in email value in Token Authentication, instead of "string" as default value

Sarmadjavediqbal opened this issue · comments

Describe the bug
A clear and concise description of what the bug is.

Expected behavior
Following should be displayed:
{
"email": "string",
"password": "string"
}
image

Instead it is displaying as follows:
{
"email": "hy3%5s4uFhBD<yJfxBfsTT@BBEM;coO2irsX[}{AZ -qKKt(e:x",
"password": "string"
}

Screenshots
image

Maybe this error is occurring on my end. but I can't figure out how to solve this issue.

Hi again. could someone tell me what could be wrong here??? I am still trying to solve this error but can't figure out what is causing this random string to occur. Kindly reply as soon as possible.

commented

Check : TokensController-> GetIpAddress() -> as master

Check : TokensController-> GetIpAddress() -> as master

Following is the TokensController. Still this bug is not fixed.

public sealed class TokensController : VersionedNeutralApiController
{
private readonly ITokenService _tokenService;

public TokensController(ITokenService tokenService) => _tokenService = tokenService;

[HttpPost]
[AllowAnonymous]
[TenantIdHeader]
[OpenApiOperation("Request an access token using credentials.", "")]
public Task<TokenResponse> GetTokenAsync(TokenRequest request, CancellationToken cancellationToken)
{
    return _tokenService.GetTokenAsync(request, GetIpAddress(), cancellationToken);
}

[HttpPost("refresh")]
[AllowAnonymous]
[TenantIdHeader]
[OpenApiOperation("Request an access token using a refresh token.", "")]
[ApiConventionMethod(typeof(FSHApiConventions), nameof(FSHApiConventions.Search))]
public Task<TokenResponse> RefreshAsync(RefreshTokenRequest request)
{
    return _tokenService.RefreshTokenAsync(request, GetIpAddress());
}

private string? GetIpAddress() =>
    Request.Headers.ContainsKey("X-Forwarded-For")
        ? Request.Headers["X-Forwarded-For"].ToString() ?? "N/A"
        : HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString() ?? "N/A";

}

The random string changes on pressing the reset button in token authentication.

image

commented

private string GetIpAddress() =>
Request.Headers.ContainsKey("X-Forwarded-For")
? Request.Headers["X-Forwarded-For"]
: HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString() ?? "N/A";

private string GetIpAddress() => Request.Headers.ContainsKey("X-Forwarded-For") ? Request.Headers["X-Forwarded-For"] : HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString() ?? "N/A";

Still not fixed. Is there any other way to fix this bug??? Is it possible that any nuget package is not compatible with this ???

Fixed it some how. I uninstalled (ZymLabs.NSwag.FluentValidation.AspNetCore) nuget package and installed a previous version of this package. It did not work but then I reinstalled the latest version (0.6.2) of (ZymLabs.NSwag.FluentValidation.AspNetCore) and the bug was gone. Thanks anyway.