Skip to content

Commit

Permalink
[init]Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xuybin committed Dec 13, 2017
1 parent c12a2e1 commit 28b6555
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ And **go-api-gateway** provide the **swagger.json** at path **/gateway/swagger/*

Because of initialization data into **casbin_rule** table
```bash
p admin /policy/* (GET)|(POST)|(PUT)|(DELETE)
p admin /policy/* (GET)|(POST)|(PUT)|(DELETE)|(HEAD)
```
So register **admin** first to authorize the operation at **/gateway/docs/**

4 changes: 2 additions & 2 deletions enforcer/casbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func insertData(dataSourceName string) (err error) {
return err
}
defer engine.Close()
engine.Exec("DELETE FROM `"+dbName+"`.`casbin_rule` WHERE `p_type`='p' AND `v0`='admin' AND `v1`='/policy/*' AND `v2`='(GET)|(POST)|(PUT)|(DELETE)' AND `v3`IS NULL AND `v4`IS NULL AND `v5`IS NULL")
_, err = engine.Exec("INSERT INTO `"+dbName+"`.`casbin_rule`(`p_type`,`v0`,`v1`,`v2`) VALUES ('p','admin','/policy/*','(GET)|(POST)|(PUT)|(DELETE)')")
engine.Exec("DELETE FROM `"+dbName+"`.`casbin_rule` WHERE `p_type`='p' AND `v0`='admin' AND `v1`='/policy/*' AND `v2`='(GET)|(POST)|(PUT)|(DELETE)|(HEAD)' AND `v3`IS NULL AND `v4`IS NULL AND `v5`IS NULL")
_, err = engine.Exec("INSERT INTO `"+dbName+"`.`casbin_rule`(`p_type`,`v0`,`v1`,`v2`) VALUES ('p','admin','/policy/*','(GET)|(POST)|(PUT)|(DELETE)|(HEAD)')")
}else {
err=fmt.Errorf("dataSourceName:%s doesn't exist dbName",dataSourceName)
}
Expand Down

0 comments on commit 28b6555

Please sign in to comment.