-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add populate_user_metadata in OIDC realm (#48357)
Make populate_user_metadata configuration parameter available in the OpenID Connect authentication realm Resolves: #48217
- Loading branch information
Showing
2 changed files
with
6 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
import org.elasticsearch.xpack.core.security.authc.Realm; | ||
import org.elasticsearch.xpack.core.security.authc.RealmConfig; | ||
import org.elasticsearch.xpack.core.security.authc.oidc.OpenIdConnectRealmSettings; | ||
import org.elasticsearch.xpack.core.security.authc.saml.SamlRealmSettings; | ||
import org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings; | ||
import org.elasticsearch.xpack.core.security.user.User; | ||
import org.elasticsearch.xpack.security.authc.support.MockLookupRealm; | ||
|
@@ -87,7 +86,9 @@ public void testAuthentication() throws Exception { | |
assertThat(result.getUser().email(), equalTo("[email protected]")); | ||
assertThat(result.getUser().fullName(), equalTo("Clinton Barton")); | ||
assertThat(result.getUser().roles(), arrayContainingInAnyOrder("kibana_user", "role1")); | ||
if (notPopulateMetadata == false) { | ||
if (notPopulateMetadata) { | ||
assertThat(result.getUser().metadata().size(), equalTo(0)); | ||
} else { | ||
assertThat(result.getUser().metadata().get("oidc(iss)"), equalTo("https://op.company.org")); | ||
assertThat(result.getUser().metadata().get("oidc(name)"), equalTo("Clinton Barton")); | ||
} | ||
|
@@ -308,7 +309,7 @@ private AuthenticationResult authenticateWithOidc(String principal, UserRoleMapp | |
|
||
final Settings.Builder builder = getBasicRealmSettings(); | ||
if (notPopulateMetadata) { | ||
builder.put(getFullSettingKey(REALM_NAME, SamlRealmSettings.POPULATE_USER_METADATA), | ||
builder.put(getFullSettingKey(REALM_NAME, OpenIdConnectRealmSettings.POPULATE_USER_METADATA), | ||
false); | ||
} | ||
if (useAuthorizingRealm) { | ||
|