Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

casbin-xorm-adapter

> 数据库
Open source

Xorm adapter for Casbin

382 stars0 likes0 views
WebsiteGitHub

About

Xorm adapter for Casbin

Xorm Adapter

Xorm Adapter is the Xorm adapter for Casbin. With this library, Casbin can load policy from Xorm supported database or save policy to it.

Based on Xorm Drivers Support, The current supported databases are:

  • Mysql: github.com/go-sql-driver/mysql
  • MyMysql: github.com/ziutek/mymysql
  • Postgres: github.com/lib/pq
  • Tidb: github.com/pingcap/tidb
  • SQLite: github.com/mattn/go-sqlite3
  • MsSql: github.com/denisenkom/go-mssqldb
  • Oracle: github.com/mattn/go-oci8 (experiment)

Installation

go get github.com/apache/casbin-xorm-adapter/v3

Simple MySQL Example

…

Simple Postgres Example

…

Context Adapter

xormadapter supports adapter with context, the following is a timeout control implemented using context

go
a, _ := xormadapter.NewAdapter("mysql", "mysql_username:mysql_password@tcp(127.0.0.1:3306)/") // Your driver and data source. 
// Limited time 300s
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Microsecond)
defer cancel()
err := a.AddPolicyCtx(ctx, "p", "p", []string{"alice", "data1", "read"})
if err != nil {
    panic(err)
}

Getting Help

  • Casbin

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goaccess-controladapterauthorizationcasbin

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库