Exemplo n.º 1
0
        public async Task <IActionResult> EndSessionRequestRedirectAsync(UpPartyLink partyLink, LogoutRequest logoutRequest)
        {
            logger.ScopeTrace("Up, OIDC End session request redirect.");
            var partyId = await UpParty.IdFormatAsync(RouteBinding, partyLink.Name);

            logger.SetScopeProperty("upPartyId", partyId);

            await logoutRequest.ValidateObjectAsync();

            await sequenceLogic.SaveSequenceDataAsync(new OidcUpSequenceData
            {
                DownPartyLink        = logoutRequest.DownPartyLink,
                UpPartyId            = partyId,
                SessionId            = logoutRequest.SessionId,
                RequireLogoutConsent = logoutRequest.RequireLogoutConsent,
                PostLogoutRedirect   = logoutRequest.PostLogoutRedirect,
            });

            return(HttpContext.GetUpPartyUrl(partyLink.Name, Constants.Routes.OAuthUpJumpController, Constants.Endpoints.UpJump.EndSessionRequest, includeSequence: true).ToRedirectResult());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> LogoutRedirect(UpPartyLink partyLink, LogoutRequest logoutRequest)
        {
            logger.ScopeTrace("Down, Logout redirect.");
            var partyId = await UpParty.IdFormat(RouteBinding, partyLink.Name);

            logger.SetScopeProperty("upPartyId", partyId);

            await logoutRequest.ValidateObjectAsync();

            await sequenceLogic.SaveSequenceDataAsync(new LoginUpSequenceData
            {
                DownPartyId          = logoutRequest.DownParty.Id,
                DownPartyType        = logoutRequest.DownParty.Type,
                UpPartyId            = partyId,
                SessionId            = logoutRequest.SessionId,
                RequireLogoutConsent = logoutRequest.RequireLogoutConsent,
                PostLogoutRedirect   = logoutRequest.PostLogoutRedirect
            });

            return(new RedirectResult($"~/{RouteBinding.TenantName}/{RouteBinding.TrackName}/({partyLink.Name})/login/logout/_{HttpContext.GetSequenceString()}"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> LogoutAsync(UpPartyLink partyLink, LogoutRequest logoutRequest)
        {
            logger.ScopeTrace("Up, SAML Logout request.");
            var partyId = await UpParty.IdFormat(RouteBinding, partyLink.Name);

            logger.SetScopeProperty("upPartyId", partyId);

            await logoutRequest.ValidateObjectAsync();

            await sequenceLogic.SaveSequenceDataAsync(new SamlUpSequenceData
            {
                DownPartyId   = logoutRequest.DownParty.Id,
                DownPartyType = logoutRequest.DownParty.Type,
            });

            if (logoutRequest.RequireLogoutConsent)
            {
                throw new NotSupportedException("Require SAML up logout consent not supported.");
            }
            if (!logoutRequest.PostLogoutRedirect)
            {
                throw new NotSupportedException("SAML up post logout redirect required.");
            }

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

            ValidatePartyLogoutSupport(party);

            switch (party.LogoutBinding.RequestBinding)
            {
            case SamlBindingType.Redirect:
                return(await LogoutAsync(party, new Saml2RedirectBinding(), logoutRequest));

            case SamlBindingType.Post:
                return(await LogoutAsync(party, new Saml2PostBinding(), logoutRequest));

            default:
                throw new NotSupportedException($"Binding '{party.LogoutBinding.RequestBinding}' not supported.");
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> LogoutRedirect(UpPartyLink partyLink, LogoutRequest logoutRequest)
        {
            logger.ScopeTrace(() => "Down, Logout redirect.");
            var partyId = await UpParty.IdFormatAsync(RouteBinding, partyLink.Name);

            logger.SetScopeProperty(Constants.Logs.UpPartyId, partyId);

            await logoutRequest.ValidateObjectAsync();

            await sequenceLogic.SetUiUpPartyIdAsync(partyId);

            await sequenceLogic.SaveSequenceDataAsync(new LoginUpSequenceData
            {
                DownPartyLink        = logoutRequest.DownPartyLink,
                UpPartyId            = partyId,
                SessionId            = logoutRequest.SessionId,
                RequireLogoutConsent = logoutRequest.RequireLogoutConsent,
                PostLogoutRedirect   = logoutRequest.PostLogoutRedirect
            });

            return(HttpContext.GetUpPartyUrl(partyLink.Name, Constants.Routes.LoginController, Constants.Endpoints.Logout, includeSequence: true).ToRedirectResult());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> LogoutRequestRedirectAsync(UpPartyLink partyLink, LogoutRequest logoutRequest)
        {
            logger.ScopeTrace(() => "Up, SAML Logout request.");
            var partyId = await UpParty.IdFormatAsync(RouteBinding, partyLink.Name);

            logger.SetScopeProperty(Constants.Logs.UpPartyId, partyId);

            await logoutRequest.ValidateObjectAsync();

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

            await sequenceLogic.SaveSequenceDataAsync(new SamlUpSequenceData
            {
                DownPartyLink        = logoutRequest.DownPartyLink,
                UpPartyId            = partyId,
                SessionId            = logoutRequest.SessionId,
                RequireLogoutConsent = logoutRequest.RequireLogoutConsent,
                PostLogoutRedirect   = logoutRequest.PostLogoutRedirect,
                Claims = logoutRequest.Claims.ToClaimAndValues()
            });

            return(HttpContext.GetUpPartyUrl(partyLink.Name, Constants.Routes.SamlUpJumpController, Constants.Endpoints.UpJump.LogoutRequest, includeSequence: true, partyBindingPattern: party.PartyBindingPattern).ToRedirectResult());
        }