{"id":20292066,"url":"https://github.com/apsislabs/papers_please","last_synced_at":"2026-05-19T14:38:14.706Z","repository":{"id":78419736,"uuid":"141667991","full_name":"apsislabs/papers_please","owner":"apsislabs","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-17T23:19:49.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-04T05:12:31.158Z","etag":null,"topics":["gem","permissions","rails","roles","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apsislabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-20T05:36:41.000Z","updated_at":"2023-07-03T14:03:01.000Z","dependencies_parsed_at":"2023-11-18T00:55:20.059Z","dependency_job_id":"88b19080-331d-4495-8ea2-d1367aab56ab","html_url":"https://github.com/apsislabs/papers_please","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/apsislabs/papers_please","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsislabs%2Fpapers_please","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsislabs%2Fpapers_please/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsislabs%2Fpapers_please/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsislabs%2Fpapers_please/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apsislabs","download_url":"https://codeload.github.com/apsislabs/papers_please/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsislabs%2Fpapers_please/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273220199,"owners_count":25066333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","permissions","rails","roles","ruby"],"created_at":"2024-11-14T15:15:17.707Z","updated_at":"2026-05-19T14:38:09.681Z","avatar_url":"https://github.com/apsislabs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# papers_please\n\nA roles and permissions gem from Apsis Labs.\n\n**NOTE**: Still under heavy development, definitely not suitable for anything remotely resembling production usage. Very unlikely to even work.\n\n\n## Example\n\n```ruby\n# app/policies/access_policy.rb\nclass AccessPolicy \u003c PapersPlease::Policy\n  def configure\n    # Define your roles\n    role :super, (proc { |u| u.super? })\n    role :admin, (proc { |u| u.admin? })\n    role :member, (proc { |u| u.member? })\n    role :guest\n\n    permit :super do |role|\n      role.grant [:manage], User\n    end\n\n    permit :admin, :super do |role|\n      role.grant [:manage, :archive], Post\n    end\n\n    permit :member do |role|\n      role.grant [:create], Post\n      role.grant [:update, :read], Post, query: (proc { |u| u.posts })\n      role.grant [:archive], Post, query: (proc { |u| u.posts }), predicate: (proc { |u, post| !post.archived? })\n    end\n\n    permit :guest do |role|\n      role.grant [:read], Post, predicate: (proc { |u, post| !post.archived? })\n    end\n\n    permit :member, :guest do |role|\n      role.grant [:read], Attachment, granted_by: [Post, (proc { |u, attachment| attachment.post })]\n    end\n  end\nend\n\n# app/controllers/posts_controller.rb\nclass PostsController \u003c ApplicationController\n  # GET /posts\n  def index\n    @posts = policy.query(:read, Post)\n    render json: @posts\n  end\n\n  # GET /posts/:id\n  def show\n    @post = Post.find(params[:id])\n    policy.authorize! :read, @post\n\n    render json: @post\n  end\n\n  # POST /posts/:id/archive\n  def archive\n    @post = Post.find(params[:id])\n    policy.authorize! :archive, @post\n\n    @post.update!(archived: true)\n    render json: @post\n  end\nend\n\nclass AttachmentsController \u003c ApplicationController\n  # GET /attachments/:id\n  def show\n    @attachment = Attachment.find([:id])\n    policy.authorize! :read, @attachment # =\u003e proxied to Post permission check\n\n    send_data @attachment.data, type: @attachment.content_type\n  end\nend\n```\n\n## A helpful CLI\n\n```bash\n$ rails papers_please:roles\n\n# =\u003e\n# +---------+------------+------------+------------+----------------+-------------------+\n# | role    | subject    | permission | has query? | has predicate? | granted by other? |\n# +---------+------------+------------+------------+----------------+-------------------+\n# | admin   | Post       | create     | yes        | yes            | no                |\n# |         | Post       | read       | yes        | yes            | no                |\n# |         | Post       | update     | yes        | yes            | no                |\n# |         | Post       | destroy    | yes        | yes            | no                |\n# |         | Attachment | create     | yes        | yes            | no                |\n# |         | Attachment | read       | yes        | yes            | no                |\n# |         | Attachment | update     | yes        | yes            | no                |\n# |         | Attachment | destroy    | yes        | yes            | no                |\n# +---------+------------+------------+------------+----------------+-------------------+\n# | manager | Post       | create     | yes        | yes            | no                |\n# |         | Post       | read       | yes        | yes            | no                |\n# |         | Post       | update     | yes        | yes            | no                |\n# |         | Post       | destroy    | yes        | yes            | no                |\n# |         | Attachment | create     | yes        | yes            | yes               |\n# |         | Attachment | read       | yes        | yes            | yes               |\n# |         | Attachment | update     | yes        | yes            | yes               |\n# |         | Attachment | destroy    | yes        | yes            | yes               |\n# +---------+------------+------------+------------+----------------+-------------------+\n# | member  | Post       | create     | yes        | yes            | no                |\n# |         | Post       | read       | yes        | yes            | no                |\n# |         | Post       | update     | yes        | yes            | no                |\n# |         | Attachment | create     | yes        | yes            | yes               |\n# |         | Attachment | read       | yes        | yes            | yes               |\n# |         | Attachment | update     | yes        | yes            | yes               |\n# +---------+------------+------------+------------+----------------+-------------------+\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'papers_please'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install papers_please\n\n## Usage\n\nTODO: Write usage instructions here\n\n## Theory\n\nThe structure of `papers_please` is very simple. At its core, it is a mechanism for storing and retrieving `Procs`. In an authorization context, these `Procs` answer two questions:\n\n1.  Given a specific user and a specific permission, which objects am I allowed to operate on?\n2.  Given a specific user and a specific object, do I have a specific permission?\n\nThe machinery of `papers_please` tries to simplify the organization and subsequent access to these questions as much as possible.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wkirby/papers_please.\n\n## Special Thanks\n\nThis owes its existence to [`AccessGranted`](https://github.com/chaps-io/access-granted). Thanks!\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n---\n\n# Built by Apsis\n\n[![apsis](https://s3-us-west-2.amazonaws.com/apsiscdn/apsis.png)](https://www.apsis.io)\n\n`papers_please` was built by Apsis Labs. We love sharing what we build! Check out our [other libraries on Github](https://github.com/apsislabs), and if you like our work you can [hire us](https://www.apsis.io/work-with-us/) to build your vision.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsislabs%2Fpapers_please","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapsislabs%2Fpapers_please","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsislabs%2Fpapers_please/lists"}