Module: TentD::API::Authorizable

Included in:
Middleware
Defined in:
lib/tentd/api/authorizable.rb

Defined Under Namespace

Classes: Error, Unauthorized

Instance Method Summary collapse

Instance Method Details

#authorize_env!(env, scope) ⇒ Object



10
11
12
13
14
# File 'lib/tentd/api/authorizable.rb', line 10

def authorize_env!(env, scope)
  unless authorize_env?(env, scope)
    raise Unauthorized
  end
end

#authorize_env?(env, scope) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/tentd/api/authorizable.rb', line 16

def authorize_env?(env, scope)
  env.authorized_scopes.to_a.include?(scope)
end