Skip to content

Instantly share code, notes, and snippets.

@Flygsand
Created February 7, 2022 08:00
Show Gist options
  • Save Flygsand/1d918e769b34e5fbbeb96f5c422b3676 to your computer and use it in GitHub Desktop.
Save Flygsand/1d918e769b34e5fbbeb96f5c422b3676 to your computer and use it in GitHub Desktop.
package example;
import org.springframework.security.oauth2.core.OAuth2TokenType;
import org.springframework.security.oauth2.server.authorization.JwtEncodingContext;
import org.springframework.security.oauth2.server.authorization.OAuth2TokenCustomizer;
import org.springframework.stereotype.Component;
@Component
public class JwtCustomizer implements OAuth2TokenCustomizer<JwtEncodingContext> {
@Override
public void customize(JwtEncodingContext context) {
if (OAuth2TokenType.ACCESS_TOKEN.equals(context.getTokenType())) {
context.getClaims().claim("key", "value");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment