apache / apache/casbin

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

Open
#1,702 1 comment 2 reactions 1 assignee Claimed by @hsluoyz View on GitHub
question
Dominant language
Go
Stars
20.4k
Forks
1.8k
Avg merge
5d 11h
Merged PRs (30d)
2

Description

**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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.