{"id":20513662,"url":"https://github.com/theopencms/active_permits","last_synced_at":"2026-04-17T22:31:17.527Z","repository":{"id":71919592,"uuid":"89841626","full_name":"TheOpenCMS/active_permits","owner":"TheOpenCMS","description":"Acts as Active Permissions. Common Authorization Solution","archived":false,"fork":false,"pushed_at":"2017-10-01T15:54:49.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T23:14:14.538Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheOpenCMS.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-30T09:27:35.000Z","updated_at":"2017-07-01T11:00:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"66b17bf1-a4d5-4cec-a999-8213bf1f5318","html_url":"https://github.com/TheOpenCMS/active_permits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheOpenCMS/active_permits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Factive_permits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Factive_permits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Factive_permits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Factive_permits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheOpenCMS","download_url":"https://codeload.github.com/TheOpenCMS/active_permits/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Factive_permits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31948369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-15T21:12:28.210Z","updated_at":"2026-04-17T22:31:17.500Z","avatar_url":"https://github.com/TheOpenCMS.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActivePermits\n\nThe Authorization Solution for TheOpenCMS\n\n### Application controller\n\nClose everything!\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  include ::ActivePermits::Controller\n  rescue_from ::ActivePermits::AuthorizationException, with: :access_denied\n\n  protect_from_forgery with: :exception\n\n  before_action :authenticate_user!, if: :needs_authorization?\n  before_action :authorize_action!,  if: :needs_authorization?\n  before_action :set_resource!,      if: :needs_authorization?\n  before_action :authorize_owner!,   if: :needs_authorization?\n\n  private\n\n  def needs_authorization?\n    !devise_controller?\n  end\n\n  def access_denied\n    redirect_back fallback_location: authorize_fallback_location,\n      flash: {error: t('active_permits.access_denied')}\n  end\n```\n\n### A Controller. Open only permitted actions!\n\n```ruby\nclass UsersController \u003c ApplicationController\n  authorize_resource_name :user\n\n  skip_before_action :authenticate_user!, if: :skip_authenticate_user?\n  skip_before_action :authorize_action!,  if: :skip_authorize_action?\n  skip_before_action :set_resource!,      if: :skip_set_resource?\n  skip_before_action :authorize_owner!,   if: :skip_authorize_owner?\n\n  private\n\n  def set_resource!\n    user_id = params[:id] || params[:user_id]\n    @user = ::User.where(login: user_id).first\n  end\n\n  protected\n\n  def skip_authenticate_user?\n    %w[index show].include?(action_name)\n  end\n\n  def skip_authorize_action?\n    %w[index show edit update].include?(action_name)\n  end\n\n  def skip_set_resource?\n    %w[index profile].include?(action_name)\n  end\n\n  def skip_authorize_owner?\n    %w[index show profile].include?(action_name)\n  end\nend\n```\n\n### Remove `Strong Parameters` code from Controllers\n\nUse `permitted_params`\n\n```ruby\nclass UsersController \u003c ApplicationController\n  def update\n    if @user.update(permitted_params)\n      redirect_to @user, notice: 'User was updated'\n    else\n      render 'users/edit'\n    end\n  end\nend\n```\n\n**app/permissions/params/users_controller/update_action.rb**\n\n```ruby\nclass UsersController::UpdateAction \u003c ActivePermits::PermittedParams::Base\n  def permitted_params\n    if @controller.current_user.admin?\n      @params.require(:user).permit!\n    else\n      @params.require(:user).permit(:login, :username, :email)\n    end\n  end\nend\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheopencms%2Factive_permits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheopencms%2Factive_permits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheopencms%2Factive_permits/lists"}