Class: ShopifyApp::JWTMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app/middleware/jwt_middleware.rb

Constant Summary collapse

TOKEN_REGEX =
/^Bearer\s+(.*?)$/

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ JWTMiddleware

Returns a new instance of JWTMiddleware.



7
8
9
# File 'lib/shopify_app/middleware/jwt_middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/shopify_app/middleware/jwt_middleware.rb', line 11

def call(env)
  return call_next(env) unless authorization_header(env)

  token = extract_token(env)
  return call_next(env) unless token

  set_env_variables(token, env)
  call_next(env)
end