fixed token utils to support both IAM and Legacy auth corner cases

This commit is contained in:
Massimiliano Assante 2022-10-19 19:59:25 +02:00
parent c6a625d800
commit 26b8336f05
1 changed files with 9 additions and 5 deletions

View File

@ -28,7 +28,10 @@ public class TokensUtils {
* @return a boolean value
*/
public static boolean isApplicationToken(Caller caller){
String username = caller.getClient().getId();
if (username.startsWith("service-account-")) {
return true;
}
return caller.getClient().getType().equals(ClientType.EXTERNALSERVICE);
}
@ -49,7 +52,10 @@ public class TokensUtils {
*/
public static boolean isUserToken(Caller caller){
String username = caller.getClient().getId();
return !username.startsWith("service-account-");
if (username.startsWith("service-account-")) {
return false;
}
return caller.getClient().getType().equals(ClientType.USER);
}
@ -58,9 +64,7 @@ public class TokensUtils {
* @return a boolean value
*/
public static boolean isUserTokenDefault(Caller caller){
return caller.getClient().getType().equals(ClientType.USER);
return isUserToken(caller);
}
/**