Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Route("assertionConsumerService")]
- public IActionResult AssertionConsumerService()
- {
- var binding = new Saml2PostBinding();
- var saml2AuthnResponse = new Saml2AuthnResponse(_saml2Config);
- var GenericHttpRequest = Request.ToGenericHttpRequest();
- binding.ReadSamlResponse(GenericHttpRequest, saml2AuthnResponse);
- if (saml2AuthnResponse.Status != Saml2StatusCodes.Success)
- {
- throw new AuthenticationException($"SAML Response status: {saml2AuthnResponse.Status}");
- }
- binding.Unbind(Request.ToGenericHttpRequest(), saml2AuthnResponse);
- // Get value from SAML-response
- var claims = ....;
- var value = claims.FindFirst(".....").Value;
- var token = _authorizationRepository.GetUserToken(value);
- // Set JWT-token cookie
- setTokenCookie(token);
- var relayStateQuery = binding.GetRelayStateQuery();
- var returnUrl = relayStateQuery.ContainsKey(relayStateReturnUrl)
- ? relayStateQuery[relayStateReturnUrl]
- : Url.Content("~/");
- return Redirect(returnUrl);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement