-
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.
- Loading branch information
Showing
71 changed files
with
1,879 additions
and
1,256 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// @ts-ignore | ||
import { uiModules } from 'ui/modules'; | ||
import { npSetup, npStart } from 'ui/new_platform'; | ||
import routes from 'ui/routes'; | ||
import { isSystemApiRequest } from '../../../../../../src/plugins/kibana_legacy/public'; | ||
import { SecurityPluginSetup } from '../../../../../plugins/security/public'; | ||
|
||
const securityPluginSetup = (npSetup.plugins as any).security as SecurityPluginSetup; | ||
if (securityPluginSetup) { | ||
routes.when('/account', { | ||
template: '<div />', | ||
controller: () => npStart.core.application.navigateToApp('security'), | ||
}); | ||
|
||
const getNextParameter = () => { | ||
const { location } = window; | ||
const next = encodeURIComponent(`${location.pathname}${location.search}${location.hash}`); | ||
return `&next=${next}`; | ||
}; | ||
|
||
const getProviderParameter = (tenant: string) => { | ||
const key = `${tenant}/session_provider`; | ||
const providerName = sessionStorage.getItem(key); | ||
return providerName ? `&provider=${encodeURIComponent(providerName)}` : ''; | ||
}; | ||
|
||
const module = uiModules.get('security', []); | ||
module.config(($httpProvider: ng.IHttpProvider) => { | ||
$httpProvider.interceptors.push(($q, $window, Promise) => { | ||
const isAnonymous = npSetup.core.http.anonymousPaths.isAnonymous(window.location.pathname); | ||
|
||
function interceptorFactory(responseHandler: (response: ng.IHttpResponse<unknown>) => any) { | ||
return function interceptor(response: ng.IHttpResponse<unknown>) { | ||
// TODO: SHOULD WE CHECK THAT IT'S NOT ERROR RESPONSE (&& response.status !== 401)? | ||
if (!isAnonymous && !isSystemApiRequest(response.config)) { | ||
securityPluginSetup.sessionTimeout.extend(response.config.url); | ||
} | ||
|
||
if (response.status !== 401 || isAnonymous) { | ||
return responseHandler(response); | ||
} | ||
|
||
const { logoutUrl, tenant } = securityPluginSetup.__legacyCompat; | ||
const next = getNextParameter(); | ||
const provider = getProviderParameter(tenant); | ||
|
||
$window.location.href = `${logoutUrl}?msg=SESSION_EXPIRED${next}${provider}`; | ||
|
||
return Promise.halt(); | ||
}; | ||
} | ||
|
||
return { | ||
response: interceptorFactory(response => response), | ||
responseError: interceptorFactory($q.reject), | ||
}; | ||
}); | ||
}); | ||
} |
31 changes: 0 additions & 31 deletions
31
x-pack/legacy/plugins/security/public/hacks/on_session_timeout.js
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
x-pack/legacy/plugins/security/public/hacks/on_unauthorized_response.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
x-pack/legacy/plugins/security/public/services/auto_logout.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.