-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Make all providers to preserve original URL when session expires. #84229
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
}); | ||
}); | ||
}); |
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'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,7 @@ | |
* 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 { | ||
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. question I'm 100% fine with the move, but I'm just curious: what was the motivation for moving this interface out of 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. Mostly because I wanted to group interface with the relevant helper function |
||
type: string; | ||
name: string; | ||
} | ||
import type { AuthenticationProvider } from './model'; | ||
|
||
export interface SessionInfo { | ||
now: number; | ||
|
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=()'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { AuthenticationProvider } from '../../common/types'; | ||
import type { AuthenticationProvider } from '../../common/model'; | ||
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. question: you've been great about updating these import statements to 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. Haha, nope, WebStorm doesn't suggest that change yet. I think I just shuffled |
||
import { LegacyAuditLogger } from './audit_service'; | ||
|
||
/** | ||
|
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.
note: I'm not a fan of moving params to the consts since it usually makes it harder to find the code that uses them. But in this specific case these parameter names are so generic that it's much easier to rely on the unique const names to find all relevant places.