Created
August 16, 2021 14:39
-
-
Save zdi-team/564e664ea4ce0ae4d6f933f1c6ba8a25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnAuthenticateRequest(object source, EventArgs args) { | |
HttpContext httpContext = HttpContext.Current; | |
if (httpContext.Request.IsAuthenticated) { | |
if (string.IsNullOrEmpty(httpContext.Request.Headers["X-CommonAccessToken"])) { | |
Uri url = httpContext.Request.Url; | |
Exception ex = null; | |
CommonAccessToken commonAccessToken = CommonAccessTokenFromUrl(httpContext. | |
User.Identity.ToString(), url, out ex); | |
} | |
} | |
} | |
private static CommonAccessToken CommonAccessTokenFromUrl(string user, Uri requestURI, out Exception ex) { | |
ex = null; | |
CommonAccessToken result = null; | |
string text = LiveIdBasicAuthModule.GetNameValueCollectionFromUri(requestURI).Get("X-Rps-CAT"); | |
if (!string.IsNullOrWhiteSpace(text)) { | |
try { | |
result = CommonAccessToken.Deserialize(Uri.UnescapeDataString(text)); | |
} catch (Exception ex2) { | |
// handle exception here | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment