-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] Make all providers to preserve original URL when session expire…
…s. (#84743)
- Loading branch information
Showing
40 changed files
with
322 additions
and
168 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
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/security/common/model/authentication_provider.test.ts
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { shouldProviderUseLoginForm } from './authentication_provider'; | ||
|
||
describe('#shouldProviderUseLoginForm', () => { | ||
['basic', 'token'].forEach((providerType) => { | ||
it(`returns "true" for "${providerType}" provider`, () => { | ||
expect(shouldProviderUseLoginForm(providerType)).toEqual(true); | ||
}); | ||
}); | ||
|
||
['anonymous', 'http', 'kerberos', 'oidc', 'pki', 'saml'].forEach((providerType) => { | ||
it(`returns "false" for "${providerType}" provider`, () => { | ||
expect(shouldProviderUseLoginForm(providerType)).toEqual(false); | ||
}); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/security/common/model/authentication_provider.ts
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Type and name tuple to identify provider used to authenticate user. | ||
*/ | ||
export interface AuthenticationProvider { | ||
type: string; | ||
name: string; | ||
} | ||
|
||
/** | ||
* Checks whether authentication provider with the specified type uses Kibana's native login form. | ||
* @param providerType Type of the authentication provider. | ||
*/ | ||
export function shouldProviderUseLoginForm(providerType: string) { | ||
return providerType === 'basic' || providerType === 'token'; | ||
} |
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
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/security/public/authentication/logged_out/logged_out_page.test.tsx
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiButton } from '@elastic/eui'; | ||
import { mountWithIntl } from '@kbn/test/jest'; | ||
import { LoggedOutPage } from './logged_out_page'; | ||
|
||
import { coreMock } from '../../../../../../src/core/public/mocks'; | ||
|
||
describe('LoggedOutPage', () => { | ||
beforeAll(() => { | ||
Object.defineProperty(window, 'location', { | ||
value: { href: 'https://some-host' }, | ||
writable: true, | ||
}); | ||
}); | ||
|
||
it('points to a base path if `next` parameter is not provided', async () => { | ||
const basePathMock = coreMock.createStart({ basePath: '/mock-base-path' }).http.basePath; | ||
const wrapper = mountWithIntl(<LoggedOutPage basePath={basePathMock} />); | ||
|
||
expect(wrapper.find(EuiButton).prop('href')).toBe('/mock-base-path/'); | ||
}); | ||
|
||
it('properly parses `next` parameter', async () => { | ||
window.location.href = `https://host.com/mock-base-path/security/logged_out?next=${encodeURIComponent( | ||
'/mock-base-path/app/home#/?_g=()' | ||
)}`; | ||
|
||
const basePathMock = coreMock.createStart({ basePath: '/mock-base-path' }).http.basePath; | ||
const wrapper = mountWithIntl(<LoggedOutPage basePath={basePathMock} />); | ||
|
||
expect(wrapper.find(EuiButton).prop('href')).toBe('/mock-base-path/app/home#/?_g=()'); | ||
}); | ||
}); |
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
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
Oops, something went wrong.