{"id":17680632,"url":"https://github.com/robacarp/authorizr","last_synced_at":"2025-06-13T16:09:38.473Z","repository":{"id":1932868,"uuid":"2861616","full_name":"robacarp/Authorizr","owner":"robacarp","description":"A barebones rails authorization library","archived":false,"fork":false,"pushed_at":"2012-01-18T22:43:47.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T19:12:22.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robacarp.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-27T16:15:48.000Z","updated_at":"2015-11-10T23:51:05.000Z","dependencies_parsed_at":"2022-09-14T13:01:45.183Z","dependency_job_id":null,"html_url":"https://github.com/robacarp/Authorizr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/robacarp/Authorizr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2FAuthorizr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2FAuthorizr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2FAuthorizr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2FAuthorizr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robacarp","download_url":"https://codeload.github.com/robacarp/Authorizr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2FAuthorizr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259677364,"owners_count":22894678,"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","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":[],"created_at":"2024-10-24T09:08:30.089Z","updated_at":"2025-06-13T16:09:38.418Z","avatar_url":"https://github.com/robacarp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"== Authorizr\nA General purpose authorization framework.\n\nNow sporting:\n\n- Controller level, block based authorization of resources and actions\n- Out of the box whitelist approach\n- Easy debugging of authorization actions with logger output\n\n== Implementing:\n\nSimply add one line to your application controller to authorize all requests for all controllers:\n\napp/controllers/application_controller.rb:\n\n    class ApplicationController \u003c ActionController::Base\n      protect_from_forgery\n      authorize_all\n    end\n\n\nThen in your controllers define an authorize block.  Simply return true if the user is authorized to view the resoure and false if not.  The block takes one parameter, the environment.\n\n=== Examples:\n\napp/controllers/posts_controller.rb:\n\n  #Example 1, deny everything always\n  authorize do |env|\n    false\n  end\n\n  #Example 2, approve everything always\n  authorize do |env|\n    true\n  end\n\n  #Example 3, approve index, show, create, new actions for everyone\n  # =\u003e        and edit, update, destroy actions for the owner\n  authorize do |env|\n    case env[:action]\n    when :index, :show, :create, :new\n      true\n    when :edit, :update, :destroy\n      post = Post.find env[:params][:id]\n      post.owner == current_user\n    else\n      false\n    end\n  end\n\n  #Example 4 [Advanced], Example 3 rewritten to use preloaded resource with user hook in place\n  authorize do |env|\n    case env[:action]\n    when :index, :show, :create, :new\n      true\n    when :edit, :update, :destroy\n      env[:resource].user == env[:user]\n    else\n      false\n    end\n  end\n\nFull detail on the environment passed into the authorize block:\n\n    env = {\n        :user =\u003e current_user,                  #nil unless ApplicationController responds to current_user\n        :action =\u003e self.action_name,            #\n        :controller =\u003e self,                    #\n        :params =\u003e params,                      #\n        :resource =\u003e resource,                  # RESTful actions will attempt to fill this with your resource\n        :model =\u003e model                         #\n    }\n\n\n== License\nThis code is released under The MIT License (MIT)\nCopyright (c) 2011 Robert L Carpenter\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobacarp%2Fauthorizr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobacarp%2Fauthorizr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobacarp%2Fauthorizr/lists"}