Skip to content

Commit

Permalink
Merge branch 'master' into 73221-remove-success
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Aug 27, 2020
2 parents 1546bef + 54bbd6a commit dfccf25
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function mockAuthenticatedUser(user: Partial<AuthenticatedUser> = {}) {
authentication_realm: { name: 'native1', type: 'native' },
lookup_realm: { name: 'native1', type: 'native' },
authentication_provider: 'basic1',
authentication_type: 'realm',
...user,
};
}
7 changes: 7 additions & 0 deletions x-pack/plugins/security/common/model/authenticated_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export interface AuthenticatedUser extends User {
* Name of the Kibana authentication provider that used to authenticate user.
*/
authentication_provider: string;

/**
* The AuthenticationType used by ES to authenticate the user.
*
* @example "realm" | "api_key" | "token" | "anonymous" | "internal"
*/
authentication_type: string;
}

export function canUserChangePassword(user: AuthenticatedUser) {
Expand Down
17 changes: 15 additions & 2 deletions x-pack/test/api_integration/apis/security/basic_login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default function ({ getService }) {
const validUsername = kibanaServerConfig.username;
const validPassword = kibanaServerConfig.password;

// Failing: See https://github.com/elastic/kibana/issues/75707
describe.skip('Basic authentication', () => {
describe('Basic authentication', () => {
it('should redirect non-AJAX requests to the login page if not authenticated', async () => {
const response = await supertest.get('/abc/xyz').expect(302);

Expand Down Expand Up @@ -145,8 +144,15 @@ export default function ({ getService }) {
'authentication_realm',
'lookup_realm',
'authentication_provider',
'authentication_type',
]);
expect(apiResponse.body.username).to.be(validUsername);
expect(apiResponse.body.authentication_provider).to.eql('__http__');
expect(apiResponse.body.authentication_realm).to.eql({
name: 'reserved',
type: 'reserved',
});
expect(apiResponse.body.authentication_type).to.be('realm');
});

describe('with session cookie', () => {
Expand Down Expand Up @@ -187,8 +193,15 @@ export default function ({ getService }) {
'authentication_realm',
'lookup_realm',
'authentication_provider',
'authentication_type',
]);
expect(apiResponse.body.username).to.be(validUsername);
expect(apiResponse.body.authentication_provider).to.eql('basic');
expect(apiResponse.body.authentication_realm).to.eql({
name: 'reserved',
type: 'reserved',
});
expect(apiResponse.body.authentication_type).to.be('realm');
});

it('should extend cookie on every successful non-system API call', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function ({ getService }: FtrProviderContext) {
expect(cookie.maxAge).to.be(0);
}

// FAILING: https://github.com/elastic/kibana/issues/75707
describe.skip('Kerberos authentication', () => {
describe('Kerberos authentication', () => {
before(async () => {
await getService('esSupertest')
.post('/_security/role_mapping/krb5')
Expand Down Expand Up @@ -82,6 +81,7 @@ export default function ({ getService }: FtrProviderContext) {
expect(user.username).to.eql(username);
expect(user.authentication_realm).to.eql({ name: 'reserved', type: 'reserved' });
expect(user.authentication_provider).to.eql('basic');
expect(user.authentication_type).to.eql('realm');
});

describe('initiating SPNEGO', () => {
Expand Down Expand Up @@ -121,7 +121,14 @@ export default function ({ getService }: FtrProviderContext) {
const sessionCookie = request.cookie(cookies[0])!;
checkCookieIsSet(sessionCookie);

const expectedUserRoles = ['kibana_admin'];
const isAnonymousAccessEnabled = (config.get(
'esTestCluster.serverArgs'
) as string[]).some((setting) => setting.startsWith('xpack.security.authc.anonymous'));

// `superuser_anonymous` role is derived from the enabled anonymous access.
const expectedUserRoles = isAnonymousAccessEnabled
? ['kibana_admin', 'superuser_anonymous']
: ['kibana_admin'];

await supertest
.get('/internal/security/me')
Expand All @@ -140,6 +147,7 @@ export default function ({ getService }: FtrProviderContext) {
authentication_realm: { name: 'kerb1', type: 'kerberos' },
lookup_realm: { name: 'kerb1', type: 'kerberos' },
authentication_provider: 'kerberos',
authentication_type: 'token',
});
});

Expand Down
Loading

0 comments on commit dfccf25

Please sign in to comment.