Skip to content

Commit 3debfdc

Browse files
caljCamille
authored andcommitted
Expose email, referral_id from the JWT
1 parent 1aecb9a commit 3debfdc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/auth/jwt.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import (
99
"github.com/dgrijalva/jwt-go"
1010
)
1111

12-
// Auth struct represnets parsed jwt information.
12+
// Auth struct represents parsed jwt information.
1313
type Auth struct {
14-
UID string `json:"uid"`
15-
Role string `json:"role"`
16-
Level json.Number `json:"level"`
17-
Audience []string `json:"aud,omitempty"`
14+
UID string `json:"uid"`
15+
State string `json:"state"`
16+
Email string `json:"email"`
17+
Role string `json:"role"`
18+
ReferralID string `json:"referral_id"`
19+
Level json.Number `json:"level"`
20+
Audience []string `json:"aud,omitempty"`
1821

1922
jwt.StandardClaims
2023
}
@@ -46,6 +49,7 @@ func appendClaims(defaultClaims, customClaims jwt.MapClaims) jwt.MapClaims {
4649
return defaultClaims
4750
}
4851

52+
// ForgeToken creates a valid JWT signed by the given private key
4953
func ForgeToken(uid, email, role string, level int, key *rsa.PrivateKey, customClaims jwt.MapClaims) (string, error) {
5054
claims := appendClaims(jwt.MapClaims{
5155
"iat": time.Now().Unix(),

0 commit comments

Comments
 (0)