Skip to content
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
5 changes: 5 additions & 0 deletions docs/changelog/114337.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 114337
summary: "Enables cluster state role mapper, to include ECK operator-defined role mappings in role resolution"
area: Authentication
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase {
}
}""";

@Override
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
Settings.Builder builder = Settings.builder()
.put(super.nodeSettings(nodeOrdinal, otherSettings))
// some tests make use of cluster-state based role mappings
.put("xpack.security.authc.cluster_state_role_mappings.enabled", true);
return builder.build();
}

@After
public void cleanUp() {
updateClusterSettings(Settings.builder().putNull("indices.recovery.max_bytes_per_sec"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ private void clearRoleMappings() throws InterruptedException {
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
Settings.Builder builder = Settings.builder()
.put(super.nodeSettings(nodeOrdinal, otherSettings))
// some tests make use of cluster-state based role mappings
.put("xpack.security.authc.cluster_state_role_mappings.enabled", true)
.put(XPackSettings.TOKEN_SERVICE_ENABLED_SETTING.getKey(), randomBoolean())
// 1st JWT realm
.put("xpack.security.authc.realms.jwt.jwt0.order", 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
public final class ClusterStateRoleMapper extends AbstractRoleMapperClearRealmCache implements ClusterStateListener {

/**
* This setting is never registered by the xpack security plugin - in order to enable the
* This setting is never registered by the xpack security plugin - in order to disable the
* cluster-state based role mapper another plugin must register it as a boolean setting
* and set it to `true`.
* and set it to `false`.
* If this setting is set to <code>true</code> then:
* <ul>
* <li>Realms that make use role mappings (all realms but file and native) will,
Expand All @@ -54,8 +54,8 @@ public final class ClusterStateRoleMapper extends AbstractRoleMapperClearRealmCa
public ClusterStateRoleMapper(Settings settings, ScriptService scriptService, ClusterService clusterService) {
this.scriptService = scriptService;
this.clusterService = clusterService;
// this role mapper is disabled by default and only code in other plugins can enable it
this.enabled = settings.getAsBoolean(CLUSTER_STATE_ROLE_MAPPINGS_ENABLED, false);
// this role mapper is enabled by default and only code in other plugins can disable it
this.enabled = settings.getAsBoolean(CLUSTER_STATE_ROLE_MAPPINGS_ENABLED, true);
if (this.enabled) {
clusterService.addListener(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public static class UnregisteredSecuritySettingsPlugin extends Plugin {
);
public static final Setting<Boolean> CLUSTER_STATE_ROLE_MAPPINGS_ENABLED = Setting.boolSetting(
"xpack.security.authc.cluster_state_role_mappings.enabled",
false,
true,
Setting.Property.NodeScope
);
public static final Setting<Boolean> NATIVE_ROLES_ENABLED = Setting.boolSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public void setup() {
() -> 1L
);
clusterService = mock(ClusterService.class);
enabledSettings = Settings.builder().put("xpack.security.authc.cluster_state_role_mappings.enabled", true).build();
disabledSettings = Settings.builder().put("xpack.security.authc.cluster_state_role_mappings.enabled", false).build();
if (randomBoolean()) {
disabledSettings = Settings.builder().put("xpack.security.authc.cluster_state_role_mappings.enabled", false).build();
enabledSettings = Settings.builder().put("xpack.security.authc.cluster_state_role_mappings.enabled", true).build();
} else {
// the cluster state role mapper is disabled by default
disabledSettings = Settings.EMPTY;
// the cluster state role mapper is enabled by default
enabledSettings = Settings.EMPTY;
}
}

Expand Down
Loading