I've successfully set up JJWT to be used in the authentication process across a series of web services. The problem is that they're created in one web service, but authenticated across multiple services. How can I successfully and safely use the signature while also assuring that all my web services use the same signature to validate incoming JWT?
// We need a signing key, so we'll create one just for this example. Usually
// the key would be read from your application configuration instead.
Key key = MacProvider.generateKey();
String compactJws = Jwts.builder()
.setSubject("Joe")
.signWith(SignatureAlgorithm.HS512, key)
.compact();
I know that I can use a plain old string to .signWith(Algorithm,String)
however I've been made aware that using a standard Java String
(literally) isn't secure enough. I was using something akin to:
String compactJws = Jwts.builder()
.setSubject("Joe")
.signWith(SignatureAlgorithm.HS512, "shared complex passphrase")
.compact();