1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

add a jwt tutorial + go client

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-11-04 21:12:13 +02:00
parent ed38047385
commit 579c3878f0
22 changed files with 818 additions and 163 deletions

View File

@@ -80,6 +80,13 @@ type Verifier struct {
// Get the context user:
// username, err := ctx.User().GetUsername()
func NewVerifier(signatureAlg Alg, signatureKey interface{}, validators ...TokenValidator) *Verifier {
if signatureAlg == HS256 {
// A tiny helper if the end-developer uses string instead of []byte for hmac keys.
if k, ok := signatureKey.(string); ok {
signatureKey = []byte(k)
}
}
return &Verifier{
Alg: signatureAlg,
Key: signatureKey,