Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
C
casbin-pg-adapter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abby Cin
casbin-pg-adapter
Commits
3261f2b6
Commit
3261f2b6
authored
Dec 28, 2019
by
khoipham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add travis yaml
parent
38a27228
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
16 deletions
+19
-16
.travis.yml
.travis.yml
+9
-0
README.md
README.md
+6
-10
docker-compose.yml
docker-compose.yml
+1
-1
go.mod
go.mod
+1
-1
main.go
pgexample/main.go
+2
-4
No files found.
.travis.yml
0 → 100644
View file @
3261f2b6
language
:
go
go
:
-
1.12.x
-
1.13.x
env
:
-
PG_CONN=postgresql://postgres:@localhost:5432/postgres?sslmode=disable
services
:
-
postgresql
scripts
:
go test github.com/casbin/casbin-pg-adapter
README.md
View file @
3261f2b6
...
...
@@ -4,7 +4,7 @@ Go-pg Adapter is the [Go-pg](https://github.com/go-pg/pg) adapter for [Casbin](h
## Installation
go get github.com/
pckhoi
/casbin-pg-adapter
go get github.com/
casbin
/casbin-pg-adapter
## Simple Postgres Example
...
...
@@ -12,9 +12,7 @@ Go-pg Adapter is the [Go-pg](https://github.com/go-pg/pg) adapter for [Casbin](h
package
main
import
(
"os"
pgadapter
"github.com/pckhoi/casbin-pg-adapter"
pgadapter
"github.com/casbin/casbin-pg-adapter"
"github.com/casbin/casbin/v2"
)
...
...
@@ -22,7 +20,7 @@ func main() {
// Initialize a Go-pg adapter and use it in a Casbin enforcer:
// The adapter will use the Postgres database named "casbin".
// If it doesn't exist, the adapter will create it automatically.
a
,
_
:=
pgadapter
.
NewAdapter
(
os
.
Getenv
(
"PG_CONN"
)
)
// Your driver and data source.
a
,
_
:=
pgadapter
.
NewAdapter
(
"postgresql://username:password@postgres:5432/database?sslmode=disable"
)
// Your driver and data source.
// Alternatively, you can construct an adapter instance with *pg.Options:
// a, _ := pgadapter.NewAdapter(&pg.Options{
// Database: "...",
...
...
@@ -59,14 +57,12 @@ You can [load a subset of policies](https://casbin.org/docs/en/policy-subset-loa
package
main
import
(
"os"
"github.com/casbin/casbin/v2"
pgadapter
"github.com/
pckhoi
/casbin-pg-adapter"
pgadapter
"github.com/
casbin
/casbin-pg-adapter"
)
func
main
()
{
a
,
_
:=
pgadapter
.
NewAdapter
(
os
.
Getenv
(
"PG_CONN"
)
)
a
,
_
:=
pgadapter
.
NewAdapter
(
"postgresql://username:password@postgres:5432/database?sslmode=disable"
)
e
,
_
:=
casbin
.
NewEnforcer
(
"examples/rbac_model.conf"
,
a
)
e
.
LoadFilteredPolicy
(
&
pgadapter
.
Filter
{
...
...
@@ -83,7 +79,7 @@ func main() {
## Debug tests
docker-compose run --rm go dlv test github.com/
pckhoi
/casbin-pg-adapter
docker-compose run --rm go dlv test github.com/
casbin
/casbin-pg-adapter
## Getting Help
...
...
docker-compose.yml
View file @
3261f2b6
...
...
@@ -22,7 +22,7 @@ services:
command
:
-
go
-
test
-
github.com/
pckhoi
/casbin-pg-adapter
-
github.com/
casbin
/casbin-pg-adapter
volumes
:
gopkg
:
go.mod
View file @
3261f2b6
module github.com/
pckhoi
/casbin-pg-adapter
module github.com/
casbin
/casbin-pg-adapter
go 1.12
...
...
pgexample/main.go
View file @
3261f2b6
package
main
import
(
"os"
pgadapter
"github.com/casbin/casbin-pg-adapter"
"github.com/casbin/casbin/v2"
pgadapter
"github.com/pckhoi/casbin-pg-adapter"
)
func
main
()
{
// Initialize a Go-pg adapter and use it in a Casbin enforcer:
// The adapter will use the Postgres database named "casbin".
// If it doesn't exist, the adapter will create it automatically.
a
,
_
:=
pgadapter
.
NewAdapter
(
os
.
Getenv
(
"PG_CONN"
)
)
// Your driver and data source.
a
,
_
:=
pgadapter
.
NewAdapter
(
"postgresql://postgres:password@postgres:5432/postgres?sslmode=disable"
)
// Your driver and data source.
// Alternatively, you can construct an adapter instance with *pg.Options:
// a, _ := pgadapter.NewAdapter(&pg.Options{
// Database: "...",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment