Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Return invalid_grant when redirect_uri is invalid on token endpoint #4095

Merged
merged 1 commit into from Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -267,7 +267,7 @@ private async Task<TokenRequestValidationResult> ValidateAuthorizationCodeReques
if (redirectUri.Equals(_validatedRequest.AuthorizationCode.RedirectUri, StringComparison.Ordinal) == false)
{
LogError("Invalid redirect_uri", new { redirectUri, expectedRedirectUri = _validatedRequest.AuthorizationCode.RedirectUri });
return Invalid(OidcConstants.TokenErrors.UnauthorizedClient);
return Invalid(OidcConstants.TokenErrors.InvalidGrant);
}

/////////////////////////////////////////////
Expand Down Expand Up @@ -511,7 +511,7 @@ private async Task<TokenRequestValidationResult> ValidateRefreshTokenRequestAsyn
private async Task<TokenRequestValidationResult> ValidateDeviceCodeRequestAsync(NameValueCollection parameters)
{
_logger.LogDebug("Start validation of device code request");

/////////////////////////////////////////////
// check if client is authorized for grant type
/////////////////////////////////////////////
Expand Down Expand Up @@ -540,11 +540,11 @@ private async Task<TokenRequestValidationResult> ValidateDeviceCodeRequestAsync(
/////////////////////////////////////////////
// validate device code
/////////////////////////////////////////////
var deviceCodeContext = new DeviceCodeValidationContext {DeviceCode = deviceCode, Request = _validatedRequest};
var deviceCodeContext = new DeviceCodeValidationContext { DeviceCode = deviceCode, Request = _validatedRequest };
await _deviceCodeValidator.ValidateAsync(deviceCodeContext);

if (deviceCodeContext.Result.IsError) return deviceCodeContext.Result;

_logger.LogDebug("Validation of authorization code token request success");

return Valid();
Expand Down Expand Up @@ -789,7 +789,7 @@ private void LogWithRequestDetails(LogLevel logLevel, string message = null, obj
{
_logger.Log(logLevel, message + "{@values}, details: {@details}", values, details);
}

}
catch (Exception ex)
{
Expand Down
Expand Up @@ -288,7 +288,7 @@ public async Task Different_RedirectUri_Between_Authorize_And_Token_Request()
var result = await validator.ValidateRequestAsync(parameters, client.ToValidationResult());

result.IsError.Should().BeTrue();
result.Error.Should().Be(OidcConstants.TokenErrors.UnauthorizedClient);
result.Error.Should().Be(OidcConstants.TokenErrors.InvalidGrant);
}

[Fact]
Expand Down