diff options
Diffstat (limited to 'cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go')
m--------- | cmd/ponzu/vendor/github.com/nilslice/jwt | 0 | ||||
-rw-r--r-- | cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go | 40 |
2 files changed, 40 insertions, 0 deletions
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt b/cmd/ponzu/vendor/github.com/nilslice/jwt deleted file mode 160000 -Subproject dab3054ad0d56718877715dc429b95302cf4c7d diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go b/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go new file mode 100644 index 0000000..aa9a5c8 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go @@ -0,0 +1,40 @@ +// Package jwt provides methods to create and check JSON Web Tokens (JWT). It only implements HMAC 256 encryption and has a very small footprint, ideal for simple usage when authorizing clients +/* + + package main + + import ( + auth "github.com/nilslice/jwt" + "fmt" + "net/http" + "strings" + "time" + ) + + 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) + } +*/ +package jwt |