ngx-http-auth-jwt-module icon indicating copy to clipboard operation
ngx-http-auth-jwt-module copied to clipboard

very basic misunderstanding...

Open TomaszWojtas opened this issue 2 years ago • 0 comments

Hello,

I followed the post post https://mostafa-asg.github.io/post/nginx-authentication-with-jwt/ I think it went successful, but...

I got stuck on the last stage. I think I make just some noobie mistake, but I keep receiving: 401 Authorisation required. Giving an example location:

location /test/{ auth_jwt_enabled on; auth_jwt_algorithm HS256; auth_jwt_validate_email off; auth_jwt_key "secret"; try_files /test.html /test.html; }

I assume that to get to the www.mysite.com/test/ I need to add header with JWT. So I go to jwt.io, generate the token using "secret" as the secret key to get JWT (like https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o).

So I authorise by adding the header and calling:

curl -H "authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o" https://www.mysite.com/test/

If you give me a hint what I am doing wrong, I would be very grateful.

Thank you very much!

Best regards Tomasz Wojtas

TomaszWojtas avatar Oct 21 '22 21:10 TomaszWojtas