Skip to content

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

@hongliangyv

Description

@hongliangyv

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!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions