mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -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 = {
|
||||
create: (features?: Partial<SecurityLicenseFeatures>): jest.Mocked<SecurityLicense> => ({
|
||||
license$: {} as any,
|
||||
isLicenseAvailable: jest.fn().mockReturnValue(true),
|
||||
isEnabled: jest.fn().mockReturnValue(true),
|
||||
getType: jest.fn().mockReturnValue('basic'),
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface SecurityLicense {
|
|||
isEnabled(): boolean;
|
||||
getType(): LicenseType | undefined;
|
||||
getFeatures(): SecurityLicenseFeatures;
|
||||
license$: Observable<ILicense>;
|
||||
features$: Observable<SecurityLicenseFeatures>;
|
||||
}
|
||||
|
||||
|
@ -28,11 +29,15 @@ export class SecurityLicenseService {
|
|||
let rawLicense: Readonly<ILicense> | undefined;
|
||||
|
||||
this.licenseSubscription = license$.subscribe((nextRawLicense) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('***** NEXT RAW LICENSE');
|
||||
rawLicense = nextRawLicense;
|
||||
});
|
||||
|
||||
return {
|
||||
license: Object.freeze({
|
||||
license$,
|
||||
|
||||
isLicenseAvailable: () => rawLicense?.isAvailable ?? false,
|
||||
|
||||
isEnabled: () => this.isSecurityEnabledFromRawLicense(rawLicense),
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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 {
|
||||
LoggerFactory,
|
||||
|
@ -66,6 +67,10 @@ export class AuthenticationService {
|
|||
this.license = license;
|
||||
|
||||
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()) {
|
||||
this.logger.error('License is not available, authentication is not possible.');
|
||||
return response.customError({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue