private void OnEnter(object source, EventArgs eventArgs) { if (!_fAuthChecked || _fAuthRequired) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; if (!_fAuthChecked) { AuthenticationSection authentication = RuntimeConfig.GetAppConfig().Authentication; _fAuthRequired = AuthenticationConfig.Mode == AuthenticationMode.Passport; _LoginUrl = authentication.Passport.RedirectUrl; _fAuthChecked = true; } if (_fAuthRequired) { PassportIdentity identity = new PassportIdentity(); this.OnAuthenticate(new PassportAuthenticationEventArgs(identity, context)); context.SetSkipAuthorizationNoDemand(AuthenticationConfig.AccessingLoginPage(context, _LoginUrl), false); if (!context.SkipAuthorization) { context.SkipAuthorization = AssemblyResourceLoader.IsValidWebResourceRequest(context); } } } }
private void OnEnter(object source, EventArgs eventArgs) { if (!_fAuthChecked || _fAuthRequired) { HttpApplication application = (HttpApplication) source; HttpContext context = application.Context; if (!_fAuthChecked) { AuthenticationSection authentication = RuntimeConfig.GetAppConfig().Authentication; _fAuthRequired = AuthenticationConfig.Mode == AuthenticationMode.Passport; _LoginUrl = authentication.Passport.RedirectUrl; _fAuthChecked = true; } if (_fAuthRequired) { PassportIdentity identity = new PassportIdentity(); this.OnAuthenticate(new PassportAuthenticationEventArgs(identity, context)); context.SetSkipAuthorizationNoDemand(AuthenticationConfig.AccessingLoginPage(context, _LoginUrl), false); if (!context.SkipAuthorization) { context.SkipAuthorization = AssemblyResourceLoader.IsValidWebResourceRequest(context); } } } }
private void OnLeave(object source, EventArgs eventArgs) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; if ((_fAuthChecked && _fAuthRequired) && (((context.User != null) && (context.User.Identity != null)) && (context.User.Identity is PassportIdentity))) { PassportIdentity identity = (PassportIdentity)context.User.Identity; if ((context.Response.StatusCode == 0x191) && !identity.WWWAuthHeaderSet) { if (((_LoginUrl == null) || (_LoginUrl.Length < 1)) || (string.Compare(_LoginUrl, "internal", StringComparison.Ordinal) == 0)) { context.Response.Clear(); context.Response.StatusCode = 200; if (!ErrorFormatter.RequiresAdaptiveErrorReporting(context)) { string str = context.Request.Url.ToString(); int index = str.IndexOf('?'); if (index >= 0) { str = str.Substring(0, index); } string str2 = identity.LogoTag2(HttpUtility.UrlEncode(str, context.Request.ContentEncoding)); string s = System.Web.SR.GetString("PassportAuthFailed", new object[] { str2 }); context.Response.Write(s); } else { ErrorFormatter formatter = new PassportAuthFailedErrorFormatter(); context.Response.Write(formatter.GetAdaptiveErrorMessage(context, true)); } } else { string str7; string completeLoginUrl = AuthenticationConfig.GetCompleteLoginUrl(context, _LoginUrl); if ((completeLoginUrl == null) || (completeLoginUrl.Length <= 0)) { throw new HttpException(System.Web.SR.GetString("Invalid_Passport_Redirect_URL")); } string str5 = context.Request.Url.ToString(); if (completeLoginUrl.IndexOf('?') >= 0) { str7 = "&"; } else { str7 = "?"; } string url = completeLoginUrl + str7 + "ReturnUrl=" + HttpUtility.UrlEncode(str5, context.Request.ContentEncoding); int num2 = str5.IndexOf('?'); if ((num2 >= 0) && (num2 < (str5.Length - 1))) { url = url + "&" + str5.Substring(num2 + 1); } context.Response.Redirect(url, false); } } } }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Set the string sIsAuth to the users SignIn status (a boolean) converted to a string. String sIsAuth = newPass.IsAuthenticated.ToString(); // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Set a string to the URL of the appropriate Passport SignIn/SignOut authority. string sPassportlink = newPass.LogoTag(); // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Get the name of the Passport domain associated with the current UserName. string passportDomain = newPass.GetDomainFromMemberName(newPass.Name); // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Declare and set myURL variable = the URL of the appropriate Passport SignIn/SignOut Authority. string myURL = newPass.AuthUrl(); // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Build a string with the elapsed time since the user last signed in with the Passport Authority. string sElapsedTimeSignIn = "Elapsed time since SignIn: " + newPass.TimeSinceSignIn.ToString() + " seconds."; // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Build a string with the elapsed time since the user's ticket was last refreshed with the Passport Authority. string sElapsedTime = "Elapsed time since ticket refresh: " + newPass.TicketAge.ToString() + " seconds."; // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Set a string variable to the Passport member name from the cookie. string sMemberName = newPass.Name; // </snippet1> }
public static void Main() { // <snippet1> // Declare new PassportIdendity object as variable newPass. System.Web.Security.PassportIdentity newPass = new System.Web.Security.PassportIdentity(); // Set a string variable that indicates whether the user has a valid Passport ticket. String sHasTick = newPass.HasTicket.ToString(); // </snippet1> }
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Methods for internal implementation /// <include file='doc\PassportAuthenticationModule.uex' path='docs/doc[@for="PassportAuthenticationModule.OnEnter"]/*' /> /// <internalonly/> /// <devdoc> /// </devdoc> void OnEnter(Object source, EventArgs eventArgs) { if (_fAuthChecked && !_fAuthRequired) { return; } HttpApplication app; HttpContext context; app = (HttpApplication)source; context = app.Context; if (!_fAuthChecked) { AuthenticationConfig settings = (AuthenticationConfig)context.GetConfig("system.web/authentication"); _fAuthRequired = (settings.Mode == AuthenticationMode.Passport); _LoginUrl = settings.PassportUrl; _fAuthChecked = true; } if (!_fAuthRequired) { return; } //////////////////////////////////////////////////////// // Step 1: See if this request is valid or not if (context.Response.StatusCode == 401 || context.Response.StatusCode == 400 || context.Response.StatusCode == 500 || context.User != null) // Some module has already verified that the credentials are invalid { return; } //////////////////////////////////////////////////////// // Step 2: Create a Passport Identity from the credentials // from IIS PassportIdentity identity = new PassportIdentity(); //////////////////////////////////////////////////////// // Step 4: Call OnAuthenticate virtual method to create // an IPrincipal for this request OnAuthenticate(new PassportAuthenticationEventArgs(identity, context)); //////////////////////////////////////////////////////// // Skip AuthZ if accessing the login page context.SkipAuthorization = AuthenticationConfig.AccessingLoginPage(context, _LoginUrl); }
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Methods for internal implementation /// <internalonly/> /// <devdoc> /// </devdoc> void OnEnter(Object source, EventArgs eventArgs) { if (_fAuthChecked && !_fAuthRequired) { return; } HttpApplication app; HttpContext context; app = (HttpApplication)source; context = app.Context; if (!_fAuthChecked) { AuthenticationSection settings = RuntimeConfig.GetAppConfig().Authentication; _fAuthRequired = (AuthenticationConfig.Mode == AuthenticationMode.Passport); _LoginUrl = settings.Passport.RedirectUrl; _fAuthChecked = true; } if (!_fAuthRequired) { return; } //////////////////////////////////////////////////////// // Step 1: See if this request is valid or not // VSWhidbey 442515: We no longer need to do this check, always proceed //////////////////////////////////////////////////////// // Step 2: Create a Passport Identity from the credentials // from IIS PassportIdentity identity = new PassportIdentity(); //////////////////////////////////////////////////////// // Step 4: Call OnAuthenticate virtual method to create // an IPrincipal for this request OnAuthenticate(new PassportAuthenticationEventArgs(identity, context)); //////////////////////////////////////////////////////// // Skip AuthZ if accessing the login page context.SetSkipAuthorizationNoDemand(AuthenticationConfig.AccessingLoginPage(context, _LoginUrl), false /*managedOnly*/); if (!context.SkipAuthorization) { context.SkipAuthorization = AssemblyResourceLoader.IsValidWebResourceRequest(context); } }
public PassportPrincipal(PassportIdentity identity, string[] roles) : base(default(System.Security.Principal.IIdentity), default(string[])) { }
/// <devdoc> /// Constructor /// </devdoc> public PassportAuthenticationEventArgs(PassportIdentity identity, HttpContext context) { _Identity = identity; _Context = context; }
/// <devdoc> /// Signs out the given Passport member from /// their current session. /// </devdoc> public static void SignOut(String strSignOutDotGifFileName) { HttpContext context = HttpContext.Current; String [] sCookieNames = {"MSPAuth", "MSPProf", "MSPConsent", "MSPSecAuth", "MSPProfC"}; String [] sCookieDomains = {"TicketDomain", "TicketDomain", "ProfileDomain", "SecureDomain", "TicketDomain"}; String [] sCookiePaths = {"TicketPath", "TicketPath", "ProfilePath", "SecurePath", "TicketPath"}; String [] sCookieDomainsV = new String[5]; String [] sCookiePathsV = new String[5]; PassportIdentity pi = null; int iter = 0; //////////////////////////////////////////////////////////// // Step 1: Clear all headers context.Response.ClearHeaders(); //////////////////////////////////////////////////////////// // Step 2: Get passport config information (if using Passport 2.0 sdk) try { if (context.User.Identity is PassportIdentity) { pi = (PassportIdentity) context.User.Identity; } else { pi = new PassportIdentity(); } if (pi != null && _iPassportVer >= 3) { // Get Domains for(iter=0; iter<5; iter++) { Object obj = pi.GetCurrentConfig(sCookieDomains[iter]); if (obj != null && (obj is String)) sCookieDomainsV[iter] = (String) obj; } // Get Paths for(iter=0; iter<5; iter++) { Object obj = pi.GetCurrentConfig(sCookiePaths[iter]); if (obj != null && (obj is String)) sCookiePathsV[iter] = (String) obj; } } } catch { // ---- exceptions } //////////////////////////////////////////////////////////// // Step 3: Add cookies for(iter=0; iter<5; iter++) { HttpCookie cookie = new HttpCookie(sCookieNames[iter], String.Empty); cookie.Expires = new DateTime(1998, 1, 1); if (sCookieDomainsV[iter] != null && sCookieDomainsV[iter].Length > 0) cookie.Domain = sCookieDomainsV[iter]; if (sCookiePathsV[iter] != null && sCookiePathsV[iter].Length > 0) cookie.Path = sCookiePathsV[iter]; else cookie.Path = "/"; context.Response.Cookies.Add(cookie); } // context.Response.AppendHeader("P3P", "CP=\"TST\""); //////////////////////////////////////////////////////////// // Step 4: Add no-cache headers context.Response.Expires = -1; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.AppendHeader("Pragma", "no-cache"); context.Response.ContentType = "image/gif"; //////////////////////////////////////////////////////////// // Step 5: Write Image file context.Response.WriteFile(strSignOutDotGifFileName); //////////////////////////////////////////////////////////// // Step 6: Mobile device support: Redirect to the "ru" in the QS (if present) String strRU = context.Request.QueryString["ru"]; if (strRU != null && strRU.Length > 1) context.Response.Redirect(strRU, false); }
public static void SignOut(string strSignOutDotGifFileName) { HttpContext current = HttpContext.Current; string[] strArray = new string[] { "MSPAuth", "MSPProf", "MSPConsent", "MSPSecAuth", "MSPProfC" }; string[] strArray2 = new string[] { "TicketDomain", "TicketDomain", "ProfileDomain", "SecureDomain", "TicketDomain" }; string[] strArray3 = new string[] { "TicketPath", "TicketPath", "ProfilePath", "SecurePath", "TicketPath" }; string[] strArray4 = new string[5]; string[] strArray5 = new string[5]; PassportIdentity identity = null; int index = 0; current.Response.ClearHeaders(); try { if (current.User.Identity is PassportIdentity) { identity = (PassportIdentity) current.User.Identity; } else { identity = new PassportIdentity(); } if ((identity != null) && (_iPassportVer >= 3)) { for (index = 0; index < 5; index++) { object currentConfig = identity.GetCurrentConfig(strArray2[index]); if ((currentConfig != null) && (currentConfig is string)) { strArray4[index] = (string) currentConfig; } } for (index = 0; index < 5; index++) { object obj3 = identity.GetCurrentConfig(strArray3[index]); if ((obj3 != null) && (obj3 is string)) { strArray5[index] = (string) obj3; } } } } catch { } for (index = 0; index < 5; index++) { HttpCookie cookie = new HttpCookie(strArray[index], string.Empty) { Expires = new DateTime(0x7ce, 1, 1) }; if ((strArray4[index] != null) && (strArray4[index].Length > 0)) { cookie.Domain = strArray4[index]; } if ((strArray5[index] != null) && (strArray5[index].Length > 0)) { cookie.Path = strArray5[index]; } else { cookie.Path = "/"; } current.Response.Cookies.Add(cookie); } current.Response.Expires = -1; current.Response.Cache.SetCacheability(HttpCacheability.NoCache); current.Response.AppendHeader("Pragma", "no-cache"); current.Response.ContentType = "image/gif"; current.Response.WriteFile(strSignOutDotGifFileName); string url = current.Request.QueryString["ru"]; if ((url != null) && (url.Length > 1)) { current.Response.Redirect(url, false); } }
public PassportPrincipal(PassportIdentity identity, string[] roles) : base(identity, roles) { }
public PassportAuthenticationEventArgs (PassportIdentity identity, System.Web.HttpContext context) { }
public PassportAuthenticationEventArgs(PassportIdentity identity, HttpContext context) { this.identity = identity; this.context = context; }
void OnLeave(Object source, EventArgs eventArgs) { HttpApplication app; HttpContext context; app = (HttpApplication)source; context = app.Context; if (!_fAuthChecked || !_fAuthRequired || context.User == null || context.User.Identity == null || !(context.User.Identity is PassportIdentity)) { return; } PassportIdentity id = (PassportIdentity)context.User.Identity; if (context.Response.StatusCode != 401 || id.WWWAuthHeaderSet) { return; } if (_LoginUrl == null || _LoginUrl.Length < 1 || String.Compare(_LoginUrl, "internal", StringComparison.Ordinal) == 0) { context.Response.Clear(); context.Response.StatusCode = 200; if (!ErrorFormatter.RequiresAdaptiveErrorReporting(context)) { String strUrl = context.Request.Url.ToString(); int iPos = strUrl.IndexOf('?'); if (iPos >= 0) { strUrl = strUrl.Substring(0, iPos); } String strLogoTag = id.LogoTag2(HttpUtility.UrlEncode(strUrl, context.Request.ContentEncoding)); String strMsg = SR.GetString(SR.PassportAuthFailed, strLogoTag); context.Response.Write(strMsg); } else { ErrorFormatter errorFormatter = new PassportAuthFailedErrorFormatter(); context.Response.Write(errorFormatter.GetAdaptiveErrorMessage(context, true)); } } else { //////////////////////////////////////////////////////////// // Step 1: Get the redirect url String redirectUrl = AuthenticationConfig.GetCompleteLoginUrl(context, _LoginUrl); //////////////////////////////////////////////////////////// // Step 2: Check if we have a valid url to the redirect-page if (redirectUrl == null || redirectUrl.Length <= 0) { throw new HttpException(SR.GetString(SR.Invalid_Passport_Redirect_URL)); } //////////////////////////////////////////////////////////// // Step 3: Construct the redirect-to url String strUrl = context.Request.Url.ToString(); String strRedirect; int iIndex; String strSep; if (redirectUrl.IndexOf('?') >= 0) { strSep = "&"; } else { strSep = "?"; } strRedirect = redirectUrl + strSep + "ReturnUrl=" + HttpUtility.UrlEncode(strUrl, context.Request.ContentEncoding); //////////////////////////////////////////////////////////// // Step 4: Add the query-string from the current url iIndex = strUrl.IndexOf('?'); if (iIndex >= 0 && iIndex < strUrl.Length - 1) { strRedirect += "&" + strUrl.Substring(iIndex + 1); } //////////////////////////////////////////////////////////// // Step 5: Do the redirect context.Response.Redirect(strRedirect, false); } }
/// <devdoc> /// Signs out the given Passport member from /// their current session. /// </devdoc> public static void SignOut(String strSignOutDotGifFileName) { HttpContext context = HttpContext.Current; String [] sCookieNames = { "MSPAuth", "MSPProf", "MSPConsent", "MSPSecAuth", "MSPProfC" }; String [] sCookieDomains = { "TicketDomain", "TicketDomain", "ProfileDomain", "SecureDomain", "TicketDomain" }; String [] sCookiePaths = { "TicketPath", "TicketPath", "ProfilePath", "SecurePath", "TicketPath" }; String [] sCookieDomainsV = new String[5]; String [] sCookiePathsV = new String[5]; PassportIdentity pi = null; int iter = 0; //////////////////////////////////////////////////////////// // Step 1: Clear all headers context.Response.ClearHeaders(); //////////////////////////////////////////////////////////// // Step 2: Get passport config information (if using Passport 2.0 sdk) try { if (context.User.Identity is PassportIdentity) { pi = (PassportIdentity)context.User.Identity; } else { pi = new PassportIdentity(); } if (pi != null && _iPassportVer >= 3) { // Get Domains for (iter = 0; iter < 5; iter++) { Object obj = pi.GetCurrentConfig(sCookieDomains[iter]); if (obj != null && (obj is String)) { sCookieDomainsV[iter] = (String)obj; } } // Get Paths for (iter = 0; iter < 5; iter++) { Object obj = pi.GetCurrentConfig(sCookiePaths[iter]); if (obj != null && (obj is String)) { sCookiePathsV[iter] = (String)obj; } } } } catch { // ---- exceptions } //////////////////////////////////////////////////////////// // Step 3: Add cookies for (iter = 0; iter < 5; iter++) { HttpCookie cookie = new HttpCookie(sCookieNames[iter], String.Empty); cookie.Expires = new DateTime(1998, 1, 1); if (sCookieDomainsV[iter] != null && sCookieDomainsV[iter].Length > 0) { cookie.Domain = sCookieDomainsV[iter]; } if (sCookiePathsV[iter] != null && sCookiePathsV[iter].Length > 0) { cookie.Path = sCookiePathsV[iter]; } else { cookie.Path = "/"; } context.Response.Cookies.Add(cookie); } // context.Response.AppendHeader("P3P", "CP=\"TST\""); //////////////////////////////////////////////////////////// // Step 4: Add no-cache headers context.Response.Expires = -1; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.AppendHeader("Pragma", "no-cache"); context.Response.ContentType = "image/gif"; //////////////////////////////////////////////////////////// // Step 5: Write Image file context.Response.WriteFile(strSignOutDotGifFileName); //////////////////////////////////////////////////////////// // Step 6: Mobile device support: Redirect to the "ru" in the QS (if present) String strRU = context.Request.QueryString["ru"]; if (strRU != null && strRU.Length > 1) { context.Response.Redirect(strRU, false); } }
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Methods for internal implementation /// <internalonly/> /// <devdoc> /// </devdoc> void OnEnter(Object source, EventArgs eventArgs) { if (_fAuthChecked && !_fAuthRequired) return; HttpApplication app; HttpContext context; app = (HttpApplication)source; context = app.Context; if (!_fAuthChecked) { AuthenticationSection settings = RuntimeConfig.GetAppConfig().Authentication; _fAuthRequired = (AuthenticationConfig.Mode == AuthenticationMode.Passport); _LoginUrl = settings.Passport.RedirectUrl; _fAuthChecked = true; } if (!_fAuthRequired) return; //////////////////////////////////////////////////////// // Step 1: See if this request is valid or not // VSWhidbey 442515: We no longer need to do this check, always proceed //////////////////////////////////////////////////////// // Step 2: Create a Passport Identity from the credentials // from IIS PassportIdentity identity = new PassportIdentity(); //////////////////////////////////////////////////////// // Step 4: Call OnAuthenticate virtual method to create // an IPrincipal for this request OnAuthenticate( new PassportAuthenticationEventArgs(identity, context) ); //////////////////////////////////////////////////////// // Skip AuthZ if accessing the login page context.SetSkipAuthorizationNoDemand(AuthenticationConfig.AccessingLoginPage(context, _LoginUrl), false /*managedOnly*/); if (!context.SkipAuthorization) { context.SkipAuthorization = AssemblyResourceLoader.IsValidWebResourceRequest(context); } }
public PassportAuthenticationEventArgs(PassportIdentity identity, System.Web.HttpContext context) { }
public static void SignOut(string strSignOutDotGifFileName) { HttpContext current = HttpContext.Current; string[] strArray = new string[] { "MSPAuth", "MSPProf", "MSPConsent", "MSPSecAuth", "MSPProfC" }; string[] strArray2 = new string[] { "TicketDomain", "TicketDomain", "ProfileDomain", "SecureDomain", "TicketDomain" }; string[] strArray3 = new string[] { "TicketPath", "TicketPath", "ProfilePath", "SecurePath", "TicketPath" }; string[] strArray4 = new string[5]; string[] strArray5 = new string[5]; PassportIdentity identity = null; int index = 0; current.Response.ClearHeaders(); try { if (current.User.Identity is PassportIdentity) { identity = (PassportIdentity)current.User.Identity; } else { identity = new PassportIdentity(); } if ((identity != null) && (_iPassportVer >= 3)) { for (index = 0; index < 5; index++) { object currentConfig = identity.GetCurrentConfig(strArray2[index]); if ((currentConfig != null) && (currentConfig is string)) { strArray4[index] = (string)currentConfig; } } for (index = 0; index < 5; index++) { object obj3 = identity.GetCurrentConfig(strArray3[index]); if ((obj3 != null) && (obj3 is string)) { strArray5[index] = (string)obj3; } } } } catch { } for (index = 0; index < 5; index++) { HttpCookie cookie = new HttpCookie(strArray[index], string.Empty) { Expires = new DateTime(0x7ce, 1, 1) }; if ((strArray4[index] != null) && (strArray4[index].Length > 0)) { cookie.Domain = strArray4[index]; } if ((strArray5[index] != null) && (strArray5[index].Length > 0)) { cookie.Path = strArray5[index]; } else { cookie.Path = "/"; } current.Response.Cookies.Add(cookie); } current.Response.Expires = -1; current.Response.Cache.SetCacheability(HttpCacheability.NoCache); current.Response.AppendHeader("Pragma", "no-cache"); current.Response.ContentType = "image/gif"; current.Response.WriteFile(strSignOutDotGifFileName); string url = current.Request.QueryString["ru"]; if ((url != null) && (url.Length > 1)) { current.Response.Redirect(url, false); } }
public PassportPrincipal(PassportIdentity identity, string[] roles) : base (default(System.Security.Principal.IIdentity), default(string[])) { }