Example of role-based HTTP Authorization with casbin
Switch branches/tags
Nothing to show
Clone or download
Latest commit 90e0d5a Jan 5, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
authorization init Jan 5, 2018
model init Jan 5, 2018
.gitignore init Jan 5, 2018
Gopkg.lock init Jan 5, 2018
Gopkg.toml init Jan 5, 2018
LICENSE init Jan 5, 2018
README.md add readme Jan 5, 2018
auth_model.conf init Jan 5, 2018
casbin-http-role-example init Jan 5, 2018
main.go init Jan 5, 2018
policy.csv init Jan 5, 2018

README.md

casbin-http-role-exampe

Simplistic Example of role-based HTTP Authorization with casbin using scs for session handling.

Run with

dep ensure
go run main.go

Which starts a server at http://localhost:8080 with the following routes:

  • POST /login - accessible if not logged in
    • takes name as a form-data parameter - there is no password
    • Valid Users:
      • Admin ID: 1, Role: admin
      • Sabine ID: 2, Role: member
      • Sepp ID: 3, Role: member
  • POST /logout - accessible if logged in
  • GET /member/current - accessible if logged in as a member
  • GET /member/role - accessible if logged in as a member
  • GET /admin/stuff - accessible if logged in as an admin