Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EssentialClaims Requires JSON array for aud claim #28

Closed
hopkinsth opened this issue Aug 30, 2017 · 2 comments
Closed

EssentialClaims Requires JSON array for aud claim #28

hopkinsth opened this issue Aug 30, 2017 · 2 comments

Comments

@hopkinsth
Copy link

hopkinsth commented Aug 30, 2017

Due to the way that EssentialClaims are parsed from JSON, the aud claim must always be an array in the source data.

For example, this sample app will fail the audience check:

package main 

import "github.com/lestrrat/go-jwx/jwt"
import "fmt"
import "encoding/json"

func main() {
    var claimSet jwt.ClaimSet
    err := json.Unmarshal([]byte(`{
      "ver": 1,
      "jti": "AT.yhqxyRwZa5koTnwWQ8G1QV4s2cGYqApe6s22lLjzqJg",
      "iss": "https://my.issuer.domain",
      "aud": "http://my.audience",
      "iat": 1504131487,
      "exp": 1514678399,
      "cid": "1234",
      "uid": "5678",
      "scp": ["users"],
      "sub": "hopkinsth@gmail.com"
    }`), &claimSet)

  if err != nil {
    panic(err)
  }
  // will print "aud not satisfied" assuming the `exp` time hasn't passed
  fmt.Println(claimSet.Verify(jwt.WithAudience("http://my.audience")))
}

On this the JWT RFC says, basically, aud can be an array or a string: https://tools.ietf.org/html/rfc7519#section-4.1.3

Planning to file a pull request for a fix later... submitting this partly as a reminder.

@lestrrat
Copy link
Collaborator

lestrrat commented Aug 31, 2017

Planning to file a pull request for a fix later... submitting this partly as a reminder.

👍 👍 👍

@lestrrat
Copy link
Collaborator

Closing this as it has been ages since last activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants