Class: ShopifyApp::JWTMiddleware

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

Constant Summary collapse

TOKEN_REGEX =
/^Bearer (.+)$/
ID_TOKEN_QUERY_PARAM =
"id_token"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ JWTMiddleware

Returns a new instance of JWTMiddleware.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  return call_next(env) unless ShopifyApp.configuration.embedded_app?

  token = token_from_authorization_header(env) || token_from_query_string(env)
  return call_next(env) unless token

  set_env_variables(token, env)
  call_next(env)
end