Comments (3)
@kuchaguangjie see: https://github.com/casbin/casdoor#config
Casdoor uses XORM to connect to DB, so all DBs supported by XORM can also be used.
XORM supports a lot of DBs including PostgreSQL: https://gitea.com/xorm/xorm#drivers-support
from casdoor.
It does support pg, but require some modification to work, since the code include some mysql specific config.
The changes I made to make it work with postgresql:
1. Create db by hand.
2. Edit conf/app.conf
dataSourceName
Change:dataSourceName = "user=postgres password=xxxxxx host=127.0.0.1 port=5432 dbname=casdoor sslmode=disable"
3. Edit object/adapter.go
-
In
InitAdapter()
Change:adapter = NewAdapter("postgres", beego.AppConfig.String("dataSourceName"))
-
In
open()
Remove:if err := a.createDatabase(); err != nil {
panic(err)
}Change:
engine, err := xorm.NewEngine(a.driverName, a.dataSourceName)`
4. Edit authz/authz.go
- In
InitAuthz()
Change:a, err := xormadapter.NewAdapter("postgres", beego.AppConfig.String("dataSourceName"), true)
Then it will able to start.
BTW, I think the code could be refactored to support various db without changes. As you mentioned, it use XORM, and the dataSourceName
config is for github.com/casbin/xorm-adapter/v2
.
from casdoor.
@kuchaguangjie thanks!
@kininaru plz modify the code to support both MySQL and PG without any code changes.
from casdoor.
Related Issues (20)
- [feature] support checking whether send-webhook API has error HOT 1
- After the /api/logout interface is invoked, casdoor is still logged in HOT 2
- Bug in sync database HOT 5
- StaticFilter doesn't 404 properly HOT 4
- face authentication without typing in the username HOT 5
- WeCom Login URL Need update HOT 2
- Login field is case sensitive and untrimmed HOT 2
- Where is the definition of "POST /api/enforce"? HOT 3
- Bug in sync DB HOT 3
- Update user address failed HOT 3
- [feature] support label text customization for signin items HOT 1
- is "api/api/swagger.json " a valid rest call? HOT 2
- Obtain the access_token based on the code HOT 1
- How to enable TOTP for a user? HOT 4
- [feature] support subpath deployment for Casdoor HOT 1
- [feature] get phone number and country from Google OAuth provider HOT 1
- PostgreSQL database name error HOT 4
- Email Regex Validation Issue in Signup Process HOT 1
- [feature] Add refund option for products HOT 4
- [Bug] QQ login on Android failed due to the missing 'state' parameter HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casdoor.