Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix required groups auth check on requests endpoints #1841

Merged
merged 2 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ public void checkReadAuthorization(SingularityUser user) {
}
}

public void checkUserInRequiredGroups(SingularityUser user) {
if (authEnabled) {
final Set<String> userGroups = user.getGroups();
final boolean userIsAdmin = !adminGroups.isEmpty() && groupsIntersect(userGroups, adminGroups);
final boolean userIsPartOfRequiredGroups = requiredGroups.isEmpty() || groupsIntersect(userGroups, requiredGroups);
if (!userIsAdmin) {
checkForbidden(
userIsPartOfRequiredGroups,
"%s must be part of one or more read only or jita groups: %s,%s", user.getId(), JavaUtils.COMMA_JOINER.join(requiredGroups));
}
}
}

public void checkForAuthorizationByTaskId(String taskId, SingularityUser user, SingularityAuthorizationScope scope) {
if (authEnabled) {
checkForbidden(user.isAuthenticated(), "Not Authenticated!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ private boolean valueOrFalse(Boolean input) {
}

private List<SingularityRequestWithState> filterAutorized(List<SingularityRequestWithState> requests, final SingularityAuthorizationScope scope, SingularityUser user) {
authorizationHelper.checkUserInRequiredGroups(user);
if (!authorizationHelper.hasAdminAuthorization(user)) {
return requests.stream()
.filter((parent) -> authorizationHelper.isAuthorizedForRequest(parent.getRequest(), user, scope))
Expand Down
2 changes: 1 addition & 1 deletion SingularityUI/app/components/requests/RequestsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RequestsPage extends Component {
if (this.state.loading) {
table = <Loader />;
} else if (!displayRequests.length) {
table = <div className="empty-table-message"><p>No matching requests</p></div>;
table = <div className="empty-table-message"><p>No requests found. You may not be part of the correct groups or teams to view the desired requests.</p></div>;
} else {
table = (
<UITable
Expand Down