mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Fixing expired license redirection (#156703)
Fixes https://github.com/elastic/kibana/issues/150539
When handling route resolver errors, we now check to see if the error
was triggered by an expired license, if so we redirect to the license
management page rather than the access denied page.
This is hard to test as you need an expired license. One way to spoof
this is by editing code in the licensing plugin to inject expired
license details.
```
response.license.expiry_date_in_millis = 1683205426704;
response.license.status = 'expired';
```
Adding this below [this
line](411ff0d0ae/x-pack/plugins/licensing/server/plugin.ts (L184)
).
This commit is contained in:
parent
0e259c8598
commit
14f5b9e883
1 changed files with 14 additions and 4 deletions
|
@ -20,6 +20,7 @@ import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';
|
|||
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { StorageContextProvider } from '@kbn/ml-local-storage';
|
||||
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { mlCapabilities } from './capabilities/check_capabilities';
|
||||
import { ML_STORAGE_KEYS } from '../../common/types/storage';
|
||||
import { ML_APP_LOCATOR, ML_PAGES } from '../../common/constants/locator';
|
||||
|
@ -74,10 +75,19 @@ export type MlGlobalServices = ReturnType<typeof getMlGlobalServices>;
|
|||
|
||||
const App: FC<AppProps> = ({ coreStart, deps, appMountParams }) => {
|
||||
const redirectToMlAccessDeniedPage = async () => {
|
||||
const accessDeniedPageUrl = await deps.share.url.locators.get(ML_APP_LOCATOR)!.getUrl({
|
||||
page: ML_PAGES.ACCESS_DENIED,
|
||||
});
|
||||
await coreStart.application.navigateToUrl(accessDeniedPageUrl);
|
||||
// access maybe be denied due to an expired license, so check the license status first
|
||||
// if the license has expired, redirect to the license management page
|
||||
const license = await firstValueFrom(deps.licensing.license$);
|
||||
const redirectPage =
|
||||
license.status === 'expired'
|
||||
? deps.share.url.locators.get('LICENSE_MANAGEMENT_LOCATOR')!.getUrl({
|
||||
page: 'dashboard',
|
||||
})
|
||||
: deps.share.url.locators.get(ML_APP_LOCATOR)!.getUrl({
|
||||
page: ML_PAGES.ACCESS_DENIED,
|
||||
});
|
||||
|
||||
await coreStart.application.navigateToUrl(await redirectPage);
|
||||
};
|
||||
|
||||
const pageDeps = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue