Initial commit

This commit is contained in:
Yaser
2026-08-13 19:56:46 +03:30
commit de1d57a67b
474 changed files with 43185 additions and 0 deletions

34
lib/barong/auth0/jwt.rb Normal file
View File

@@ -0,0 +1,34 @@
# frozen_string_literal: true
module Barong
module Auth0
class JWT
def self.verify(token)
::JWT.decode(token,
nil,
true, # Verify the signature of this token
algorithms: 'RS256',
iss: "https://#{Barong::App.config.auth0_domain}/",
verify_iss: true,
aud: Barong::App.config.auth0_client_id,
verify_aud: true
) do |header|
jwks_hash[header['kid']]
end
end
def self.jwks_hash
uri = "https://#{Barong::App.config.auth0_domain}/.well-known/jwks.json"
jwks_raw = Net::HTTP.get URI(uri)
jwks_keys = Array(JSON.parse(jwks_raw)['keys'])
Hash[jwks_keys.map do |k|
[
k['kid'],
OpenSSL::X509::Certificate.new(Base64.decode64(k['x5c'].first)).public_key
]
end
]
end
end
end
end