예제 #1
0
        public static bool CheckGripSignature(this HttpRequestMessage request, PublishControl.Configuration config, DateTime?checkTime = null)
        {
            IEnumerable <string> values;

            if (!request.Headers.TryGetValues("Grip-Sig", out values))
            {
                return(false);
            }

            foreach (var headerVal in values)
            {
                try
                {
                    Validator.CheckGripSignature(headerVal, config, checkTime);
                    return(true);
                }
                catch (ValidationException)
                {
                    // skip to the next
                }
            }

            return(false);
        }
예제 #2
0
        public static Dictionary <string, object> CheckGripSignature(string gripSignatureHeader, PublishControl.Configuration config, DateTime?checkTime = null)
        {
            string claimRaw = null;

            foreach (var entry in config.Entries)
            {
                if (entry.Key == null)
                {
                    continue;
                }

                try
                {
                    claimRaw = JWT.JsonWebToken.Decode(gripSignatureHeader, entry.Key);
                    break;
                }
                catch (Exception)
                {
                    // pass
                }
            }

            if (claimRaw == null)
            {
                throw new ValidationException("Could not decode signature with any key.");
            }

            return(CheckGripSignature(claimRaw, checkTime));
        }