Skip to content

Commit

Permalink
Implement Kibana Login Selector (#53010)
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin authored Mar 23, 2020
1 parent dd93a14 commit fa69765
Show file tree
Hide file tree
Showing 74 changed files with 5,201 additions and 1,390 deletions.
5 changes: 1 addition & 4 deletions x-pack/legacy/plugins/security/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export const security = (kibana: Record<string, any>) =>
uiExports: {
hacks: ['plugins/security/hacks/legacy'],
injectDefaultVars: (server: Server) => {
return {
secureCookies: getSecurityPluginSetup(server).__legacyCompat.config.secureCookies,
enableSpaceAwarePrivileges: server.config().get('xpack.spaces.enabled'),
};
return { enableSpaceAwarePrivileges: server.config().get('xpack.spaces.enabled') };
},
},

Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/security/common/login_state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 { LoginLayout } from './licensing';

export interface LoginSelector {
enabled: boolean;
providers: Array<{ type: string; name: string; description?: string }>;
}

export interface LoginState {
layout: LoginLayout;
allowLogin: boolean;
showLoginForm: boolean;
requiresSecureConnection: boolean;
selector: LoginSelector;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function mockAuthenticatedUser(user: Partial<AuthenticatedUser> = {}) {
enabled: true,
authentication_realm: { name: 'native1', type: 'native' },
lookup_realm: { name: 'native1', type: 'native' },
authentication_provider: 'basic',
authentication_provider: 'basic1',
...user,
};
}
17 changes: 17 additions & 0 deletions x-pack/plugins/security/common/parse_next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ describe('parseNext', () => {
expect(parseNext(href, basePath)).toEqual(`${next}#${hash}`);
});

it('should properly handle multiple next with hash', () => {
const basePath = '/iqf';
const next1 = `${basePath}/app/kibana`;
const next2 = `${basePath}/app/ml`;
const hash = '/discover/New-Saved-Search';
const href = `${basePath}/login?next=${next1}&next=${next2}#${hash}`;
expect(parseNext(href, basePath)).toEqual(`${next1}#${hash}`);
});

it('should properly decode special characters', () => {
const basePath = '/iqf';
const next = `${encodeURIComponent(basePath)}%2Fapp%2Fkibana`;
Expand Down Expand Up @@ -118,6 +127,14 @@ describe('parseNext', () => {
expect(parseNext(href)).toEqual(`${next}#${hash}`);
});

it('should properly handle multiple next with hash', () => {
const next1 = '/app/kibana';
const next2 = '/app/ml';
const hash = '/discover/New-Saved-Search';
const href = `/login?next=${next1}&next=${next2}#${hash}`;
expect(parseNext(href)).toEqual(`${next1}#${hash}`);
});

it('should properly decode special characters', () => {
const next = '%2Fapp%2Fkibana';
const hash = '/discover/New-Saved-Search';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security/common/parse_next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export function parseNext(href: string, basePath = '') {
return `${basePath}/`;
}

return query.next + (hash || '');
return next + (hash || '');
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading

0 comments on commit fa69765

Please sign in to comment.