Questions tagged [jwt]

JSON Web Token (JWT, pronounced "jot") is a type of token-based authentication used in space-constrained environments such as HTTP Authorization headers. Use this tag for questions relating to the configuration, generation and usage of JWTs in your code.

JSON Web Token (JWT, pronounced "jot") is a token format for use in space-constrained environments such as HTTP authorization headers. It is defined in RFC 7519.

JWTs encode security "claims" as JSON objects and the token can be signed and or encrypted. JWT is used by the OpenID Connect authenticatication standard.

More information about JWT and libraries for different languages can be found on the official JWT site.

17340 questions
37
votes
2 answers

Spring Boot Unit Tests with JWT Token Security

I am creating a backend using Spring Boot and I have just added JWT security to it. I have done some tests using a REST Client and the JWT security is working fine, however all of my unit tests are now returning a 403 error code. I've added the…
Felipe
  • 6,312
  • 11
  • 52
  • 70
37
votes
3 answers

What should be the "Secret" in JWT?

I am going to apply JWT into my REST API developed using Java-Jersey. I am using this library for JWT - https://github.com/auth0/java-jwt I have few questions about the JWT - Secret Does this Secret has to be unique? Shall I use the hashed version…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
37
votes
8 answers

How can I decode JWT (JSON web token) token in Swift?

I have a JWT token like this eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ How can I decode this so that I can get the payload like this { …
37
votes
3 answers

How can I validate a JWT passed via cookies?

The UseJwtBearerAuthentication middleware in ASP.NET Core makes it easy to validate incoming JSON Web Tokens in Authorization headers. How do I authenticate a JWT passed via cookies, instead of a header? Something like UseCookieAuthentication, but…
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
36
votes
8 answers

ASP.NET Core WebAPI Cookie + JWT Authentication

we have a SPA (Angular) with API backend (ASP.NET Core WebAPI): SPA is listens on app.mydomain.com, API on app.mydomain.com/API We use JWT for Authentication with built-in Microsoft.AspNetCore.Authentication.JwtBearer; I have a controller…
Luke1988
  • 1,850
  • 2
  • 24
  • 42
36
votes
1 answer

Google play services returning a token signed with a non-Google key

I have an Android client getting an authentication token from Google Play Services, by using GoogleAuthUtil.getToken(Context context, Account account, String scope). This is then sent to a backend (Go) server, which checks that the token was signed…
JohnGB
  • 1,906
  • 2
  • 20
  • 31
36
votes
3 answers

Identity Server 4: adding claims to access token

I am using Identity Server 4 and Implicit Flow and want to add some claims to the access token, the new claims or attributes are "tenantId" and "langId". I have added langId as one of my scopes as below and then requesting that through identity…
36
votes
7 answers

Use JWT (Authorization: Bearer) in Swagger in ASP.NET Core

I'm creating a REST api in ASP.NET Core 1.0. I was using Swagger to test but now I added JWT authorization for some routes. (with UseJwtBearerAuthentication) Is it possible to modify the header of the Swagger requests so the routes with the…
MonkeyDreamzzz
  • 3,978
  • 1
  • 39
  • 36
35
votes
1 answer

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

I'm working with ASP.NET Core Web API application. I'm trying to implement Jwt Token Based Authentication on top of ASP.NET Identity( built in with database tables). I have implemented all scenarios like register user, login etc but now trying to…
35
votes
8 answers

Django Rest Framework JWT Unit Test

I am using DRF with the JWT package for authentication. Now, I'm trying to write a unit test that authenticates itself with a JWT token. No matter how I try it, I can't get the test API client to authenticate itself via JWT. If I do the same with an…
Christof
  • 3,777
  • 4
  • 37
  • 49
34
votes
7 answers

ASP.NET core JWT authentication always throwing 401 unauthorized

I'm trying to implement JWT authentication on my asp.net core webAPI as simply as possible. I don't know what i'm missing but it's always returning 401 even with the proper bearer token. here is my configureServices code public void…
34
votes
3 answers

React - How to check if JWT is valid before sending a post request?

another noob question. I'm logging in my user to the system using JWT authorization, getting the token and saving it in localstorage and then sending a post request that saves data (its a big form basically). Problem is, the sever is invalidating…
Samia Ruponti
  • 3,910
  • 12
  • 42
  • 62
34
votes
7 answers

JWT Verify client-side?

I have a nodejs api with an angular frontend. The API is successfully using JWT with passport to secure it's endpoints. I am now conscious that after the tokens have expired, my front end will still allow the user to request my api endpoints…
George Edwards
  • 8,979
  • 20
  • 78
  • 161
34
votes
4 answers

How to protect all controllers by default with bearer token in ASP.NET Core?

I have added a JWT middleware to my application: app.UseJwtBearerAuthentication(options => { options.AutomaticAuthenticate = true;} ) Ideally what I want to achieve is that all controller actions are protected by default (there were filters for…
Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207
34
votes
2 answers

Significant differences between Cookies and JWT for native mobile apps

I have been using Cookies for authentication and session control in my web apps, and am content with its functionalities. I was introduced by an iOS app developer that the new hot thing is JWT (JSON Web Token). He told me that JWT is the way of…
skyork
  • 7,113
  • 18
  • 63
  • 103