Skip to content

Commit

Permalink
mention AcceptTemporal in the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pascaldekloe committed Jun 19, 2022
1 parent bea05ed commit 6dbf322
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ Note how the verification process is self-contained with just a public key.
// verify a JWT
claims, err := jwt.EdDSACheck(token, JWTPublicKey)
if err != nil {
log.Print("credentials denied with ", err)
log.Print("credentials rejected: ", err)
return
}
if !claims.Valid(time.Now()) {
log.Print("credential time constraints exceeded")
err = claims.AcceptTemporal(time.Now(), time.Second)
if err != nil {
log.Print("credential constraints violated: ", err)
return
}

// ready for use
log.Print("hello ", claims.Subject)
if verified, _ := claims.Set["email_verified"].(bool); !verified {
log.Print("e-mail confirmation pending")
Expand Down
9 changes: 5 additions & 4 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ func ExampleClaims() {
// verify a JWT
claims, err := jwt.RSACheck(token, &RSAKey.PublicKey)
if err != nil {
fmt.Println("credentials denied on", err)
fmt.Println("credentials rejected:", err)
return
}
if !claims.Valid(time.Now()) {
fmt.Println("time constraints exceeded")
err = claims.AcceptTemporal(time.Now(), time.Second)
if err != nil {
fmt.Println("credential constraints violated:", err)
return
}
if !claims.AcceptAudience("armory") {
fmt.Println("reject on audience", claims.Audiences)
fmt.Println("credentials not for armory:", claims.Audiences)
return
}
fmt.Println(string(claims.Raw))
Expand Down

0 comments on commit 6dbf322

Please sign in to comment.