-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make order setting mandatory for Realm config #51195
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
Changes from 23 commits
65cf24c
d186b0a
82e08d2
71bfb3e
5370163
1132f5f
7fa20a3
3d724e8
adca1bf
0f60b22
3cb7a83
22399ce
0edef24
b439a49
9548e2f
a74482e
e0aa65b
994c0af
da8e7e3
7fbf061
472b2d6
64d0292
aad6d19
84cb684
4c61828
c264e31
43fffa3
0614cbc
fe13c71
ad7a1b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,9 @@ However, multiple bind operations might be needed to find the correct user DN. | |
|
|
||
| .. Add a realm configuration of to `elasticsearch.yml` under the | ||
| `xpack.security.authc.realms.ldap` namespace. At a minimum, you must specify | ||
| the `url` of the LDAP server, and set `user_search.base_dn` to the container DN | ||
| where the users are searched for. | ||
| If you are configuring multiple realms, you should also explicitly set the | ||
| `order` attribute to control the order in which the realms are consulted during | ||
| the `url` and `order` of the LDAP server, and set `user_search.base_dn` to the | ||
| container DN where the users are searched for. | ||
| The `order` attribute to control the order in which the realms are consulted during | ||
| authentication. See <<ref-ldap-settings>> for all of the options you can set for | ||
|
||
| an `ldap` realm. | ||
| + | ||
|
|
@@ -73,7 +72,7 @@ realms you specify are used for authentication. If you also want to use the | |
| .. Add a realm configuration to `elasticsearch.yml` in the | ||
| `xpack.security.authc.realms.ldap` namespace. At a minimum, you must specify | ||
| the `url` of the LDAP server, and specify at least one template with the | ||
| `user_dn_templates` option. If you are configuring multiple realms, you should | ||
| `user_dn_templates` option. If you are configuring multiple realms, you must | ||
| also explicitly set the `order` attribute to control the order in which the | ||
| realms are consulted during authentication. | ||
|
||
| See <<ref-ldap-settings>> for all of the options you can set for an `ldap` realm. | ||
|
|
@@ -206,6 +205,7 @@ xpack: | |
| realms: | ||
| ldap: | ||
| ldap1: | ||
| order: 0 | ||
ywangd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| metadata: cn | ||
| -------------------------------------------------- | ||
| -- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * | ||
| * * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * * or more contributor license agreements. Licensed under the Elastic License; | ||
| * * you may not use this file except in compliance with the Elastic License. | ||
| * | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.core.security.authc; | ||
|
|
||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
| import org.elasticsearch.env.Environment; | ||
| import org.elasticsearch.test.ESTestCase; | ||
| import org.junit.Before; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
||
| public class RealmConfigTests extends ESTestCase { | ||
|
|
||
| private RealmConfig.RealmIdentifier realmIdentifier; | ||
| private Settings globalSettings; | ||
| private Environment environment; | ||
| private ThreadContext threadContext; | ||
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
| realmIdentifier = new RealmConfig.RealmIdentifier(randomAlphaOfLengthBetween(4, 12), randomAlphaOfLengthBetween(4,12)); | ||
| environment = Mockito.mock(Environment.class); | ||
| globalSettings = Settings.builder().put("path.home", createTempDir()).build(); | ||
| threadContext = new ThreadContext(globalSettings); | ||
| super.setUp(); | ||
| } | ||
|
|
||
| public void testWillPassWhenOrderSettingIsConfigured() { | ||
| Settings settings = Settings.builder() | ||
| .put(globalSettings) | ||
| .put(RealmSettings.realmSettingPrefix(realmIdentifier) + "order", 0) | ||
| .build(); | ||
|
|
||
| RealmConfig realmConfig = new RealmConfig(realmIdentifier, settings, environment, threadContext); | ||
| assertEquals(0, realmConfig.order); | ||
| } | ||
|
|
||
| public void testWillFailWhenOrderSettingIsMissing() { | ||
| Settings settings = Settings.builder().put(globalSettings).build(); | ||
| var e = expectThrows(IllegalArgumentException.class, () -> new RealmConfig(realmIdentifier, settings, environment, threadContext)); | ||
| assertThat(e.getMessage(), containsString("'order' is a mandatory parameter for realm config")); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.