Skip to content

Commit

Permalink
Add ability to parse body without verification (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
segabriel authored Apr 6, 2022
1 parent 1d039d6 commit 8f7068b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import java.util.Map;
import reactor.core.publisher.Mono;

@FunctionalInterface
public interface JwtTokenResolver {

/**
* Parses and returns token claims without verification.
*
* @param token jwt token
* @return parsed claims
*/
Map<String, Object> parseBody(String token);

/**
* Verifies and returns token claims if everything went ok.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public JwtTokenResolverImpl cleanupInterval(Duration cleanupInterval) {
return c;
}

@Override
public Map<String, Object> parseBody(String token) {
JwtTokenParser tokenParser = tokenParserFactory.newParser(token);
JwtToken jwtToken = tokenParser.parseToken();
return jwtToken.body();
}

@Override
public Mono<Map<String, Object>> resolve(String token) {
return Mono.defer(
Expand Down

0 comments on commit 8f7068b

Please sign in to comment.