Module: Devise::Auth0::Helpers

Defined in:
lib/devise/auth0/helpers.rb

Overview

Helpers to parse token from a request and to a response

Constant Summary collapse

AUTH_METHOD =
"Bearer"

Class Method Summary collapse

Class Method Details

.get_auth(env) ⇒ String?

Parses the token from a rack request

Parameters:

  • env (Hash)

    rack env hash

Returns:

  • (String)

    JWT token

  • (nil)

    if token is not present



15
16
17
18
19
20
21
# File 'lib/devise/auth0/helpers.rb', line 15

def get_auth(env)
  auth = env["HTTP_AUTHORIZATION"].presence
  return unless auth

  method, token = auth.split
  method == AUTH_METHOD ? token : nil
end