Skip to content

Cannot unmarshal array into Go struct field GatewayClaims.aud of type string #66

@vnugent

Description

@vnugent

- Do you want to request a feature or report a bug?
Bug

- What is the current behavior?

git-gateway can't handle Auth0 token with audience formatted as array.

Auth0 JWT:

{
  "iss": "...",
  "sub": " ...",
  "aud": [
    "https://git-gateway" <-- array
   ],
  ...
}

git-gateway returns:  {"code":401,"msg":"Invalid token: json: cannot unmarshal array into Go struct field GatewayClaims.aud of type string"}

- If the current behavior is a bug, please provide the steps to reproduce.

  1. Go to jwt.io and generate a new token.
  2. Change aud in the payload from a string to an array. Ex:

From

 "aud": "https://git-gateway"

to

"aud": [
    "https://git-gateway"
   ],

- What is the expected behavior?
git-gateway can handle audience as an array

- Please mention your Go version, and operating system version.
Running in a container built with the included Dockerfile.


Edit: it is a known issue the jwt library: dgrijalva/jwt-go#308

token, err := p.ParseWithClaims(bearer, &GatewayClaims{}, func(token *jwt.Token) (interface{}, error) {

Update: I have made a fix. Upgrading jwt library to the latest. PR to come.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions