Class: TentD::API::Authorization

Inherits:
Middleware show all
Defined in:
lib/tentd/api/authorization.rb

Instance Method Summary collapse

Methods inherited from Middleware

#call, #initialize

Methods included from Authorizable

#authorize_env!, #authorize_env?

Constructor Details

This class inherits a constructor from TentD::API::Middleware

Instance Method Details

#action(env) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/tentd/api/authorization.rb', line 4

def action(env)
  env.authorized_scopes = []
  if env.current_auth.kind_of?(Model::AppAuthorization)
    env.authorized_scopes = env.current_auth.scopes.map(&:to_sym)
    env.authorized_scopes.delete(:read_secrets) unless env.params && env.params.secrets.to_s == 'true'
  end
  env
end