Skip to content

Commit

Permalink
Enhance "aud" examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Sanches committed Mar 13, 2019
1 parent 1ea3c5b commit c708f45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ h := jwt.Header{KeyID: "kid"}
p := jwt.Payload{
Issuer: "gbrlsnchs",
Subject: "someone",
Audience: jwt.Audience{"gophers"},
Audience: jwt.Audience{"https://golang.org", "https://jwt.io"},
ExpirationTime: now.Add(24 * 30 * 12 * time.Hour).Unix(),
NotBefore: now.Add(30 * time.Minute).Unix(),
IssuedAt: now.Unix(),
Expand Down Expand Up @@ -96,7 +96,7 @@ p := CustomPayload{
Payload: jwt.Payload{
Issuer: "gbrlsnchs",
Subject: "someone",
Audience: jwt.Audience{"gophers"},
Audience: jwt.Audience{"https://golang.org", "https://jwt.io"},
ExpirationTime: now.Add(24 * 30 * 12 * time.Hour).Unix(),
NotBefore: now.Add(30 * time.Minute).Unix(),
IssuedAt: now.Unix(),
Expand Down Expand Up @@ -139,7 +139,7 @@ fmt.Println(h.KeyID)

iatValidator := jwt.IssuedAtValidator(now)
expValidator := jwt.ExpirationTimeValidator(now, true)
audValidator := jwt.AudienceValidator(jwt.Audience{"admin", "sudo"})
audValidator := jwt.AudienceValidator(jwt.Audience{"https://golang.org", "https://jwt.io", "https://google.com", "https://reddit.com"})
if err := p.Validate(iatValidator, expValidator, audValidator); err != nil {
switch err {
case jwt.ErrIatValidation:
Expand Down

0 comments on commit c708f45

Please sign in to comment.