-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[Kerberos] Add authorization realms support to Kerberos realm #32392
Merged
bizybot
merged 8 commits into
elastic:security-lookup-realms
from
bizybot:kerberos-lookup-realm-support
Aug 2, 2018
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
da5a808
[Kerberos] Add authorization realms support to Kerberos realm
ccec8aa
Merge branch 'security-lookup-realms' into kerberos-lookup-realm-support
79491e4
[Kerberos] Add authorization settings to Kerberos realm settings
fcad655
Merge branch 'security-lookup-realms' into kerberos-lookup-realm-support
e465e08
[Kerberos] Address review comments
67b06d9
Merge branch 'security-lookup-realms' into kerberos-lookup-realm-support
846017d
Merge branch 'security-lookup-realms' into kerberos-lookup-realm-support
3d5c2b8
[Kerberos] Changes to use `authorization_realms`
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,13 @@ | |
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.common.util.set.Sets; | ||
import org.elasticsearch.env.TestEnvironment; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.threadpool.TestThreadPool; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.watcher.ResourceWatcherService; | ||
import org.elasticsearch.xpack.core.security.authc.AuthenticationResult; | ||
import org.elasticsearch.xpack.core.security.authc.Realm; | ||
import org.elasticsearch.xpack.core.security.authc.RealmConfig; | ||
import org.elasticsearch.xpack.core.security.authc.kerberos.KerberosRealmSettings; | ||
import org.elasticsearch.xpack.core.security.support.Exceptions; | ||
|
@@ -30,6 +32,7 @@ | |
|
||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
@@ -58,6 +61,7 @@ public abstract class KerberosRealmTestCase extends ESTestCase { | |
|
||
protected KerberosTicketValidator mockKerberosTicketValidator; | ||
protected NativeRoleMappingStore mockNativeRoleMappingStore; | ||
protected XPackLicenseState licenseState; | ||
|
||
protected static final Set<String> roles = Sets.newHashSet("admin", "kibana_user"); | ||
|
||
|
@@ -69,6 +73,8 @@ public void setup() throws Exception { | |
globalSettings = Settings.builder().put("path.home", dir).build(); | ||
settings = KerberosTestCase.buildKerberosRealmSettings(KerberosTestCase.writeKeyTab(dir.resolve("key.keytab"), "asa").toString(), | ||
100, "10m", true, randomBoolean()); | ||
licenseState = mock(XPackLicenseState.class); | ||
when(licenseState.isAuthorizingRealmAllowed()).thenReturn(true); | ||
} | ||
|
||
@After | ||
|
@@ -101,13 +107,20 @@ protected void assertSuccessAuthenticationResult(final User expectedUser, final | |
is(equalTo(KerberosAuthenticationToken.NEGOTIATE_AUTH_HEADER_PREFIX + outToken))); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: drop this extra line |
||
protected KerberosRealm createKerberosRealm(final String... userForRoleMapping) { | ||
return createKerberosRealm(Collections.emptyList(), userForRoleMapping); | ||
} | ||
|
||
protected KerberosRealm createKerberosRealm(final List<Realm> delegatedRealms, final String... userForRoleMapping) { | ||
config = new RealmConfig("test-kerb-realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), | ||
new ThreadContext(globalSettings)); | ||
mockNativeRoleMappingStore = roleMappingStore(Arrays.asList(userForRoleMapping)); | ||
mockKerberosTicketValidator = mock(KerberosTicketValidator.class); | ||
final KerberosRealm kerberosRealm = | ||
new KerberosRealm(config, mockNativeRoleMappingStore, mockKerberosTicketValidator, threadPool, null); | ||
Collections.shuffle(delegatedRealms, random()); | ||
kerberosRealm.initialize(delegatedRealms, licenseState); | ||
return kerberosRealm; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to cache here. The delegated realm resolved the user and it should be caching it. The kerberos realm will never use the cache entry that we add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I too did not want to add caching here but thought it would be consistent with others. I will remove it. Thank you.