Skip to content

Commit

Permalink
Change typings to reflect non-optional security dep
Browse files Browse the repository at this point in the history
+ update KibanaLogic to no longer need a {} fallback
  • Loading branch information
cee-chen committed Jul 20, 2021
1 parent 1db67c8 commit 28f552b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ describe('KibanaLogic', () => {
expect(KibanaLogic.values.config).toEqual({});
});

it('gracefully handles disabled security', () => {
mountKibanaLogic({ ...mockKibanaValues, security: undefined } as any);

expect(KibanaLogic.values.security).toEqual({});
});

it('gracefully handles non-cloud installs', () => {
mountKibanaLogic({ ...mockKibanaValues, cloud: undefined } as any);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ interface KibanaLogicProps {
renderHeaderActions(HeaderActions: FC): void;
// Required plugins
charts: ChartsPluginStart;
security: SecurityPluginStart;
// Optional plugins
cloud?: CloudSetup;
security?: SecurityPluginStart;
}
export interface KibanaValues extends Omit<KibanaLogicProps, 'cloud' | 'security'> {
export interface KibanaValues extends Omit<KibanaLogicProps, 'cloud'> {
navigateToUrl(path: string, options?: CreateHrefOptions): Promise<void>;
cloud: Partial<CloudSetup>;
security: Partial<SecurityPluginStart>;
}

export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
Expand All @@ -54,7 +53,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
},
{},
],
security: [props.security || {}, {}],
security: [props.security, {}],
setBreadcrumbs: [props.setBreadcrumbs, {}],
setChromeIsVisible: [props.setChromeIsVisible, {}],
setDocTitle: [props.setDocTitle, {}],
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export interface ClientData extends InitialAppData {
interface PluginsSetup {
cloud?: CloudSetup;
home?: HomePublicPluginSetup;
security?: SecurityPluginSetup;
security: SecurityPluginSetup;
}
export interface PluginsStart {
cloud?: CloudSetup;
licensing: LicensingPluginStart;
charts: ChartsPluginStart;
data: DataPublicPluginStart;
security?: SecurityPluginStart;
security: SecurityPluginStart;
}

export class EnterpriseSearchPlugin implements Plugin {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/enterprise_search/server/lib/check_access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { callEnterpriseSearchConfigAPI } from './enterprise_search_config_api';

interface CheckAccess {
request: KibanaRequest;
security?: SecurityPluginSetup;
security: SecurityPluginSetup;
spaces: SpacesPluginStart;
config: ConfigType;
log: Logger;
Expand All @@ -43,7 +43,7 @@ export const checkAccess = async ({
request,
log,
}: CheckAccess): Promise<ProductAccess> => {
const isRbacEnabled = security?.authz.mode.useRbacForRequest(request) ?? false;
const isRbacEnabled = security.authz.mode.useRbacForRequest(request) ?? false;

// We can only retrieve the active space when either:
// 1) security is enabled, and the request has already been authenticated
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/enterprise_search/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { ConfigType } from './';

interface PluginsSetup {
usageCollection?: UsageCollectionSetup;
security?: SecurityPluginSetup;
security: SecurityPluginSetup;
features: FeaturesPluginSetup;
infra: InfraPluginSetup;
}
Expand Down

0 comments on commit 28f552b

Please sign in to comment.