Created
October 15, 2018 10:35
-
-
Save ysv/010c8ddf5c11e8bf91ff95eeb9aea8af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verify_options = { | |
verify_expiration: true, | |
verify_not_before: true, | |
iss: ENV["JWT_ISSUER"], | |
verify_iss: !ENV["JWT_ISSUER"].nil?, | |
verify_iat: true, | |
verify_jti: true, | |
aud: ENV["JWT_AUDIENCE"].to_s.split(",").reject(&:empty?), | |
verify_aud: !ENV["JWT_AUDIENCE"].nil?, | |
sub: "session", | |
verify_sub: true, | |
algorithms: [ENV["JWT_ALGORITHM"] || "RS256"], | |
leeway: ENV["JWT_DEFAULT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? }, | |
iat_leeway: ENV["JWT_ISSUED_AT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? }, | |
exp_leeway: ENV["JWT_EXPIRATION_LEEWAY"].yield_self { |n| n.to_i unless n.nil? }, | |
nbf_leeway: ENV["JWT_NOT_BEFORE_LEEWAY"].yield_self { |n| n.to_i unless n.nil? }, | |
}.compact | |
token = "put your token" | |
public_key = APIv2::Auth::Utils.jwt_public_key | |
payload, header = JWT.decode(token, public_key, true, verify_options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment