I took this sample test SP code from ItFoxTec and perform a SingleLogout from this controller:
[Route("SingleLogout")]
public async Task<IActionResult> SingleLogout()
{
Saml2StatusCodes status;
var requestBinding = new Saml2PostBinding();
var logoutRequest = new Saml2LogoutRequest(config, User);
try
{
requestBinding.Unbind(Request.ToGenericHttpRequest(), logoutRequest);
status = Saml2StatusCodes.Success;
await logoutRequest.DeleteSession(HttpContext);
}
catch (Exception exc)
{
// log exception
Debug.WriteLine("SingleLogout error: " + exc);
status = Saml2StatusCodes.RequestDenied;
}
var responsebinding = new Saml2PostBinding();
responsebinding.RelayState = requestBinding.RelayState;
var saml2LogoutResponse = new Saml2LogoutResponse(config)
{
InResponseToAsString = logoutRequest.IdAsString,
Status = status
};
return responsebinding.Bind(saml2LogoutResponse).ToActionResult();
}
As I hit this endpoint, My IDP occured an error with message:
HTTP Form does not contain SAMLRequest
It seems the error occured on Saml2BindingException
Am I did a misconfiguration in IdP or SP? Thank you.
The SP initiate logout by calling the Logout method
.
The SingleLogout method
is called from the IdP to do single logout initiated by the IdP or another SP.