22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/vnetwork/core/verify_token.rb', line 22
def access_token_decode(token, publickey)
if publickey.nil?
raise StandardError, "ENV['AUTH_PUBLIC_KEY'] invalid. please set AUTH_PUBLIC_KEY in your ENV variables."
end
body = JWT.decode(token, OpenSSL::PKey::RSA.new(publickey), true, {
algorithm: ALGORITHM
})[0]
HashWithIndifferentAccess.new body
rescue JWT::ExpiredSignature
raise JWT::ExpiredSignature, 'authorization.access_token[] expired'
rescue JWT::DecodeError
raise JWT::DecodeError, 'authorization.access_token[] invalid'
rescue JWT::VerificationError
raise JWT::VerificationError, 'authorization.access_token[] failed'
end
|