How to achieve transaction consistency between Casbin policy operations and other database operations?

Open
#1,702 1 comment 2 reactions 1 assignee View on GitHub

@hsluoyz is already working on this.

Since Aug 6, 2026.

Assessment

This issue has not been assessed yet.

Description

question

Description
In our application, we need to update both business data and Casbin authorization policies atomically. For example, when changing a user's role:

Update the user's role in the business database

Update the corresponding Casbin grouping policy

Currently, these operations happen in separate transactions, risking data inconsistency if one succeeds and the other fails.

Questions:

What are the recommended patterns for ensuring transaction consistency between Casbin policies and business data?

Does Casbin provide built-in support for coordinating these operations within a single transaction?

Are there adapter-specific solutions (e.g., for Gorm, Xorm, or specific databases)?

Context:

We're using gorm-adapter

Database: PostgreSQL

Application framework: [specify framework, e.g., Go Gin, Spring Boot]

Any guidance or examples would be greatly appreciated!

Dominant language
Go
Stars
20.4k
Forks
1.8k
Avg merge
5d 11h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/casbin

All issues in apache/casbin

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.