예제 #1
0
        static string GetToken(RavenBaseApiController controller)
        {
            const string bearerPrefix = "Bearer ";

            var auth = controller.GetHeader("Authorization");

            if (auth == null)
            {
                auth = controller.GetCookie("OAuth-Token");
                if (auth != null)
                {
                    auth = Uri.UnescapeDataString(auth);
                }
            }
            if (auth == null || auth.Length <= bearerPrefix.Length ||
                !auth.StartsWith(bearerPrefix, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            var token = auth.Substring(bearerPrefix.Length, auth.Length - bearerPrefix.Length);

            return(token);
        }
예제 #2
0
        static string GetToken(RavenBaseApiController controller)
		{
			const string bearerPrefix = "Bearer ";

			var auth = controller.GetHeader("Authorization");
			if (auth == null)
			{
				auth = controller.GetCookie("OAuth-Token");
				if (auth != null)
					auth = Uri.UnescapeDataString(auth);
			}
			if (auth == null || auth.Length <= bearerPrefix.Length ||
				!auth.StartsWith(bearerPrefix, StringComparison.OrdinalIgnoreCase))
				return null;

			var token = auth.Substring(bearerPrefix.Length, auth.Length - bearerPrefix.Length);

			return token;
		}