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

Include enabled roles in QueryContext for event listeners #18994

Merged
merged 1 commit into from
Sep 15, 2023
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 @@ -345,6 +345,7 @@ private QueryContext createQueryContext(SessionRepresentation session, Optional<
session.getUser(),
session.getOriginalUser(),
session.getPrincipal(),
session.getEnabledRoles(),
session.getGroups(),
session.getTraceToken(),
session.getRemoteUserAddress(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class QueryContext
private final String user;
private final String originalUser;
private final Optional<String> principal;
private final Set<String> enabledRoles;
private final Set<String> groups;
private final Optional<String> traceToken;
private final Optional<String> remoteClientAddress;
Expand Down Expand Up @@ -65,6 +66,7 @@ public QueryContext(
String user,
String originalUser,
Optional<String> principal,
Set<String> enabledRoles,
Set<String> groups,
Optional<String> traceToken,
Optional<String> remoteClientAddress,
Expand All @@ -87,6 +89,7 @@ public QueryContext(
this.user = requireNonNull(user, "user is null");
this.originalUser = requireNonNull(originalUser, "originalUser is null");
this.principal = requireNonNull(principal, "principal is null");
this.enabledRoles = requireNonNull(enabledRoles, "enabledRoles is null");
this.groups = requireNonNull(groups, "groups is null");
this.traceToken = requireNonNull(traceToken, "traceToken is null");
this.remoteClientAddress = requireNonNull(remoteClientAddress, "remoteClientAddress is null");
Expand Down Expand Up @@ -125,6 +128,12 @@ public Optional<String> getPrincipal()
return principal;
}

@JsonProperty
public Set<String> getEnabledRoles()
{
return enabledRoles;
}

@JsonProperty
public Set<String> getGroups()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public class TestHttpEventListener
"user",
"originalUser",
Optional.of("principal"),
Set.of(), // enabledRoles
Set.of(), // groups
Optional.empty(), // traceToken
Optional.empty(), // remoteClientAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class TestMysqlEventListener
"user",
"originalUser",
Optional.of("principal"),
Set.of("role1", "role2"),
Set.of("group1", "group2"),
Optional.of("traceToken"),
Optional.of("remoteAddress"),
Expand Down Expand Up @@ -288,6 +289,7 @@ public class TestMysqlEventListener
"originalUser",
Optional.empty(),
Set.of(),
Set.of(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Expand Down
Loading