Skip to content

Refresh token#50

Open
georgebejan wants to merge 1 commit intocode4romania:developfrom
georgebejan:refresh_token
Open

Refresh token#50
georgebejan wants to merge 1 commit intocode4romania:developfrom
georgebejan:refresh_token

Conversation

@georgebejan
Copy link
Member

What does it fix?

#44

How has it been tested?

Tested the whole register-> login -> request access token flow with Postman

@vercel
Copy link

vercel bot commented Apr 7, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/code4romania/next-door/pbg2b3zwm
✅ Preview: https://next-door-git-fork-georgebejan-refreshtoken.code4romania.now.sh


final String jwt = tokenProvider.generateToken(authentication);
return ResponseEntity.ok(new JwtAuthenticationResponse(jwt));
final UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a custom implementation for this and not a normal authentication flow?
Default SpringSecurity Authentication using JWT is super simple to implement without extra work needed.
And for the long run is the way to go


return Jwts.builder()
.setSubject(userPrincipal.getId().toString())
.setSubject(userId.toString())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safest way to sign the access token is using Private key and implementing RSA algorithm
Also, for the current implementation the signing key is too short

@@ -60,6 +84,7 @@ public boolean validateToken(final String authToken) {
} catch (IllegalArgumentException ex) {
LOGGER.error("JWT claims string is empty.");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a best practice to pass exception to the logger to have it's stacktrace, event if you have a custom logging message the stacktrace provides valuable info

jwtExpirationInMs: 1000
jwt:
secret: test
accessTokenExpirationInMs: 86400000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this too much interval?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants