Simplistic Example of role-based HTTP Authorization with casbin using scs for session handling.
Run with
dep ensure
go run main.goWhich starts a server at http://localhost:8080 with the following routes:
POST /login- accessible if not logged in- takes
nameas a form-data parameter - there is no password - Valid Users:
AdminID:1, Role:adminSabineID:2, Role:memberSeppID:3, Role:member
- takes
POST /logout- accessible if logged inGET /member/current- accessible if logged in as a memberGET /member/role- accessible if logged in as a memberGET /admin/stuff- accessible if logged in as an admin