mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
(will be reverted) explicitly await for license to be ready in the auth hook
This commit is contained in:
parent
d3a24d0cc7
commit
fdf73feb0a
3 changed files with 11 additions and 0 deletions
|
@ -9,6 +9,7 @@ import { SecurityLicense, SecurityLicenseFeatures } from '.';
|
||||||
|
|
||||||
export const licenseMock = {
|
export const licenseMock = {
|
||||||
create: (features?: Partial<SecurityLicenseFeatures>): jest.Mocked<SecurityLicense> => ({
|
create: (features?: Partial<SecurityLicenseFeatures>): jest.Mocked<SecurityLicense> => ({
|
||||||
|
license$: {} as any,
|
||||||
isLicenseAvailable: jest.fn().mockReturnValue(true),
|
isLicenseAvailable: jest.fn().mockReturnValue(true),
|
||||||
isEnabled: jest.fn().mockReturnValue(true),
|
isEnabled: jest.fn().mockReturnValue(true),
|
||||||
getType: jest.fn().mockReturnValue('basic'),
|
getType: jest.fn().mockReturnValue('basic'),
|
||||||
|
|
|
@ -14,6 +14,7 @@ export interface SecurityLicense {
|
||||||
isEnabled(): boolean;
|
isEnabled(): boolean;
|
||||||
getType(): LicenseType | undefined;
|
getType(): LicenseType | undefined;
|
||||||
getFeatures(): SecurityLicenseFeatures;
|
getFeatures(): SecurityLicenseFeatures;
|
||||||
|
license$: Observable<ILicense>;
|
||||||
features$: Observable<SecurityLicenseFeatures>;
|
features$: Observable<SecurityLicenseFeatures>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +29,15 @@ export class SecurityLicenseService {
|
||||||
let rawLicense: Readonly<ILicense> | undefined;
|
let rawLicense: Readonly<ILicense> | undefined;
|
||||||
|
|
||||||
this.licenseSubscription = license$.subscribe((nextRawLicense) => {
|
this.licenseSubscription = license$.subscribe((nextRawLicense) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('***** NEXT RAW LICENSE');
|
||||||
rawLicense = nextRawLicense;
|
rawLicense = nextRawLicense;
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
license: Object.freeze({
|
license: Object.freeze({
|
||||||
|
license$,
|
||||||
|
|
||||||
isLicenseAvailable: () => rawLicense?.isAvailable ?? false,
|
isLicenseAvailable: () => rawLicense?.isAvailable ?? false,
|
||||||
|
|
||||||
isEnabled: () => this.isSecurityEnabledFromRawLicense(rawLicense),
|
isEnabled: () => this.isSecurityEnabledFromRawLicense(rawLicense),
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||||
import type {
|
import type {
|
||||||
LoggerFactory,
|
LoggerFactory,
|
||||||
|
@ -66,6 +67,10 @@ export class AuthenticationService {
|
||||||
this.license = license;
|
this.license = license;
|
||||||
|
|
||||||
http.registerAuth(async (request, response, t) => {
|
http.registerAuth(async (request, response, t) => {
|
||||||
|
await license.license$.pipe(take(1)).toPromise();
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('***** AWAIT REGISTER AUTH COMPLETE');
|
||||||
|
|
||||||
if (!license.isLicenseAvailable()) {
|
if (!license.isLicenseAvailable()) {
|
||||||
this.logger.error('License is not available, authentication is not possible.');
|
this.logger.error('License is not available, authentication is not possible.');
|
||||||
return response.customError({
|
return response.customError({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue