Пример #1
0
        /// <summary>
        /// Send an authentication request to the IDP.
        /// </summary>
        /// <param name="context">The context.</param>
        private void SendRequest(HttpContext context, Saml2Configuration config)
        {
            // See if the "ReturnUrl" - parameter is set.
            var returnUrl = context.Request.QueryString["ReturnUrl"];

            if (!string.IsNullOrEmpty(returnUrl) && context.Session != null)
            {
                context.Session["RedirectUrl"] = returnUrl;
            }

            var isRedirected  = false;
            var selectionUtil = new IdpSelectionUtil(Logger);
            var idp           = selectionUtil.RetrieveIDP(context.Request.Params, context.Request.QueryString, config, s => { context.Response.Redirect(s); isRedirected = true; });

            if (isRedirected)
            {
                return;
            }
            if (idp == null)
            {
                // Display a page to the user where she can pick the IDP
                Logger.DebugFormat(TraceMessages.IdentityProviderRedirect);

                var page = new SelectSaml20IDP();
                page.ProcessRequest(context);
                return;
            }

            var authnRequest = Saml20AuthnRequest.GetDefault(config);

            TransferClient(idp, authnRequest, context, config);
        }
Пример #2
0
        public override string BuildRedirectUrl()
        {
            string rc            = null;
            var    logger        = SAML2.Logging.LoggerProvider.LoggerFor(typeof(SamlMessage));
            var    selectionUtil = new IdpSelectionUtil(logger);
            var    allparams     = BuildParams(form, context.Request.Query);
            var    idp           = selectionUtil.RetrieveIDP(allparams, BuildParams(context.Request.Query), config, s => rc = s);

            if (rc != null)
            {
                return(rc);            // IDP selection screen
            }
            if (idp == null)
            {
                // Display a page to the user where she can pick the IDP
                logger.DebugFormat(TraceMessages.IdentityProviderRedirect);
                throw new NotImplementedException("Selection of IDP not yet done (probably need a map call on middleware extension method)");
                //var page = new SelectSaml20IDP();
                //page.ProcessRequest(context);
                //return;
            }

            var authnRequest = Saml20AuthnRequest.GetDefault(config);

            return(AuthnRequestForIdp(idp, authnRequest, context, config));
        }
Пример #3
0
        public string BuildSignOutRedirectUrl()
        {
            string rc            = null;
            var    logger        = SAML2.Logging.LoggerProvider.LoggerFor(typeof(SamlMessage));
            var    selectionUtil = new IdpSelectionUtil(logger);
            var    allparams     = BuildParams(form, context.Request.Query);
            var    idp           = selectionUtil.RetrieveIDP(allparams, BuildParams(context.Request.Query), config, s => rc = s);

            if (rc != null)
            {
                return(rc);            // IDP selection screen
            }
            if (idp == null)
            {
                logger.DebugFormat(TraceMessages.IdentityProviderRedirect);
                throw new NotImplementedException("Selection of IDP not yet done (probably need a map call on middleware extension method)");
            }

            var logoutRequest = Saml20LogoutRequest.GetDefault(config);

            return(LogoutRequestForIdp(idp, logoutRequest, context, config));
        }