Beispiel #1
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     if (!String.IsNullOrEmpty(IdentityConfig.Realm))
     {
         e.SignInRequestMessage.Realm = IdentityConfig.Realm;
     }
 }
Beispiel #2
0
 protected override void OnRedirectingToIdentityProvider(RedirectingToIdentityProviderEventArgs e)
 {
     //"X-Requested-With", "XMLHttpRequest"
     if ((new HttpRequestWrapper(HttpContext.Current.Request)).IsAjaxRequest())
     {
         e.Cancel = true;
     }
     base.OnRedirectingToIdentityProvider(e);
 }
Beispiel #3
0
        protected override void OnRedirectingToIdentityProvider(RedirectingToIdentityProviderEventArgs e)
        {
            this.LogDebugIfEnabled(string.Format(CultureInfo.InvariantCulture, "Changing reply from \"{0}\" to \"{1}\".", e.SignInRequestMessage.Reply, this.WebFacade.Request.Url), "OnRedirectingToIdentityProvider");

            // ReSharper disable PossibleNullReferenceException
            e.SignInRequestMessage.Reply = this.WebFacade.Request.Url.ToString();
            // ReSharper restore PossibleNullReferenceException

            base.OnRedirectingToIdentityProvider(e);
        }
 /// <summary>
 /// Raises the <see cref="E:System.IdentityModel.Services.WSFederationAuthenticationModule.RedirectingToIdentityProvider" /> event.
 /// </summary>
 /// <param name="e">The data for the event.</param>
 protected override void OnRedirectingToIdentityProvider(RedirectingToIdentityProviderEventArgs e)
 {
     Logger.Info("OnRedirectingToIdentityProvider start");
     if (this.EnvironmentLive && e != null)
     {
         var wctx = HttpUtility.ParseQueryString(e.SignInRequestMessage.GetParameter("wctx"));
         if (wctx != null && wctx.Count != 0)
         {
             string ru = wctx["ru"];
             ru = ru.Replace("&", "%26");
             ru = ru.Replace("=", "%3D");
             Logger.Info(string.Format("OnRedirectingToIdentityProvider  ReturnURL: {0}", ru));
             e.SignInRequestMessage.Realm = this.DetermineDynamicRealm() + ru;
             Logger.Info(string.Format("OnRedirectingToIdentityProvider  Realm: {0}", e.SignInRequestMessage.Realm));
         }
     }
     Logger.Info("OnRedirectingToIdentityProvider End");
     base.OnRedirectingToIdentityProvider(e);
 }
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     SignInRequestMessage signInRequestMessage = e.SignInRequestMessage;
 }
Beispiel #6
0
 /// <summary>
 /// Module Event Hanlder.
 /// Handles the RedirectingToIdentityProvider event of the WSFederationAuthenticationModule control.
 /// See 'Programming WIF', p.74 for more details.
 /// </summary>
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
 }
Beispiel #7
0
        void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
        {
            var host = HttpContext.Current.Request.Url.Host;

            if (host == "www.grean.id")
            {
                SetIdPHost("easyid.www.grean.id", e.SignInRequestMessage);
            }

            if (!String.IsNullOrEmpty(IdentityConfig.Realm))
            {
                e.SignInRequestMessage.Realm = IdentityConfig.Realm;
                var authMethod = "";
                if (HttpContext.Current.Request.Url.Query != null)
                {
                    var qs = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query);
                    if (qs["authMethod"] != null)
                    {
                        authMethod = qs["authMethod"];
                    }
                }
                e.SignInRequestMessage.Reply =
                    new Uri(
                        HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority),
                        UriKind.Absolute).AbsoluteUri;
                if (authMethod == "nobid-mobile")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:no:bankid:mobile";
                    e.SignInRequestMessage.HomeRealm          = "nobid-mobile";
                }
                else if (authMethod == "nobid-central")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:no:bankid:central";
                    //e.SignInRequestMessage.HomeRealm = "nobid-central";
                }
                else if (authMethod == "sbid")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:se:bankid:another-device";
                    e.SignInRequestMessage.HomeRealm          = "sbid";
                }
                else if (authMethod == "sbid-local")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:se:bankid:same-device";
                    e.SignInRequestMessage.HomeRealm          = "sbid-local";
                }
                else if (authMethod == "dknemid-poces")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:dk:nemid:poces";
                    e.SignInRequestMessage.HomeRealm          = "dknemid-poces";
                }
                else if (authMethod == "dknemid-moces")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:dk:nemid:moces";
                    e.SignInRequestMessage.HomeRealm          = "dknemid-moces";
                }
                else if (authMethod == "dknemid-moces-codefile")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:dk:nemid:moces:codefile";
                    e.SignInRequestMessage.HomeRealm          = "dknemid-moces-codefile";
                }
                else if (authMethod == "fi-tupas")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:fi:tupas";
                    e.SignInRequestMessage.HomeRealm          = "fi-tupas";
                }
                else if (authMethod == "fi-mobile-id")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:fi:mobile-id";
                    e.SignInRequestMessage.HomeRealm          = "fi-mobile-id";
                }
                else if (authMethod == "fi-all")
                {
                    e.SignInRequestMessage.AuthenticationType = "urn:grn:authn:fi:all";
                    e.SignInRequestMessage.HomeRealm          = "fi-all";
                }
            }
        }
Beispiel #8
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     // keep original request deep path etc.
     //e.SignInRequestMessage = new SignInRequestMessage(new Uri(issuer), realm, Request.Url.AbsoluteUri);
     //signInMessage.Context = originalUrl;
 }
 private void CustomAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     var auth = (CustomWSFederationAuthenticationModule)sender;
     Debug.WriteLine("RedirectingToIdentityProvider. SignInRequestMessage:" + e.SignInRequestMessage);
 }
 protected override void OnRedirectingToIdentityProvider(RedirectingToIdentityProviderEventArgs e)
 {
     var parameters = HmacHelper.CreateHmacRequestParametersFromConfig(Consts.PermissionHmacSettingsPrefix);
     parameters.ForEach(e.SignInRequestMessage.Parameters.Add);
     base.OnRedirectingToIdentityProvider(e);
 }
Beispiel #11
0
// ReSharper disable InconsistentNaming
// Naming required to expose method to WSFederationAuthentication
        public void WSFederationAuthentication_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
// ReSharper restore InconsistentNaming
        {
            Trace.TraceInformation("WSFederationAuthentication_RedirectingToIdentityProvider: RequestUrl=" + e.SignInRequestMessage.RequestUrl);
            if (e.SignInRequestMessage.RequestUrl.Contains("localhost") ||
                e.SignInRequestMessage.RequestUrl.Contains("127.0.0.1"))
            {
                e.SignInRequestMessage.HomeRealm = "https://localhost:444/";
            }
            else if (e.SignInRequestMessage.RequestUrl.Contains("service-staging"))
            {
                e.SignInRequestMessage.HomeRealm = "https://service-staging.brightstardb.com/";
            }
        }
Beispiel #12
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     SignInRequestMessage signInRequestMessage = e.SignInRequestMessage;
 }
Beispiel #13
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     // Populer sign in request'et med whr-parameteren
     e.SignInRequestMessage.HomeRealm = Request.QueryString["whr"];
 }
 private void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     e.SignInRequestMessage.HomeRealm = "fcsamerica.com";
     e.SignInRequestMessage.Realm = "localhost:WebTestClient";
     e.SignInRequestMessage.Reply = Request.Url.ToString();
 }
Beispiel #15
0
 public void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     // can modify e.SignInRequestMessage
     var m = e.SignInRequestMessage;
 }
Beispiel #16
0
 protected void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     //if (SessionModule.ShouldReturn401OnAuthError(HttpContext.Current.Request))
     //    e.Cancel = true;
 }
Beispiel #17
0
 /// <summary>
 /// Retrieves the address that was used in the browser for accessing 
 /// the web application, and injects it as WREPLY parameter in the
 /// request to the STS
 /// Reference: http://msdn.microsoft.com/en-us/library/ee517293.aspx - WS-Federated Authentication Module Overview
 ///          : http://msdn.microsoft.com/en-us/library/microsoft.identitymodel.protocols.wsfederation.signinrequestmessage_members.aspx - SignInRequestMessage Members
 ///          : http://www.leastprivilege.com/GenevaIntegrationIntoASPNET.aspx - Geneva integration into ASP.NET
 ///          : http://www.leastprivilege.com/GenevaHTTPModulesClaimsPrincipalHttpModule.aspx - Geneva HTTP Modules: ClaimsPrincipalHttpModule
 /// </summary>      
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     HttpRequest request = HttpContext.Current.Request; Uri requestUrl = request.Url; StringBuilder wreply = new StringBuilder();  wreply.Append(requestUrl.Scheme); wreply.Append("://");  String host = request.Headers["Host"]; host = host.Replace("127.0.0.1", "localhost"); host = host.Replace("127.0.0.2", "localhost"); wreply.Append(host); e.SignInRequestMessage.Realm = wreply.ToString().EndsWith("/") ? wreply.ToString() : wreply.ToString() + "/"; e.SignInRequestMessage.Reply = wreply.ToString().EndsWith("/") ? wreply.ToString() : wreply.ToString() + "/";
 }
        private void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
        {
            // In the Windows Azure environment, build a wreply parameter for the SignIn request
            // that reflects the real address of the application.
            HttpRequest request    = HttpContext.Current.Request;
            Uri         requestUrl = request.Url;
            var         wreply     = new StringBuilder();

            wreply.Append(requestUrl.Scheme); // e.g. "http" or "https"
            wreply.Append("://");
            wreply.Append(request.Headers["Host"] ?? requestUrl.Authority);
            wreply.Append(request.ApplicationPath);

            if (!request.ApplicationPath.EndsWith("/"))
            {
                wreply.Append("/");
            }

            e.SignInRequestMessage.Reply = wreply.ToString();
        }
        private void CustomAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
        {
            var auth = (CustomWSFederationAuthenticationModule)sender;

            Debug.WriteLine("RedirectingToIdentityProvider. SignInRequestMessage:" + e.SignInRequestMessage);
        }
Beispiel #20
0
        private void WSFederationAuthenticationModule_RedirectingToIdentityProvider( object sender, RedirectingToIdentityProviderEventArgs e )
        {
            Debug.WriteLine ( "FederatedAuthenticationModule.RedirectingToIdentityProvider -" );
            Debug.WriteLine ( "FederatedAuthenticationModule.RedirectingToIdentityProvider - SigningInRequestMessage" );
            Debug.WriteLine ( e.SignInRequestMessage.WriteQueryString () );
            e.SignInRequestMessage.BaseUri = new Uri ( FederatedAuthentication.WSFederationAuthenticationModule.Issuer );

            // If there is a Home Real specified, then use it as the BaseUri (Go to said IP-STS to get authenticated
            if (string.IsNullOrWhiteSpace ( Request["whr"]) )
            {
                return;
            }
            var url = new Uri ( Request["whr"]);
            e.SignInRequestMessage.BaseUri = url;

            //if ( e.SignInRequestMessage.RequestUrl.Contains (
            //    "IP1RealmEntry.aspx" ) )
            //{
            //    e.SignInRequestMessage.BaseUri =
            //        new Uri ( "https://localhost/IP1/STS/Default.aspx" );
            //}

            //else if ( e.SignInRequestMessage.RequestUrl.Contains (
            //    "IP2RealmEntry.aspx" ) )
            //{
            //    e.SignInRequestMessage.BaseUri = new Uri (
            //        "https://localhost/IP2/STS/Default.aspx" );
            //}
        }
Beispiel #21
0
 /// <summary>
 /// Retrieves the address that was used in the browser for accessing
 /// the web application, and injects it as WREPLY parameter in the
 /// request to the STS
 /// Reference: http://msdn.microsoft.com/en-us/library/ee517293.aspx - WS-Federated Authentication Module Overview
 ///          : http://msdn.microsoft.com/en-us/library/microsoft.identitymodel.protocols.wsfederation.signinrequestmessage_members.aspx - SignInRequestMessage Members
 ///          : http://www.leastprivilege.com/GenevaIntegrationIntoASPNET.aspx - Geneva integration into ASP.NET
 ///          : http://www.leastprivilege.com/GenevaHTTPModulesClaimsPrincipalHttpModule.aspx - Geneva HTTP Modules: ClaimsPrincipalHttpModule
 /// </summary>
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     HttpRequest request = HttpContext.Current.Request; Uri requestUrl = request.Url; StringBuilder wreply = new StringBuilder();  wreply.Append(requestUrl.Scheme); wreply.Append("://");  String host = request.Headers["Host"]; host = host.Replace("127.0.0.1", "localhost"); host = host.Replace("127.0.0.2", "localhost"); wreply.Append(host); e.SignInRequestMessage.Realm = wreply.ToString().EndsWith("/") ? wreply.ToString() : wreply.ToString() + "/"; e.SignInRequestMessage.Reply = wreply.ToString().EndsWith("/") ? wreply.ToString() : wreply.ToString() + "/";
 }
Beispiel #22
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     System.Diagnostics.Trace.WriteLine("Handling RedirectingToIdentityProvider event");
 }
Beispiel #23
0
 public void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
 }
Beispiel #24
0
        //</Snippet7>

        //<Snippet8>
        void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
        {
            //Use this event to programmatically modify the sign-in message to the STS.
            System.Diagnostics.Trace.WriteLine("Handling RedirectingToIdentityProvider event");
        }
Beispiel #25
0
        private void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
        {
            Debug.WriteLine("FederatedAuthenticationModule.RedirectingToIdentityProvider -");
            Debug.WriteLine("FederatedAuthenticationModule.RedirectingToIdentityProvider - SigningInRequestMessage");
            Debug.WriteLine(e.SignInRequestMessage.WriteQueryString());
            e.SignInRequestMessage.BaseUri = new Uri(FederatedAuthentication.WSFederationAuthenticationModule.Issuer);

            // If there is a Home Real specified, then use it as the BaseUri (Go to said IP-STS to get authenticated
            if (string.IsNullOrWhiteSpace(Request["whr"]))
            {
                return;
            }
            var url = new Uri(Request["whr"]);

            e.SignInRequestMessage.BaseUri = url;

            //if ( e.SignInRequestMessage.RequestUrl.Contains (
            //    "IP1RealmEntry.aspx" ) )
            //{
            //    e.SignInRequestMessage.BaseUri =
            //        new Uri ( "https://localhost/IP1/STS/Default.aspx" );
            //}

            //else if ( e.SignInRequestMessage.RequestUrl.Contains (
            //    "IP2RealmEntry.aspx" ) )
            //{
            //    e.SignInRequestMessage.BaseUri = new Uri (
            //        "https://localhost/IP2/STS/Default.aspx" );
            //}
        }
Beispiel #26
0
 void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
 {
     if (ad.Equals("true"))
     {
         if (!String.IsNullOrEmpty(IdentityConfig.Realm))
         {
             e.SignInRequestMessage.Realm = IdentityConfig.Realm;
         }
     }
 }
Beispiel #27
0
// ReSharper disable InconsistentNaming
// Naming required to expose method to WSFederationAuthentication
        public void WSFederationAuthentication_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
// ReSharper restore InconsistentNaming
        {
            Trace.TraceInformation("WSFederationAuthentication_RedirectingToIdentityProvider: RequestUrl=" + e.SignInRequestMessage.RequestUrl);
             if (e.SignInRequestMessage.RequestUrl.Contains("localhost") ||
                e.SignInRequestMessage.RequestUrl.Contains("127.0.0.1"))
            {
                e.SignInRequestMessage.HomeRealm = "https://localhost:444/";
            }
            else if (e.SignInRequestMessage.RequestUrl.Contains("service-staging"))
            {
                e.SignInRequestMessage.HomeRealm = "https://service-staging.brightstardb.com/";
            }
            
        }