https://github.com/gobricks/ginyourface
Gin middleware for Facecontrol
https://github.com/gobricks/ginyourface
Last synced: 5 months ago
JSON representation
Gin middleware for Facecontrol
- Host: GitHub
- URL: https://github.com/gobricks/ginyourface
- Owner: gobricks
- License: mit
- Created: 2016-05-16T17:18:32.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-16T17:27:33.000Z (about 10 years ago)
- Last Synced: 2024-06-20T12:37:56.748Z (almost 2 years ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/gobricks/ginyourface)
[](https://goreportcard.com/report/github.com/gobricks/ginyourface)
# ginyourface
[Gin](https://github.com/gin-gonic/gin) middleware for [facecontrol](https://github.com/gobricks/facecontrol).
# Basic example
Create file `main.go` and paste the following code into it:
``` go
package main
import (
"github.com/gin-gonic/gin"
"github.com/gobricks/ginyourface"
)
func main() {
r := gin.New()
// now every request will be validated through Facecontrol service
// and userPayload will be returned if user has valid token
r.Use(ginyourface.Facecontrol())
r.GET("/personal", func(c *gin.Context) {
userData := c.MustGet("userPayload").(interface{})
c.String(http.StatusOK, "Hello %s", userData["username"])
})
r.Run(":8080")
}
```
# Build and run
```
$ go build main.go
$ FC_HOST="https://facecontrol.mysite.com" FC_LOGIN_PAGE="https://login.mysite.com" FC_SESSION_COOKIE="sessid" ./main
```