Class: Soar::Policy::AccessManager::ModelProvider::Stub
- Inherits:
-
Object
- Object
- Soar::Policy::AccessManager::ModelProvider::Stub
- Includes:
- Jsender
- Defined in:
- lib/soar/policy/access_manager/model_provider/stub.rb
Instance Method Summary collapse
-
#authorized?(service_identifier, resource_identifier, request) ⇒ Hash
A jsend hash.
-
#initialize(meta: {}, policies: {}) ⇒ Stub
constructor
A new instance of Stub.
Constructor Details
#initialize(meta: {}, policies: {}) ⇒ Stub
Returns a new instance of Stub.
15 16 17 18 |
# File 'lib/soar/policy/access_manager/model_provider/stub.rb', line 15 def initialize(meta: {}, policies: {}) @meta = @policies = policies end |
Instance Method Details
#authorized?(service_identifier, resource_identifier, request) ⇒ Hash
Returns a jsend hash.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/soar/policy/access_manager/model_provider/stub.rb', line 26 def (service_identifier, resource_identifier, request) notifications = [] decision = false begin if ENV['RACK_ENV'] == 'development' notifications << 'Authorized in development environment' decision = true end = (service_identifier) policy = ['policy'] if and .is_a?(Hash) and ['policy'] if policy.nil? decision = true notifications << 'No policy associated with service' else decision, detail = ask_policy(policy, request[:authentication_identifier], service_identifier, resource_identifier, request) notifications.concat(detail) if not detail.empty? notifications << 'Policy rejected authorization request' if not decision notifications << 'Policy approved authorization request' if decision end rescue SoarSr::ValidationError => ex notifications << "AccessManager error authorizing #{service_identifier} for #{resource_identifier}: #{ex.}" decision = false rescue Exception => ex notifications << "AccessManager error authorizing #{service_identifier} for #{resource_identifier}: #{ex.}" decision = false end success(notifications, { 'approved' => decision } ) end |