{"id":25437143,"url":"https://github.com/ka8725/grut","last_synced_at":"2026-05-01T19:32:07.507Z","repository":{"id":144738722,"uuid":"89747484","full_name":"ka8725/grut","owner":"ka8725","description":"Flexible authorization solution for Ruby projects.","archived":false,"fork":false,"pushed_at":"2017-09-25T22:04:14.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-15T04:11:26.298Z","etag":null,"topics":["authorization","persistent","ruby","ruby-on-rails"],"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/ka8725.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-28T21:53:54.000Z","updated_at":"2023-05-31T19:14:38.000Z","dependencies_parsed_at":"2023-05-04T22:27:38.537Z","dependency_job_id":null,"html_url":"https://github.com/ka8725/grut","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ka8725/grut","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ka8725%2Fgrut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ka8725%2Fgrut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ka8725%2Fgrut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ka8725%2Fgrut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ka8725","download_url":"https://codeload.github.com/ka8725/grut/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ka8725%2Fgrut/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32510655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["authorization","persistent","ruby","ruby-on-rails"],"created_at":"2025-02-17T08:32:47.009Z","updated_at":"2026-05-01T19:32:07.488Z","avatar_url":"https://github.com/ka8725.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grut\n\nDefine user permissions in a Ruby project dynamically and store them in a database with Grut's help.\nThis allows to manage access to specific entities for concrete users on the fly through a user interface.\n\n## Installation\n\nGrut requires already installed any of the database adapters supported by [sequel](https://github.com/jeremyevans/sequel). `pg` and `mysql2` are the most popular ones.\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'grut'\n```\n\nConfigure the database connection after that in some place of the project that have Grut installed. For example, it could be the following line in the `config/application.rb` of a Rails project:\n\n```ruby\nGrut::Config.instance.db_url = 'postgres://username:password@localhost/my_project_dev'\n```\n\n\u003e It's assumed that in that case there will be used `pg` gem and there will be created `my_project_dev` database\n\u003e and the `username` user with the `password` password has access to that database.\n\nAnd run migrations:\n\n```\nrake grut:install\n```\n\n## Usage\n\nThere are two main classes: `Grut::Guardian` and `Grut::Statement`. Use `Grut::Guardian` to manage control\naccess for entries and `Grut::Statement` to get information about defined permissions for a given user.\nLook into the following code snippet that demonstrates their usage:\n\n```ruby\nuser = Struct.new(:id).new(42)\nstore = Struct.new(:id).new(12)\n\nguardian = Grut::Guardian.new(user, :admin)\nstatement = Grut::Statement.new(user)\n\nguardian.permitted?(:manage_store, all: true) # =\u003e false\nguardian.permitted?(:manage_store, id: store.id) # =\u003e false\nstatement.all #=\u003e []\n\nguardian.permit(:manage_store, all: true)\nguardian.permitted?(:manage_store, all: true) # =\u003e true\nguardian.permitted?(:manage_store, id: store.id) # =\u003e true\nstatement.all #=\u003e [#\u003cstruct Grut::Statement::Entry role=\"admin\", permission=\"manage_store\", contract_key=\"all\", contract_value=\"true\"\u003e]\n\nguardian.forbid(:manage_store, all: true)\nguardian.permitted?(:manage_store, all: true) # =\u003e false\nguardian.permitted?(:manage_store, id: store.id) # =\u003e false\nstatement.all #=\u003e []\n\nguardian.permit(:manage_store, id: 1)\nguardian.permitted?(:manage_store, all: true) # =\u003e true\nguardian.permitted?(:manage_store, id: store.id) # =\u003e true\nstatement.all #=\u003e [#\u003cstruct Grut::Statement::Entry role=\"admin\", permission=\"manage_store\", contract_key=\"id\", contract_value=\"1\"\u003e]\n```\n\n## Development\n\nInstall PostgreSQL and add the following user with password:\n\n```ruby\ncreateuser -l -s grut\npsql -d postgres -c \"alter user grut with password 'password';\"\n```\n\nRun `bin/setup` to install dependencies. Then, run `rake test` 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/ka8725/grut. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fka8725%2Fgrut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fka8725%2Fgrut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fka8725%2Fgrut/lists"}