Пример #1
0
        public static string GenerateContentAuthenticationRequest(HttpContextBase httpContext)
        {         // should be called on content app
            string token;

            lock (CacheLocker)
            {
                string cacheKey;
                do
                {
                    var randomBytes = EncryptionManager.GetRandomBytes(24);
                    token    = HttpServerUtility.UrlTokenEncode(randomBytes);
                    cacheKey = GetCacheKey(token);
                } while (httpContext.Cache[token] != null);

                httpContext.Cache.Insert(cacheKey, httpContext.Request.RawUrl, null, DateTime.UtcNow.AddSeconds(60), Cache.NoSlidingExpiration);
            }

            var uriBuilder = new UriBuilder
            {
                Host   = httpContext.Request.Params["webhost"],
                Scheme = HttpContext.Current.Request.Url.Scheme,
                Path   = "authorization",
                Query  = $"token={token}"
            };

            return(uriBuilder.ToString());
        }