Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solutions] Move authentication UI and hooks to 'public/common' #128924

Merged
merged 2 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

export * from './all';
export * from './authentications';
export * from './common';
export * from './details';
export * from './first_last_seen';
Expand All @@ -15,8 +14,6 @@ export * from './overview';
export * from './uncommon_processes';

export enum HostsQueries {
authentications = 'authentications',
authenticationsEntities = 'authenticationsEntities',
details = 'hostDetails',
firstOrLastSeen = 'firstOrLastSeen',
hosts = 'hosts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
HostDetailsStrategyResponse,
HostDetailsRequestOptions,
HostsOverviewStrategyResponse,
HostAuthenticationsRequestOptions,
HostAuthenticationsStrategyResponse,
HostOverviewRequestOptions,
HostFirstLastSeenStrategyResponse,
HostsQueries,
Expand Down Expand Up @@ -88,12 +86,17 @@ import {
TotalUsersKpiStrategyResponse,
} from './users/kpi/total_users';
import { UsersRequestOptions, UsersStrategyResponse } from './users/all';
import {
UserAuthenticationsRequestOptions,
UserAuthenticationsStrategyResponse,
} from './users/authentications';

export * from './cti';
export * from './hosts';
export * from './risk_score';
export * from './matrix_histogram';
export * from './network';
export * from './users';

export type FactoryQueryTypes =
| HostsQueries
Expand Down Expand Up @@ -132,8 +135,6 @@ export type StrategyResponseType<T extends FactoryQueryTypes> = T extends HostsQ
? HostDetailsStrategyResponse
: T extends HostsQueries.overview
? HostsOverviewStrategyResponse
: T extends HostsQueries.authentications
? HostAuthenticationsStrategyResponse
: T extends HostsQueries.firstOrLastSeen
? HostFirstLastSeenStrategyResponse
: T extends HostsQueries.uncommonProcesses
Expand All @@ -148,6 +149,8 @@ export type StrategyResponseType<T extends FactoryQueryTypes> = T extends HostsQ
? UserDetailsStrategyResponse
: T extends UsersQueries.kpiTotalUsers
? TotalUsersKpiStrategyResponse
: T extends UsersQueries.authentications
? UserAuthenticationsStrategyResponse
: T extends UsersQueries.users
? UsersStrategyResponse
: T extends NetworkQueries.details
Expand Down Expand Up @@ -194,8 +197,6 @@ export type StrategyRequestType<T extends FactoryQueryTypes> = T extends HostsQu
? HostDetailsRequestOptions
: T extends HostsQueries.overview
? HostOverviewRequestOptions
: T extends HostsQueries.authentications
? HostAuthenticationsRequestOptions
: T extends HostsQueries.firstOrLastSeen
? HostFirstLastSeenRequestOptions
: T extends HostsQueries.uncommonProcesses
Expand All @@ -206,6 +207,8 @@ export type StrategyRequestType<T extends FactoryQueryTypes> = T extends HostsQu
? HostsKpiHostsRequestOptions
: T extends HostsKpiQueries.kpiUniqueIps
? HostsKpiUniqueIpsRequestOptions
: T extends UsersQueries.authentications
? UserAuthenticationsRequestOptions
: T extends UsersQueries.details
? UserDetailsRequestOptions
: T extends UsersQueries.kpiTotalUsers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { IEsSearchResponse } from '../../../../../../../src/plugins/data/common';
import { AuthenticationHit } from '../hosts';
import { Inspect, Maybe, TimerangeInput } from '../../common';
import { RequestBasicOptions } from '../';
import { AuthenticationHit, RequestBasicOptions } from '../';
import { AlertsGroupData } from './alerts';
import { AnomaliesActionGroupData, AnomalyHit } from './anomalies';
import { DnsHistogramGroupData } from './dns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ import {
Hit,
TotalHit,
} from '../../../common';
import { RequestOptionsPaginated } from '../../';
import { RequestOptionsPaginated } from '../..';

export interface HostAuthenticationsStrategyResponse extends IEsSearchResponse {
export interface UserAuthenticationsStrategyResponse extends IEsSearchResponse {
edges: AuthenticationsEdges[];
totalCount: number;
pageInfo: PageInfoPaginated;
inspect?: Maybe<Inspect>;
}

export interface HostAuthenticationsRequestOptions extends RequestOptionsPaginated {
export interface UserAuthenticationsRequestOptions extends RequestOptionsPaginated {
defaultIndex: string[];
stackByField: AuthStackByField;
}

export enum AuthStackByField {
userName = 'user.name',
hostName = 'host.name',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the AuthStackByField.hostName ever used? I only see it in tests. It seems we always stack by userName?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Only user.name is being used. However, host.name is necessary for this issue: #129047

}

export interface AuthenticationsEdges {
Expand All @@ -41,7 +47,7 @@ export interface AuthenticationItem {
_id: string;
failures: number;
successes: number;
user: UserEcs;
stackedValue: UserEcs['name'] | HostEcs['name'];
lastSuccess?: Maybe<LastSourceHost>;
lastFailure?: Maybe<LastSourceHost>;
}
Expand All @@ -58,17 +64,15 @@ export interface AuthenticationHit extends Hit {
lastSuccess?: LastSourceHost;
lastFailure?: LastSourceHost;
};
user: string;
stackedValue: string;
failures: number;
successes: number;
cursor?: string;
sort: StringOrNumber[];
}

export interface AuthenticationBucket {
key: {
user_uid: string;
};
key: string;
doc_count: number;
failures: {
doc_count: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';

import { Inspect, Maybe, TimerangeInput } from '../../../common';
Expand All @@ -23,7 +22,3 @@ export interface UserDetailsRequestOptions extends Partial<RequestBasicOptions>
timerange: TimerangeInput;
inspect?: Maybe<Inspect>;
}

export interface AggregationRequest {
[aggField: string]: estypes.AggregationsAggregationContainer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@

import { TotalUsersKpiStrategyResponse } from './kpi/total_users';

export * from './all';
export * from './common';
export * from './kpi';
export * from './details';
export * from './authentications';

export enum UsersQueries {
details = 'userDetails',
kpiTotalUsers = 'usersKpiTotalUsers',
users = 'allUsers',
authentications = 'authentications',
authenticationsEntities = 'authenticationsEntities',
}

export type UserskKpiStrategyResponse = Omit<TotalUsersKpiStrategyResponse, 'rawResponse'>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './common';
export * from './total_users';
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* 2.0.
*/

export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-authentications-loading-false"]';
export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-users-authentications-loading-false"]';
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
export const AUTHENTICATIONS_TAB = '[data-test-subj="navigation-authentications"]';
export const HEADER_SUBTITLE = '[data-test-subj="header-panel-subtitle"]';
export const USER_NAME_CELL = '[data-test-subj="render-content-user.name"]';
export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-authentications-loading-false"]';
export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-users-authentications-loading-false"]';
Loading