Skip to content

Commit

Permalink
Allow account scaffold to access extended users
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Mar 26, 2024
1 parent 4d9940a commit 743861a
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UserAccessGuard(ClientRepository clientRepository) {
}

public boolean accessToExtended(UserId userId) {
return isMe(userId) || isAdmin() || isLocalRunnerAuthenticated();
return isMe(userId) || isAdmin() || isLocalRunnerAuthenticated() || isApiKeyWithExtendedAccess();
}

public boolean isMe(UserId userId) {
Expand Down Expand Up @@ -85,7 +85,7 @@ public boolean haveAccessToUser(UserId userId, boolean userLocked) {
return true;
}

if (apiKeyWithAccess()) {
if (isApiKeyWithAccess()) {
return true;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ private boolean haveAcceptedClient(UserId userId) {
}

/** Api Key with type INFO or ACCOUNT_SCAFFOLD have access to user information. */
private boolean apiKeyWithAccess() {
private boolean isApiKeyWithAccess() {
if (AuthenticationExtractor.getAuthentication()
instanceof ApiAuthentication apiAuthenticationPrincipal) {
ApiKeyType apiKeyType = apiAuthenticationPrincipal.get().keyType();
Expand All @@ -138,4 +138,17 @@ private boolean apiKeyWithAccess() {

return false;
}

private boolean isApiKeyWithExtendedAccess() {
if (AuthenticationExtractor.getAuthentication()
instanceof ApiAuthentication apiAuthenticationPrincipal) {
ApiKeyType apiKeyType = apiAuthenticationPrincipal.get().keyType();
return apiKeyType.equals(ApiKeyType.ACCOUNT_SCAFFOLD);
}

return false;
}



}

0 comments on commit 743861a

Please sign in to comment.