json-web-token

How to keep client JSON web token secure in a React Native app?

烂漫一生 提交于 2019-12-20 12:27:10
问题 We are building a React Native app for iOS and we are using an internal API built on node + express + jsonwebtoken. When the user logs in with username/password, the server validates those credentials and sends the client back a JSON web token that they must then send along with every API request. So the React native app must store this token. How do I securely store this client token in the React native app? Is it necessary to take any additional steps besides just storing the token in a

JWT Verify client-side?

最后都变了- 提交于 2019-12-20 10:37:58
问题 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 without prompting them to reenter their log in details to get a fresh token. This is how my backend generates the token: function generateToken(user) { return jwt.sign(user, secret, { expiresIn: 10080 // in seconds }); } So to implement this logic I think

JSON Web Token (JWT) benefits over a database session token

最后都变了- 提交于 2019-12-18 09:59:37
问题 With a database session token system I could have a user login with a username/password, the server could generate a token (a uuid for example) and store it in the database and return that token to the client. Every request from thereon would include the token and the server would look up whether the token is valid and what user it belongs to. Using JWT there would be no need to save anything to the database with respect to session/tokens thanks to the combination of the secret key kept on

Generated with Java JJWT signature fails at jwt.io debugger

淺唱寂寞╮ 提交于 2019-12-18 07:00:01
问题 I am using the jjwt Java library for server side generation of jwt in on servlets, the code snipper below straight from the jjwt GitHub page https://github.com/jwtk/jjwt generates and prints out this token. eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.XIKER3owR8BS3Krhsksg9INh9VBSejdn_qN-ONtPans String compactJws = Jwts.builder() .setSubject("Joe") .signWith(SignatureAlgorithm.HS256, "secret") .compact(); PrintWriter out = response.getWriter(); out.println(compactJws); However, when I try to verify

implementing refresh-tokens with angular and express-jwt

為{幸葍}努か 提交于 2019-12-17 22:12:29
问题 I want to implement the Sliding expiration concept with json web tokens using angular, nodejs and express-jwt. I'm a little confused on how to do this, and am struggling to find any example of refresh tokens or and other material relating to sessions with these technologies/frameworks. A few options I was thinking of were Generating a new token with each request after the initial login Keeping track of issued token on the server side along But I'm honestly not sure, please help 回答1: I managed

Only allow signing in from one device at a time in NodeJS

僤鯓⒐⒋嵵緔 提交于 2019-12-12 09:07:54
问题 I am using JWT for authentication. However I do not want the user to be logged in from multiple devices. How do I ensure this? Right now - All I can think of is to store the JWT into DB and then check if it exists . And if it exists, what was the time it was generated at. If too much time - we go and regenerate the token and pass on back to the 2nd device. 回答1: That's pretty much your only option, the JWT is pretty stateless on purpose. Similar to how you can't really do a server side logout

custom refresh token method in JWT method

╄→гoц情女王★ 提交于 2019-12-12 04:54:38
问题 according to this article http://www.jianshu.com/p/b11accc40ba7 one method to secure the JWT is refreshToken: in center auth server, we maintain a table like this: table auth_tokens( user_id, jwt_hash, expire ) The following is work flow: User request the login API with phone and we verified it, after that, the auth server send one token, and register the token ( add one row in the table. ) When the token expired, user request the exchange API with the old token. Firstly the auth server

JWT How to bypass certain API routes and http methods

蓝咒 提交于 2019-12-11 12:48:52
问题 I can make get JSON-Web-Token to ignore paths using .unless like this. app.use(expressJWT({secret: config.JWTSECRET}).unless({path: ['/register', '/authentication', ]})); I have a route with different HTTP methods (get, put, post, delete). I want the GET version of /events to not require a token, but the POST version of /event to require a token. Can I do this without having different routes for GET and POST etc. /events //GET - no token required /events //POST - token required 回答1: If I know

Angular 'Error: $injector:cdep Circular Dependency' when using factory in app.js

若如初见. 提交于 2019-12-11 09:48:20
问题 I am trying to use tokens to handle my user authentication. I hit a bump in the road and I am not entirely sure where to go from here. I looked around a bit, and it looks like I should use the $injector service, but I am not 100% sure. Could anyone please assist? I created a factory that gets the token from node: angular.module('myApp').factory('authenticateInterceptor', function(authenticateToken){ var authenticateInterceptorFactory = {}; authenticateInterceptorFactory.request = function

When JWT expires, will the JWT stored in local storage be removed automatically?

耗尽温柔 提交于 2019-12-11 06:06:49
问题 I have JWT already stored in the user's browser's local storage. I have set the JWT's expiration date to be on in 7 days using nodejs/express. Will the browser detect the expiration date and automatically remove it from the local storage? or will my server have to check the JWT and remove the expired JWT from the user's browser's local storage? 回答1: Local storage does not have an auto-expiring feature so the browser will not remove the JWT from local storage. It will be up to you or a library