Skip to content

About

Activity-based authorization for Ruby — one explicit decision, default-deny, no framework required. Docs: kuickr.co/stocklive/permissify-rdocs

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Permissify

Activity-based authorization for Ruby. One explicit question, a structured answer, default-deny by construction. No framework required.

Permissify.define(:article) do
  fact(:draft) { |ctx| ctx.resource.status == "draft" }
  fact(:owned) { |ctx| ctx.resource.user_id == ctx.actor.id }

  permission(:editable) { |ctx| ctx.all?(:draft, :owned) }

  action :edit, maps_to: :editable
end

decision = Permissify.decide(actor: user, action: :edit,
                             resource: article, resource_key: :article)
decision.allowed?   # => true / false
decision.reason     # => :allowed / :denied / :unknown_action / :missing_fact / ...

What it guarantees

  • Default-deny. Unknown resource, action, permission, or fact — and any evaluation error — all deny. Nothing is allowed by omission.
  • No superuser bypass. Elevated access is an ordinary named fact used inside a permission, so it is explainable and testable.
  • No magic action fallback. Action aliases are explicit and finite; there is no generated :"#{action}able".
  • Structured decisions. Every evaluation returns an immutable Decision (allowed, permission, reason, checks, metadata). Booleans are projections of it.
  • Ruby-only core. Rails and Predicate are optional adapters, loaded only when their host constants are present.

FactSource

Facts a definition does not register inline are resolved through a FactSource (fetch(name, context) → value or FactSource::Missing). A missing fact denies. Predicate integration is simply an alternative FactSource; swapping it must not change any decision.

Installation

Published on RubyGems as permissify-rb (the name permissify belongs to an unrelated gem). The library is still required as permissify.

# Gemfile
gem "permissify-rb"
require "permissify"            # core
require "permissify/rails"      # optional controller concern (auto-loaded under Rails)
require "permissify/predicate"  # optional Predicate fact source

Status

0.5.0 — the core (Registry, DSL, DecisionContext, Decision, FactSource, default-deny), database-level authorized scopes, the optional Rails controller adapter and zero-config Railtie, and the optional Predicate fact source are implemented and tested. See CHANGELOG.md.

bundle install
bundle exec rake    # boundary check, workflows, suite

Releases follow RELEASING.md.

About

Activity-based authorization for Ruby — one explicit decision, default-deny, no framework required. Docs: kuickr.co/stocklive/permissify-rdocs

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages