module Kemal::Hmac

Defined in:

kemal-hmac.cr
kemal-hmac/client.cr
kemal-hmac/handler.cr
kemal-hmac/hmac_algorithm.cr
kemal-hmac/token.cr

Constant Summary

ALGORITHM = algorithm((ENV.fetch("HMAC_ALGORITHM", "SHA256")).upcase)
HMAC_CLIENT_HEADER = ENV.fetch("HMAC_CLIENT_HEADER", "hmac-client")
HMAC_KEY_DELIMITER = ENV.fetch("HMAC_KEY_DELIMITER", "_")
HMAC_KEY_SUFFIX_LIST = ((ENV.fetch("HMAC_KEY_SUFFIX_LIST", "HMAC_SECRET_BLUE,HMAC_SECRET_GREEN")).split(",")).map(&.strip)
HMAC_REJECTED_CODE = (ENV.fetch("HMAC_REJECTED_CODE", 401)).to_i
HMAC_REJECTED_MESSAGE_PREFIX = ENV.fetch("HMAC_REJECTED_MESSAGE_PREFIX", "Unauthorized:")
HMAC_TIMESTAMP_HEADER = ENV.fetch("HMAC_TIMESTAMP_HEADER", "hmac-timestamp")
HMAC_TIMESTAMP_SECOND_WINDOW = (ENV.fetch("HMAC_TIMESTAMP_SECOND_WINDOW", 30)).to_i
HMAC_TOKEN_HEADER = ENV.fetch("HMAC_TOKEN_HEADER", "hmac-token")
KEY_VALIDATION_REGEX = /^[A-Z0-9][A-Z0-9_-]+[A-Z0-9]$/
MD4 = 0
MD5 = 1
RIPEMD160 = 2
SHA1 = 3
SHA224 = 4
SHA256 = 5
SHA384 = 6
SHA512 = 7

Class Method Summary

Class Method Detail

def self.algorithm(algorithm : String) : OpenSSL::Algorithm #

[View source]
def self.algorithms(algorithm) : Int32 #

select the algorithm based on the string name and falls back to SHA256 if no match is found


[View source]