Skip to content

Commit

Permalink
The users/me endpoint now provides more accurate information based on…
Browse files Browse the repository at this point in the history
… various configs (#2602)
  • Loading branch information
EricWittmann authored Jun 30, 2022
1 parent b5fd988 commit bc45667
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/src/main/java/io/apicurio/registry/auth/AuthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ public boolean isApplicationRbacEnabled() {
return this.roleBasedAuthorizationEnabled && "application".equals(getRoleSource());
}

public boolean isAnonymousReadsEnabled() {
return anonymousReadAccessEnabled.get();
}

public boolean isAuthenticatedReadsEnabled() {
return authenticatedReadAccessEnabled.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ public UserInfo getCurrentUserInfo() {
info.setDeveloper(rbac.isDeveloper());
info.setViewer(rbac.isReadOnly());
} else {
info.setAdmin(false);
info.setAdmin(true);
info.setDeveloper(false);
info.setViewer(false);
}
if (authConfig.isAdminOverrideEnabled() && adminOverride.isAdmin()) {
info.setAdmin(true);
}
if (securityIdentity.isAnonymous() && authConfig.isAnonymousReadsEnabled()) {
info.setViewer(true);
}
if (!securityIdentity.isAnonymous() && authConfig.isAuthenticatedReadsEnabled()) {
info.setViewer(true);
}
return info;
}

Expand Down

0 comments on commit bc45667

Please sign in to comment.