コード例 #1
0
        public async Task <IActionResult> SingleLogoutRequestAsync(string partyId, SingleLogoutSequenceData sequenceData)
        {
            logger.ScopeTrace("Down, SAML Single Logout request.");
            logger.SetScopeProperty("downPartyId", partyId);
            var party = await tenantRepository.GetAsync <SamlDownParty>(partyId);

            if (!ValidatePartySingleLogoutSupport(party))
            {
                return(await singleLogoutDownLogic.HandleSingleLogoutAsync(sequenceData));
            }

            var claims = await claimsDownLogic.FromJwtToSamlClaimsAsync(sequenceData.Claims.ToClaimList());

            switch (party.LogoutBinding.RequestBinding)
            {
            case SamlBindingTypes.Redirect:
                return(await SingleLogoutRequestAsync(party, new Saml2RedirectBinding(), claims));

            case SamlBindingTypes.Post:
                return(await SingleLogoutRequestAsync(party, new Saml2PostBinding(), claims));

            default:
                throw new NotSupportedException($"SAML binding '{party.LogoutBinding.RequestBinding}' not supported.");
            }
        }
コード例 #2
0
ファイル: SamlAuthnDownLogic.cs プロジェクト: lulzzz/FoxIDs
        public async Task <IActionResult> AuthnResponseAsync(string partyId, Saml2StatusCodes status = Saml2StatusCodes.Success, IEnumerable <Claim> jwtClaims = null)
        {
            logger.ScopeTrace($"Down, SAML Authn response{(status != Saml2StatusCodes.Success ? " error" : string.Empty )}, Status code '{status}'.");
            logger.SetScopeProperty("downPartyId", partyId);

            var party = await tenantRepository.GetAsync <SamlDownParty>(partyId);

            var samlConfig   = saml2ConfigurationLogic.GetSamlDownConfig(party, true);
            var sequenceData = await sequenceLogic.GetSequenceDataAsync <SamlDownSequenceData>(false);

            var claims = jwtClaims != null ? await claimsDownLogic.FromJwtToSamlClaimsAsync(jwtClaims) : null;

            return(await AuthnResponseAsync(party, samlConfig, sequenceData.Id, sequenceData.RelayState, sequenceData.AcsResponseUrl, status, claims));
        }