BTBurke / caddy-jwt

JWT middleware for the Caddy server
MIT License
114 stars 39 forks source link

Do not see Claims passed as headers in request #5

Closed JunedS closed 8 years ago

JunedS commented 8 years ago

I have defined proxy in Caddy file which passed all the rest api request to the proxied server.

I have added extra claims like id ("abc") and type ("xyz") and passing jwt_token in cookie which is HttpOnly. When the control comes in the api method and if I do r.Header.Get("Token-Claim-Id") or r.Header.Get("Token-Claim-Type") I see its blank. Even r.Header.Get("Token") is returning blank.

Note: Cookie is having jwt_token and the value is also there.

Please let me know what is that I an missing or my understanding is wrong.

Thanks, Juned S

BTBurke commented 8 years ago

The tests show the the headers are being added for custom claims. It could be a couple things related to how you're constructing the token. What jwt library are you using? When it's processing the custom claims it's trying to assert a type for both the claim's name and value. The claim name should be a string, the value can be any one of several types. Try setting your claim name to "id" and "type" to see if that fixes the problem. If you're using a good jwt library, it should coerce any claim name to string automatically.

Let me know if you are still having problems with it and I'll run some integration tests to make sure the headers aren't being stripped somewhere by Caddy later in the request handling process.

JunedS commented 8 years ago

Hi,

Not sure what I was doing wrong and I didn't change anything but it seems to be working now (can get claim from the header in request). I have been using jwt-go library by dgrijalva.

Thanks