kibana/x-pack/plugins/security/server/errors.ts
Aleh Zasypkin 91e1d9c712
Migrate authentication subsystem to the new platform. (#39446)
* Temporary Core workarounds.

* Move files to NP Security Plugin.

* Fix references.

* Migrate to the New Platform.

* Review#1: remove unused `loginAttempt` from provider iterator, rely more on RecursiveReadonly, etc.

* Integrate latest core changes: isTlsEnabled and get rid of legacy ES config.

* Revert `deepFreeze` changes and rely on `src/core/utils`.

* Review#2: do not mutate injectedVars in onInit. Integrate latest upstream changes.

* Use mocks provided by the Core.

* Expect ElasticsearchError instead of Boom errors as 401 Cluster client errors.

* Simplify session handling for `login`.

* Review#3: properly handle session updates for `login`, remove redundant hapi-auth-cookie deps from x-pack package.json, migrate to new core sessionStorage API, integrate latest Kerberos provider changes from upstream

* Do not clear session on login if it does not exist.
2019-07-19 11:09:49 +02:00

19 lines
670 B
TypeScript

/*
* 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 Boom from 'boom';
export function wrapError(error: any) {
return Boom.boomify(error, { statusCode: getErrorStatusCode(error) });
}
/**
* Extracts error code from Boom and Elasticsearch "native" errors.
* @param error Error instance to extract status code from.
*/
export function getErrorStatusCode(error: any): number {
return Boom.isBoom(error) ? error.output.statusCode : error.statusCode || error.status;
}