mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-22 07:19:59 +00:00
This commit is contained in:
parent
7c84f063e6
commit
9a8d29b8ca
@ -22,6 +22,7 @@ public class AuthenticationConfiguration {
|
||||
@Getter @Setter private String authority;
|
||||
@Getter @Setter private String clientId;
|
||||
@Getter @Setter private String callbackUrl;
|
||||
@Getter @Setter private String jwtEmail = "email";
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -40,12 +40,14 @@ public class JwtFilter implements ContainerRequestFilter {
|
||||
public static final String AUTHORIZATION_HEADER = "Authorization";
|
||||
public static final String TOKEN_PREFIX = "Bearer";
|
||||
private String publicKeyUri;
|
||||
private String jwtEmail;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private JwtFilter() {}
|
||||
|
||||
public JwtFilter(AuthenticationConfiguration authenticationConfiguration) {
|
||||
this.publicKeyUri = authenticationConfiguration.getPublicKey();
|
||||
this.jwtEmail = authenticationConfiguration.getJwtEmail();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@ -79,7 +81,9 @@ public class JwtFilter implements ContainerRequestFilter {
|
||||
throw new AuthenticationException("Invalid token");
|
||||
}
|
||||
String authorizedEmail;
|
||||
if (jwt.getClaims().get("email") != null) {
|
||||
if (jwt.getClaims().get(jwtEmail) != null) {
|
||||
authorizedEmail = jwt.getClaim(jwtEmail).as(TextNode.class).asText();
|
||||
} else if (jwt.getClaims().get("email") != null) {
|
||||
authorizedEmail = jwt.getClaim("email").as(TextNode.class).asText();
|
||||
} else if (jwt.getClaims().get("preferred_username") != null) {
|
||||
authorizedEmail = jwt.getClaim("preferred_username").as(TextNode.class).asText();
|
||||
|
Loading…
x
Reference in New Issue
Block a user