Module: Eaco

Defined in:
lib/eaco.rb,
lib/eaco/acl.rb,
lib/eaco/dsl.rb,
lib/eaco/rake.rb,
lib/eaco/actor.rb,
lib/eaco/error.rb,
lib/eaco/railtie.rb,
lib/eaco/version.rb,
lib/eaco/adapters.rb,
lib/eaco/coverage.rb,
lib/eaco/cucumber.rb,
lib/eaco/dsl/base.rb,
lib/eaco/resource.rb,
lib/eaco/dsl/actor.rb,
lib/eaco/controller.rb,
lib/eaco/designator.rb,
lib/eaco/rake/utils.rb,
lib/eaco/dsl/resource.rb,
lib/eaco/cucumber/world.rb,
lib/eaco/rake/default_task.rb,
lib/eaco/dsl/actor/designators.rb,
lib/eaco/adapters/active_record.rb,
lib/eaco/cucumber/active_record.rb,
lib/eaco/adapters/couchrest_model.rb,
lib/eaco/dsl/resource/permissions.rb,
lib/eaco/cucumber/active_record/user.rb,
lib/eaco/cucumber/active_record/schema.rb,
lib/eaco/cucumber/active_record/document.rb,
lib/eaco/cucumber/active_record/position.rb,
lib/eaco/cucumber/active_record/department.rb,
lib/eaco/adapters/active_record/compatibility.rb,
lib/eaco/adapters/active_record/postgres_jsonb.rb,
lib/eaco/adapters/couchrest_model/couchdb_lucene.rb,
lib/eaco/cucumber/active_record/user/designators.rb,
lib/eaco/adapters/active_record/compatibility/v32.rb,
lib/eaco/adapters/active_record/compatibility/v40.rb,
lib/eaco/adapters/active_record/compatibility/v41.rb,
lib/eaco/adapters/active_record/compatibility/v42.rb,
lib/eaco/adapters/active_record/compatibility/v50.rb,
lib/eaco/adapters/active_record/compatibility/v51.rb,
lib/eaco/adapters/active_record/compatibility/scoped.rb,
lib/eaco/cucumber/active_record/user/designators/user.rb,
lib/eaco/adapters/active_record/compatibility/sanitized.rb,
lib/eaco/cucumber/active_record/user/designators/position.rb,
lib/eaco/cucumber/active_record/user/designators/department.rb,
lib/eaco/cucumber/active_record/user/designators/authenticated.rb

Overview

Welcome to Eaco!

Eaco is a full-fledged authorization framework for Ruby that allows you to describe which actions are allowed on your resources, how to identify your users as having a particular privilege and which privileges are granted to a specific resource through the usage of ACLs.

Defined Under Namespace

Modules: Actor, Adapters, Controller, Coverage, Cucumber, DSL, Rake, Resource Classes: ACL, Designator, Error, Forbidden, Malformed, Railtie

Constant Summary collapse

DEFAULT_RULES =

The location of the default rules file

Pathname('./config/authorization.rb')
VERSION =

Current version

'1.1.2'

Class Method Summary collapse

Class Method Details

.eval!(source, path) ⇒ Object

Evaluates the given authorization rules source, orignally found on path.

Parameters:

  • source (String)

    DSL source code

  • path (String)

    Source code origin, for better backtraces.

Returns:

  • true

Raises:

  • (Error)

    if something goes wrong while evaluating the DSL.

See Also:


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/eaco.rb', line 75

def self.eval!(source, path)
  DSL.send :eval, source, nil, path, 1

  true
rescue => e
  raise Error, <<-EOF

=== EACO === Error while evaluating rules

#{e.message}

 +--------- -- -
 | #{e.backtrace.join("\n | ")}
 +-

=== EACO ===

  EOF
end

.parse_default_rules_file!Object

Parses and evaluates the authorization rules from the DEFAULT_RULES.

The authorization rules define all the authorization framework behaviour through the DSL

Returns:

  • true


40
41
42
# File 'lib/eaco.rb', line 40

def self.parse_default_rules_file!
  parse_rules! DEFAULT_RULES
end

.parse_rules!(rules) ⇒ Object

Parses the given rules file.

Parameters:

  • rules (Pathname)

Returns:

  • true

Raises:

  • (Malformed)

    if the rules file does not exist.


53
54
55
56
57
58
59
60
# File 'lib/eaco.rb', line 53

def self.parse_rules!(rules)
  unless rules.exist?
    path = rules.realpath rescue rules.to_s
    raise Malformed, "Please create #{path} with Eaco authorization rules"
  end

  eval! rules.read, rules.realpath.to_s
end