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

Minor: Domain only access policy prevents bots from listing #19017

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Minor: Domain only access policy prevents bots listing
harshach committed Dec 12, 2024
commit 3607d8dd0f3b9192a0a879b85e98ea13000d535f
Original file line number Diff line number Diff line change
@@ -116,12 +116,20 @@ public String getTestSuiteFQNCondition() {

private String getDomainCondition(String tableName) {
String domainId = getQueryParam("domainId");
return domainId == null
? ""
: String.format(
"(%s in (SELECT entity_relationship.toId FROM entity_relationship WHERE entity_relationship.fromEntity='domain' AND entity_relationship.fromId IN (%s) AND "
+ "relation=10))",
nullOrEmpty(tableName) ? "id" : String.format("%s.id", tableName), domainId);
String entityIdColumn = nullOrEmpty(tableName) ? "id" : (tableName + ".id");

if (domainId == null) {
return "";
} else if ("null".equals(domainId)) {
return String.format(
"(%s NOT IN (SELECT entity_relationship.toId FROM entity_relationship WHERE entity_relationship.fromEntity='domain' AND relation=10))",
entityIdColumn);
} else {
return String.format(
"(%s in (SELECT entity_relationship.toId FROM entity_relationship WHERE entity_relationship.fromEntity='domain' AND entity_relationship.fromId IN (%s) AND "
+ "relation=10))",
entityIdColumn, domainId);
}
}

public String getApiCollectionCondition(String apiEndpoint) {
Original file line number Diff line number Diff line change
@@ -692,7 +692,9 @@ public static void addDomainQueryParam(SecurityContext securityContext, ListFilt
SubjectContext subjectContext = getSubjectContext(securityContext);
// If the User is admin then no need to add domainId in the query param
// Also if there are domain restriction on the subject context via role
if (!subjectContext.isAdmin() && !subjectContext.isBot() && subjectContext.hasAnyRole(DOMAIN_ONLY_ACCESS_ROLE)) {
if (!subjectContext.isAdmin()
&& !subjectContext.isBot()
&& subjectContext.hasAnyRole(DOMAIN_ONLY_ACCESS_ROLE)) {
if (!nullOrEmpty(subjectContext.getUserDomains())) {
filter.addQueryParam(
"domainId", getCommaSeparatedIdsFromRefs(subjectContext.getUserDomains()));