Created
May 12, 2019 02:30
-
-
Save rwehresmann/86b2cbb99eb9933488a018500e0ddbe2 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
| Knock.setup do |config| | |
| if Rails.env.test? | |
| config.token_secret_signature_key = -> { Rails.application.credentials.read } | |
| else | |
| config.token_audience = -> { ENV['AUTH0_AUDIENCE'] } | |
| # Auth0 uses RS256. | |
| config.token_signature_algorithm = 'RS256' | |
| # API secret from Auth0. | |
| config.token_secret_signature_key = -> { ENV['AUTH0_CLIENT_SECRET'] } | |
| # RS256 is an asymmetric algorithm, which means it requires a private and public key. | |
| jwks_raw = HTTP.get(ENV['AUTH0_RSA_DOMAIN']).body.to_s | |
| jwks_keys = Array(JSON.parse(jwks_raw)['keys']) | |
| config.token_public_key = OpenSSL::X509::Certificate.new(Base64.decode64(jwks_keys[0]['x5c'].first)).public_key | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment