diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-19 13:50:05 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-19 13:50:05 -0700 |
commit | ea078f9b4221332b9f63cc4e178aa814eec06e4f (patch) | |
tree | a90da6f77f265ce63c82da73f502f324bfb89ebc /cmd/ponzu/vendor/github.com/nilslice/jwt/README.md | |
parent | ea8ea4c22662aa082181a6c456ec56acf2bd777c (diff) |
vendoring all the dependencies into vendor directory prior to build step, which still vendors ponzu core code
Diffstat (limited to 'cmd/ponzu/vendor/github.com/nilslice/jwt/README.md')
-rw-r--r-- | cmd/ponzu/vendor/github.com/nilslice/jwt/README.md | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md b/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md new file mode 100644 index 0000000..a384dd1 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md @@ -0,0 +1,43 @@ +# JWT + +### Usage + $ go get github.com/nilslice/jwt + +package jwt provides methods to create and check JSON Web Tokens. It only implements HMAC 256 encryption and has a very small footprint, ideal for simple usage when authorizing clients + +```go + package main + + import ( + auth "github.com/nilslice/jwt" + "fmt" + "net/http" + "strings" + ) + + func main() { + http.HandleFunc("/auth/new", func(res http.ResponseWriter, req *http.Request) { + claims := map[string]interface{}{"exp": time.Now().Add(time.Hour * 24).Unix()} + token, err := auth.New(claims) + if err != nil { + http.Error(res, "Error", 500) + return + } + res.Header().Add("Authorization", "Bearer "+token) + + res.WriteHeader(http.StatusOK) + }) + + http.HandleFunc("/auth", func(res http.ResponseWriter, req *http.Request) { + userToken := strings.Split(req.Header.Get("Authorization"), " ")[1] + + if auth.Passes(userToken) { + fmt.Println("ok") + } else { + fmt.Println("no") + } + }) + + http.ListenAndServe(":8080", nil) + } +``` |