Skip to content

Commit 751b7f2

Browse files
authored
[7.x] Implement AnonymousAuthenticationProvider. (#84055)
1 parent 078322f commit 751b7f2

File tree

32 files changed

+1847
-205
lines changed

32 files changed

+1847
-205
lines changed

test/functional/services/common/browser.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
197197
return await driver.get(url);
198198
}
199199

200+
/**
201+
* Retrieves the cookie with the given name. Returns null if there is no such cookie. The cookie will be returned as
202+
* a JSON object as described by the WebDriver wire protocol.
203+
* https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_Options.html
204+
*
205+
* @param {string} cookieName
206+
* @return {Promise<IWebDriverCookie>}
207+
*/
208+
public async getCookie(cookieName: string) {
209+
return await driver.manage().getCookie(cookieName);
210+
}
211+
200212
/**
201213
* Moves the remote environment’s mouse cursor to the specified point {x, y} which is
202214
* offset to browser page top left corner.

x-pack/plugins/security/common/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ export const UNKNOWN_SPACE = '?';
1717
export const GLOBAL_RESOURCE = '*';
1818
export const APPLICATION_PREFIX = 'kibana-';
1919
export const RESERVED_PRIVILEGES_APPLICATION_WILDCARD = 'kibana-*';
20+
21+
export const AUTH_PROVIDER_HINT_QUERY_STRING_PARAMETER = 'auth_provider_hint';

x-pack/plugins/security/common/login_state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface LoginSelectorProvider {
1010
type: string;
1111
name: string;
1212
usesLoginForm: boolean;
13+
showInSelector: boolean;
1314
description?: string;
1415
hint?: string;
1516
icon?: string;

x-pack/plugins/security/common/model/authenticated_user.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ describe('#canUserChangePassword', () => {
2020
} as AuthenticatedUser)
2121
).toEqual(true);
2222
});
23+
24+
it(`returns false for users in the ${realm} realm if used for anonymous access`, () => {
25+
expect(
26+
canUserChangePassword({
27+
username: 'foo',
28+
authentication_provider: { type: 'anonymous', name: 'does not matter' },
29+
authentication_realm: {
30+
name: 'the realm name',
31+
type: realm,
32+
},
33+
} as AuthenticatedUser)
34+
).toEqual(false);
35+
});
2336
});
2437

2538
it(`returns false for all other realms`, () => {

x-pack/plugins/security/common/model/authenticated_user.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ export interface AuthenticatedUser extends User {
4242
}
4343

4444
export function canUserChangePassword(user: AuthenticatedUser) {
45-
return REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE.includes(user.authentication_realm.type);
45+
return (
46+
REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE.includes(user.authentication_realm.type) &&
47+
user.authentication_provider.type !== 'anonymous'
48+
);
4649
}

x-pack/plugins/security/public/authentication/login/__snapshots__/login_page.test.tsx.snap

Lines changed: 0 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)