Minor: Revert JWT Filter changes to extract username (#14607)

This commit is contained in:
Sriharsha Chintalapani 2024-01-06 23:49:52 -08:00 committed by GitHub
parent d513dc4d4d
commit a41a341aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,6 @@
package org.openmetadata.service.security;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.service.security.jwt.JWTTokenGenerator.SUBJECT_CLAIM;
import static org.openmetadata.service.security.jwt.JWTTokenGenerator.TOKEN_TYPE;
import com.auth0.jwk.Jwk;
@ -184,12 +183,6 @@ public class JwtFilter implements ContainerRequestFilter {
@SneakyThrows
public String validateAndReturnUsername(Map<String, Claim> claims) {
// Get username from JWT token
String claimUserName = "";
if (!Objects.isNull(claims.get(SUBJECT_CLAIM))) {
claimUserName = claims.get(SUBJECT_CLAIM).as(TextNode.class).asText();
}
// Get email from JWT token
String jwtClaim =
jwtPrincipalClaims.stream()
@ -213,11 +206,6 @@ public class JwtFilter implements ContainerRequestFilter {
domain = StringUtils.EMPTY;
}
// Prefer userName over email
if (org.apache.commons.lang3.StringUtils.isNotBlank(claimUserName)) {
userName = claimUserName;
}
// validate principal domain
if (enforcePrincipalDomain && !domain.equals(principalDomain)) {
throw new AuthenticationException(