Example #1
0
        public static string DecryptAndAuthenticateContentUser(string token, string data)
        {         // should be called on content app
            string url = HttpContext.Current.Cache[GetCacheKey(token)] as string;

            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            RPIdentity rpIdentity;

            try
            {
                string userData = EncryptionManager.Decrypt(data);
                rpIdentity = new RPIdentity(userData);
            }
            catch
            {
                return(null);
            }
            DateTime now = DateTime.Now;
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                2,
                rpIdentity.Name,
                now,
                now.Add(AuthenticationContentTimeout),
                false,
                rpIdentity.GetCookieString(),
                FormsAuthentication.FormsCookiePath
                );

            SetTicketToCookie(ticket);
            return(url);
        }
Example #2
0
        public static string GenerateContentAuthenticationResponse(string token)
        {         // should be called on web app
            RPIdentity rpIdentity = (RPIdentity)HttpContext.Current.User.Identity;

            string data       = EncryptionManager.Encrypt(rpIdentity.GetCookieString());
            var    uriBuilder = new UriBuilder
            {
                Host   = WebUrlManager.Host,
                Scheme = HttpContext.Current.Request.Url.Scheme,
                Path   = "user/authenticate",
                Query  = $"token={token}&data={data}"
            };

            return(uriBuilder.ToString());
        }