diff --git a/pom.xml b/pom.xml
index 7ac8292..42ad127 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
com.bloggios.authentication-config
authentication-configuration-jar
- 2.0
+ 2.1
authentication-configuration-jar
authentication-configuration-jar
diff --git a/src/main/java/com/bloggios/authenticationconfig/authentication/JwtTokenValidationFilter.java b/src/main/java/com/bloggios/authenticationconfig/authentication/JwtTokenValidationFilter.java
index e7684f3..a61992a 100644
--- a/src/main/java/com/bloggios/authenticationconfig/authentication/JwtTokenValidationFilter.java
+++ b/src/main/java/com/bloggios/authenticationconfig/authentication/JwtTokenValidationFilter.java
@@ -240,12 +240,18 @@ private void addAuthentication(HttpServletRequest request, String token) {
String userId = jwtDecoderUtil.extractUserId(token);
String email = jwtDecoderUtil.extractEmail(token);
String username = jwtDecoderUtil.extractUsername(token);
+ String userBadge = jwtDecoderUtil.extractBadge(token);
+ boolean isBadge = false;
+ if (StringUtils.hasText(userBadge)) {
+ isBadge = Boolean.parseBoolean(userBadge);
+ }
Collection extends GrantedAuthority> grantedAuthorities = jwtDecoderUtil.extractAuthorities(token);
authenticatedUser.setUserId(userId);
authenticatedUser.setEmail(email);
authenticatedUser.setAuthorities(grantedAuthorities);
authenticatedUser.setClientIp(jwtDecoderUtil.extractClientIp(token));
authenticatedUser.setUsername(username);
+ authenticatedUser.setBadge(isBadge);
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(authenticatedUser, null, grantedAuthorities);
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authentication);
diff --git a/src/main/java/com/bloggios/authenticationconfig/payload/AuthenticatedUser.java b/src/main/java/com/bloggios/authenticationconfig/payload/AuthenticatedUser.java
index d18e5b0..b1c32ef 100644
--- a/src/main/java/com/bloggios/authenticationconfig/payload/AuthenticatedUser.java
+++ b/src/main/java/com/bloggios/authenticationconfig/payload/AuthenticatedUser.java
@@ -50,4 +50,5 @@ public class AuthenticatedUser {
private String email;
private String clientIp;
public String username;
+ private boolean isBadge;
}
diff --git a/src/main/java/com/bloggios/authenticationconfig/util/JwtDecoderUtil.java b/src/main/java/com/bloggios/authenticationconfig/util/JwtDecoderUtil.java
index 91a5b67..49d5d70 100644
--- a/src/main/java/com/bloggios/authenticationconfig/util/JwtDecoderUtil.java
+++ b/src/main/java/com/bloggios/authenticationconfig/util/JwtDecoderUtil.java
@@ -111,13 +111,13 @@ public String extractUsername(String token) {
}
}
- public String extractTokenType(String token) {
+ public String extractBadge(String token) {
try {
Jwt jwt = jwtDecoder.decode(token);
- return jwt.getClaimAsString("type");
+ return jwt.getClaimAsString("is-badge");
} catch (Exception e) {
- logger.error("Exception Occurred while extracting Token Type from token with default message as : {}", e.getMessage());
- throw new AuthenticationConfigException("Unable to extract Token Type from the Token");
+ logger.error("Exception Occurred while extracting User Badge from token with default message as : {}", e.getMessage());
+ throw new AuthenticationConfigException("Unable to extract User Badge from the Token");
}
}
}