Skip to content

feat: add LoadPolicy API to load policies from database on startup#59

Merged
hsluoyz merged 5 commits intomasterfrom
copilot/add-policy-auto-load
Feb 12, 2026
Merged

feat: add LoadPolicy API to load policies from database on startup#59
hsluoyz merged 5 commits intomasterfrom
copilot/add-policy-auto-load

Conversation

Copy link
Contributor

Copilot AI commented Jan 1, 2026

fix: #30

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nomeguy nomeguy marked this pull request as ready for review January 1, 2026 13:35
Copilot AI and others added 3 commits January 1, 2026 13:40
- Add EnforcerServer.load_policies/1 to load from configured adapter
- Add EnforcerServer.load_mapping_policies/1 to load mapping policies from adapter
- Add corresponding GenServer handlers
- Create comprehensive test suite for new functionality
- Maintain backward compatibility with file-based loading (load_policies/2)
- Add documentation and examples

Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
- Add "Persisting Policies to Database with EctoAdapter" section
- Document database setup and migration
- Show how to load policies from database on startup
- Demonstrate auto-persist behavior
- Provide production application startup pattern
- Include examples for both ACL and RBAC models

Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
- Add transaction/1 support to MockRepo
- Enables save_policies testing which uses transactions
- Supports both 0-arity and 1-arity transaction functions

Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add auto-load functionality for policies in EctoAdapter Add LoadPolicy API to load policies from database on startup Jan 1, 2026
Copilot AI requested a review from nomeguy January 1, 2026 13:48
@sushilbansal
Copy link

@nomeguy @hsluoyz can this be corrected and merged please? Thanks in advance.

@hsluoyz
Copy link
Member

hsluoyz commented Feb 12, 2026

@copilot fix:

Run mix format --check-formatted
  mix format --check-formatted
  shell: /usr/bin/bash -e {0}
  env:
    INSTALL_DIR_FOR_OTP: /home/runner/work/_temp/.setup-beam/otp
    INSTALL_DIR_FOR_ELIXIR: /home/runner/work/_temp/.setup-beam/elixir
** (Mix) mix format failed due to --check-formatted.
The following files are not formatted:

  * test/persist/ecto_server_load_test.exs
  *

- Run mix format on test/persist/ecto_server_load_test.exs
- Remove trailing whitespace to comply with Elixir formatting standards
- Fixes CI build failure from mix format --check-formatted

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 12, 2026

@copilot fix:

...

Fixed in commit 3825d72. Ran mix format on the test file to remove trailing whitespace and comply with Elixir formatting standards.

Copilot AI requested a review from hsluoyz February 12, 2026 09:16
@hsluoyz hsluoyz changed the title Add LoadPolicy API to load policies from database on startup feat: add LoadPolicy API to load policies from database on startup Feb 12, 2026
@hsluoyz hsluoyz merged commit c506f69 into master Feb 12, 2026
2 of 3 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.13.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EctoAdapter: No Built-in Way to Load Policies from Database on Startup

5 participants