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
6 changes: 5 additions & 1 deletion x-pack/legacy/server/lib/esjs_shield_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
* @param {Array.<string>} ids A list of encrypted request tokens returned within SAML
* preparation response.
* @param {string} content SAML response returned by identity provider.
* @param {string} [realm] Optional string used to identify the name of the OpenID Connect realm
* that should be used to authenticate request.
*
* @returns {{username: string, access_token: string, expires_in: number}} Object that
* includes name of the user, access token to use for any consequent requests that
Expand Down Expand Up @@ -373,6 +375,8 @@
* @param {string} nonce The nonce parameter that was returned by Elasticsearch in the
* preparation response.
* @param {string} redirect_uri The URL to where the UA was redirected by the OpenID Connect provider.
* @param {string} [realm] Optional string used to identify the name of the OpenID Connect realm
* that should be used to authenticate request.
*
* @returns {{username: string, access_token: string, refresh_token; string, expires_in: number}} Object that
* includes name of the user, access token to use for any consequent requests that
Expand All @@ -391,7 +395,7 @@
*
* @param {string} token An access token that was created by authenticating to an OpenID Connect realm and
* that needs to be invalidated.
* @param {string} refres_token A refresh token that was created by authenticating to an OpenID Connect realm and
* @param {string} refresh_token A refresh token that was created by authenticating to an OpenID Connect realm and
* that needs to be invalidated.
*
* @returns {{redirect?: string}} If the Elasticsearch OpenID Connect realm configuration and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ describe('OIDCAuthenticationProvider', () => {
sinon.assert.calledWithExactly(
mockOptions.client.callAsInternalUser,
'shield.oidcAuthenticate',
{ body: { state: 'statevalue', nonce: 'noncevalue', redirect_uri: expectedRedirectURI } }
{
body: {
state: 'statevalue',
nonce: 'noncevalue',
redirect_uri: expectedRedirectURI,
realm: 'oidc1',
},
}
);

expect(authenticationResult.redirected()).toBe(true);
Expand Down Expand Up @@ -180,7 +187,14 @@ describe('OIDCAuthenticationProvider', () => {
sinon.assert.calledWithExactly(
mockOptions.client.callAsInternalUser,
'shield.oidcAuthenticate',
{ body: { state: 'statevalue', nonce: 'noncevalue', redirect_uri: expectedRedirectURI } }
{
body: {
state: 'statevalue',
nonce: 'noncevalue',
redirect_uri: expectedRedirectURI,
realm: 'oidc1',
},
}
);

expect(authenticationResult.failed()).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ export class OIDCAuthenticationProvider extends BaseAuthenticationProvider {
access_token: accessToken,
refresh_token: refreshToken,
} = await this.options.client.callAsInternalUser('shield.oidcAuthenticate', {
body: { state: stateOIDCState, nonce: stateNonce, redirect_uri: authenticationResponseURI },
body: {
state: stateOIDCState,
nonce: stateNonce,
redirect_uri: authenticationResponseURI,
realm: this.realm,
},
});

this.logger.debug('Request has been authenticated via OpenID Connect.');
Expand Down
Loading