GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Introduce ActionPolicy authorization adapter by amkisko · Pull Request #8708 · activeadmin/activeadmin

Conversation

@amkisko

@amkisko amkisko commented May 2, 2025

Copy link
Copy Markdown

This PR introduces a new ActiveAdmin::ActionPolicyAdapter to enable integration with the Action Policy authorization framework. The adapter implements both #authorized? and #scope_collection methods, mapping ActiveAdmin’s internal permissions to Action Policy’s rules and scopes.

ActiveAdmin supports a pluggable authorization system, but out of the box, it only provides adapters for popular frameworks like Pundit and CanCanCan. As more teams adopt Action Policy for its performance, flexibility, and first-class Rails support, it’s increasingly desirable to make ActiveAdmin compatible with it out of the box.

References:

  • https://gist.github.com/amkisko/c704c1a6462d573dfa4820ae07d807a6
  • https://actionpolicy.evilmartians.io

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danishsatkut reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
amkisko added 2 commits April 28, 2025 15:45
@amkisko
Introduce ActiveAdmin::ActionPolicyAdapter
f719294
References:
- https://gist.github.com/amkisko/c704c1a6462d573dfa4820ae07d807a6
- actionpolicy.evilmartians.io
@amkisko
Add ActionPolicy support
2719789
This commit introduces the ActionPolicy adapter for ActiveAdmin, allowing for flexible authorization management. The ActionPolicy gem is added to the Gemfile, and relevant documentation is updated to guide users on configuring the adapter. Additionally, new policy templates are included to demonstrate usage.

Ref: https://actionpolicy.evilmartians.io
@amkisko

amkisko commented May 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

@tagliala @javierjulio Hey! Here's better PR for review and discussion.

There is one critical thing to figure out is how to organize test templates as they are intersecting with Pundit. I suggested the option, but really I don't like it at this point, but it should work. Also I could not figure out yet what is missing on my machine for running rspec, tests are not checked.

And sure before merging squashing required (so that you can edit commit message to the preferred format) or I can recreate it again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@amkisko
amkisko marked this pull request as draft May 2, 2025 09:35
tagliala
tagliala reviewed May 2, 2025
View reviewed changes

@tagliala tagliala left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Thanks for this PR.

Also I could not figure out yet what is missing on my machine for running rspec, tests are not checked.

Maybe something related to bundler? I've seen the removal of ruby, so I guess that build native extensions is somehow not working.

Run specs with just CI=1 rake, that will create the test app and proceed with all the specs

First comments:

  1. Rebase from baster
  2. Remove the change in the comment
  3. Please make sure that specs and linters pass locally
313 files inspected, 17 offenses detected, 17 offenses autocorrectable

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

amkisko reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread gemfiles/rails_71/Gemfile.lock Outdated

PLATFORMS
arm64-darwin
ruby

@tagliala tagliala May 2, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this change

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@amkisko amkisko May 2, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw this one, it was automatically modified by bundler locally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
amkisko added 4 commits December 18, 2025 11:14
@amkisko
Merge branch 'master' of https://github.com/activeadmin/activeadmin i…
2e2c1be
…nto patch/action-policy-adapter
@amkisko
Update Gemfile and Gemfile.lock for sqlite3 and action_policy versions
0229d02
- Removed platform specification for sqlite3 in multiple Gemfiles.
- Updated action_policy version from 0.7.4 to 0.7.5 in Gemfile.lock across all Rails versions.
- Adjusted Bundler version in Gemfile.lock to 2.7.2.

These changes ensure compatibility and streamline the dependency management.
@amkisko
Enhance ActionPolicyAdapter with improved policy handling and error m…
7e51960
…anagement

- Added frozen string literal to improve performance.
- Refactored `authorized?` and `scope_collection` methods for better clarity and functionality.
- Improved error handling in `retrieve_policy` to provide more informative messages.
- Updated tests to reflect changes in policy initialization and scoping behavior.
- Added frozen string literal to user policy template for consistency.

These changes enhance the robustness and maintainability of the ActionPolicyAdapter.
@amkisko
Refactor ActionPolicyAdapter tests for clarity and error handling
ea1d31e
- Updated the test for differentiating between `:new` and `:create` abilities to improve clarity.
- Added tests to ensure proper authorization behavior for new post instances.
- Introduced a context to handle cases where the default policy does not exist, ensuring appropriate error handling.

These changes enhance the robustness of the ActionPolicyAdapter tests and improve error management.
@amkisko
amkisko marked this pull request as ready for review December 18, 2025 13:06
amkisko added 4 commits March 4, 2026 14:50
@amkisko
Handle ActiveRecord::Relation in policy_target method
936d40c
@amkisko
Fix issue fetching policy correctly
f8387ed
This bug was quite invisible and affected all scopes as normally non-administrator users do not have access to ActiveAdmin and the area assumed to be safe.
@amkisko
Make scope_collection logic stricter to always call ActionPolicy method
57a62e3
@amkisko
Merge branch 'master' of https://github.com/activeadmin/activeadmin i…
94cd0ed
…nto patch/action-policy-adapter

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tagliala tagliala tagliala left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@amkisko @tagliala
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.