Skip to content

Commit

Permalink
Expose email, referral_id from the JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
calj authored and Camille committed Nov 27, 2020
1 parent 1aecb9a commit 3debfdc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/auth/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (
"github.com/dgrijalva/jwt-go"
)

// Auth struct represnets parsed jwt information.
// Auth struct represents parsed jwt information.
type Auth struct {
UID string `json:"uid"`
Role string `json:"role"`
Level json.Number `json:"level"`
Audience []string `json:"aud,omitempty"`
UID string `json:"uid"`
State string `json:"state"`
Email string `json:"email"`
Role string `json:"role"`
ReferralID string `json:"referral_id"`
Level json.Number `json:"level"`
Audience []string `json:"aud,omitempty"`

jwt.StandardClaims
}
Expand Down Expand Up @@ -46,6 +49,7 @@ func appendClaims(defaultClaims, customClaims jwt.MapClaims) jwt.MapClaims {
return defaultClaims
}

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

0 comments on commit 3debfdc

Please sign in to comment.