Skip to content

Conversation

@DevEpso
Copy link
Member

@DevEpso DevEpso commented Nov 8, 2025

I implemented a basic springboot json web token handler class, that is based on the newest version(0.13.0) of the io.jsonwebtoken api. This was fully built without the help of AI.

https://github.com/jwtk/jjwt

---- Additionally added a inner class to the User.java for data that is
allowed to be shared publicly (aka send back to the user).
@DevEpso DevEpso added java Pull requests that update java code springboot labels Nov 8, 2025
@DevEpso DevEpso linked an issue Nov 8, 2025 that may be closed by this pull request
Copy link
Member

@MaximilianRau04 MaximilianRau04 left a comment

Choose a reason for hiding this comment

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

SECRET_KEY is injected by Spring after object construction via @value("${jwt.secret}").
This means that when the JwtParser is initialized at field level, SECRET_KEY is still null, causing getSigningKey() to be called with null, leading to a potential NullPointerException.

Consider initializing the parser lazily (e.g., in a getter) or inside a @PostConstruct method after the secret has been set.

private JwtParser parser = Jwts.parser()
.verifyWith(getSigningKey())
.build();

Copy link
Member

Choose a reason for hiding this comment

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

SECRET_KEY is injected by Spring after object construction via @value("${jwt.secret}").
This means that when the JwtParser is initialized at field level, SECRET_KEY is still null, causing getSigningKey() to be called with null, leading to a potential NullPointerException.

Consider initializing the parser lazily (e.g., in a getter) or inside a @PostConstruct method after the secret has been set.

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

Labels

authentication java Pull requests that update java code springboot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JWT Service Implementation

4 participants