Skip to content

Commit

Permalink
Review#1: pass full authc setup contract to nav control service and…
Browse files Browse the repository at this point in the history
… keep `authorization` in the legacy config schema.
  • Loading branch information
azasypkin committed Jan 3, 2020
1 parent 75659fc commit e9783d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/security/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const security = kibana =>
session: HANDLED_IN_NEW_PLATFORM,
secureCookies: HANDLED_IN_NEW_PLATFORM,
loginAssistanceMessage: HANDLED_IN_NEW_PLATFORM,
authorization: HANDLED_IN_NEW_PLATFORM,
audit: Joi.object({
enabled: Joi.boolean().default(false),
}).default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('SecurityNavControlService', () => {
);
navControlService.setup({
securityLicense: new SecurityLicenseService().setup({ license$ }).license,
getCurrentUser: mockSecuritySetup.authc.getCurrentUser,
authc: mockSecuritySetup.authc,
});

const coreStart = coreMock.createStart();
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('SecurityNavControlService', () => {
const navControlService = new SecurityNavControlService();
navControlService.setup({
securityLicense: new SecurityLicenseService().setup({ license$ }).license,
getCurrentUser: securityMock.createSetup().authc.getCurrentUser,
authc: securityMock.createSetup().authc,
});

const coreStart = coreMock.createStart();
Expand All @@ -118,7 +118,7 @@ describe('SecurityNavControlService', () => {
const navControlService = new SecurityNavControlService();
navControlService.setup({
securityLicense: new SecurityLicenseService().setup({ license$ }).license,
getCurrentUser: securityMock.createSetup().authc.getCurrentUser,
authc: securityMock.createSetup().authc,
});

const coreStart = coreMock.createStart();
Expand All @@ -134,7 +134,7 @@ describe('SecurityNavControlService', () => {
const navControlService = new SecurityNavControlService();
navControlService.setup({
securityLicense: new SecurityLicenseService().setup({ license$ }).license,
getCurrentUser: securityMock.createSetup().authc.getCurrentUser,
authc: securityMock.createSetup().authc,
});

const coreStart = coreMock.createStart();
Expand All @@ -155,7 +155,7 @@ describe('SecurityNavControlService', () => {
const navControlService = new SecurityNavControlService();
navControlService.setup({
securityLicense: new SecurityLicenseService().setup({ license$ }).license,
getCurrentUser: securityMock.createSetup().authc.getCurrentUser,
authc: securityMock.createSetup().authc,
});

const coreStart = coreMock.createStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AuthenticationServiceSetup } from '../authentication';

interface SetupDeps {
securityLicense: SecurityLicense;
getCurrentUser: AuthenticationServiceSetup['getCurrentUser'];
authc: AuthenticationServiceSetup;
}

interface StartDeps {
Expand All @@ -23,15 +23,15 @@ interface StartDeps {

export class SecurityNavControlService {
private securityLicense!: SecurityLicense;
private getCurrentUser!: AuthenticationServiceSetup['getCurrentUser'];
private authc!: AuthenticationServiceSetup;

private navControlRegistered!: boolean;

private securityFeaturesSubscription?: Subscription;

public setup({ securityLicense, getCurrentUser }: SetupDeps) {
public setup({ securityLicense, authc }: SetupDeps) {
this.securityLicense = securityLicense;
this.getCurrentUser = getCurrentUser;
this.authc = authc;
}

public start({ core }: StartDeps) {
Expand Down Expand Up @@ -59,7 +59,7 @@ export class SecurityNavControlService {
private registerSecurityNavControl(
core: Pick<CoreStart, 'chrome' | 'http' | 'i18n' | 'application'>
) {
const currentUserPromise = this.getCurrentUser();
const currentUserPromise = this.authc.getCurrentUser();
core.chrome.navControls.registerRight({
order: 2000,
mount: (el: HTMLElement) => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SecurityPlugin implements Plugin<SecurityPluginSetup, SecurityPlugi

this.navControlService.setup({
securityLicense: license,
getCurrentUser: authc.getCurrentUser,
authc,
});

return {
Expand Down

0 comments on commit e9783d4

Please sign in to comment.