Class: AuthenticJwt::Grape::Middleware

Inherits:
Grape::Middleware::Base
  • Object
show all
Defined in:
lib/authentic_jwt/grape/middleware.rb

Instance Method Summary collapse

Instance Method Details

#beforeObject

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/authentic_jwt/grape/middleware.rb', line 9

def before
  return unless scope

  raise Unauthorized, "JWT public key not present" unless public_key

  raise Unauthorized, "Authorization header not present" unless authorization_header

  raise Unauthorized, "Bearer token not present" unless bearer_token

  raise Unauthorized, "JWT payload not present" unless jwt_payload

  context.extend(AuthMethods)
  context.jwt_payload = jwt_payload

  return unless 

  raise Forbidden, "Account has no role" unless .any?

  raise Forbidden, "Account role is too low" unless (acceptable_roles & ).any?
end