Skip to content

Instantly share code, notes, and snippets.

@zdi-team
Created August 16, 2021 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdi-team/564e664ea4ce0ae4d6f933f1c6ba8a25 to your computer and use it in GitHub Desktop.
Save zdi-team/564e664ea4ce0ae4d6f933f1c6ba8a25 to your computer and use it in GitHub Desktop.
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