Skip to content

Commit

Permalink
Add another section for RadiusRouter.HandleRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-timofeev committed Jun 27, 2024
1 parent d6fdc2d commit 29d7faf
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions MultiFactor.Radius.Adapter/Server/RadiusRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public async Task HandleRequest(PendingRequest request)
if (request.AuthenticationState.SecondFactor == AuthenticationCode.Awaiting)
{
var code = await ProcessSecondAuthenticationFactor(request);

if (code == PacketCode.AccessChallenge)
{
request.ResponseCode = request.AuthenticationState.GetResultPacketCode();
Expand All @@ -223,7 +224,17 @@ public async Task HandleRequest(PendingRequest request)
return;
}

if (code != PacketCode.AccessAccept)
if (code == PacketCode.AccessAccept)
{
_logger.Information("Second factor accepted for user '{user:l}' from {host:l}:{port}",
request.UserName, request.RemoteEndpoint.Address, request.RemoteEndpoint.Port);
request.AuthenticationState.SetSecondFactor(AuthenticationCode.Accept);
request.ResponseCode = request.AuthenticationState.GetResultPacketCode();
CreateAndSendRadiusResponse(request);
return;
}

if (code == PacketCode.AccessReject)
{
_logger.Information("Second factor rejected for user '{user:l}' from {host:l}:{port}",
request.UserName, request.RemoteEndpoint.Address, request.RemoteEndpoint.Port);
Expand All @@ -232,11 +243,6 @@ public async Task HandleRequest(PendingRequest request)
CreateAndSendRadiusResponse(request);
return;
}

request.AuthenticationState.SetSecondFactor(AuthenticationCode.Accept);
request.ResponseCode = request.AuthenticationState.GetResultPacketCode();
CreateAndSendRadiusResponse(request);
return;
}

request.ResponseCode = request.AuthenticationState.GetResultPacketCode();
Expand Down

0 comments on commit 29d7faf

Please sign in to comment.