Skip to content

Commit

Permalink
Set JWT expiration to 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
badass-techie committed Oct 15, 2023
1 parent 432cc06 commit 4a3058a
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

import com.badasstechie.identity.util.Pair;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.jwt.JwtClaimsSet;
import org.springframework.security.oauth2.jwt.JwtEncoder;
import org.springframework.security.oauth2.jwt.JwtEncoderParameters;
import org.springframework.stereotype.Service;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
Expand All @@ -31,7 +27,7 @@ public Pair<String, Instant> generateToken(Long userId, String scope) {
JwtClaimsSet claims = JwtClaimsSet.builder()
.issuer("self")
.issuedAt(now)
.expiresAt(now.plus(500, ChronoUnit.HOURS)) // TODO: Change this to 5 minutes
.expiresAt(now.plus(5, ChronoUnit.MINUTES))
.subject(userId.toString())
.claim("scope", scope)
.build();
Expand Down

0 comments on commit 4a3058a

Please sign in to comment.