Skip to content

Commit

Permalink
yarn lint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Sam <[email protected]>
  • Loading branch information
samuelcostae committed Aug 10, 2023
1 parent 772a81f commit a3be5ef
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { RoleEditMappedUser } from './panels/role-mapping/role-edit-mapped-user'
import { RoleView } from './panels/role-view/role-view';
import { TenantList } from './panels/tenant-list/tenant-list';
import { UserList } from './panels/user-list';
import { ServiceAccountList } from "./panels/service-account-list";
import { ServiceAccountList } from './panels/service-account-list';
import { Action, ResourceType, RouteItem, SubAction } from './types';
import { buildHashUrl, buildUrl } from './utils/url-builder';
import { CrossPageToast } from './cross-page-toast';
Expand Down
14 changes: 6 additions & 8 deletions public/apps/configuration/panels/service-account-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ import { Action, ResourceType } from '../types';
import { EMPTY_FIELD_VALUE } from '../ui-constants';
import { useContextMenuState } from '../utils/context-menu';
import { ExternalLink, tableItemsUIProps, truncatedListView } from '../utils/display-utils';
import {
getUserList,
InternalUsersListing,
} from '../utils/internal-user-list-utils';
import { getUserList, InternalUsersListing } from '../utils/internal-user-list-utils';
import { showTableStatusMessage } from '../utils/loading-spinner-utils';
import { buildHashUrl } from '../utils/url-builder';

Expand Down Expand Up @@ -178,11 +175,12 @@ export function ServiceAccountList(props: AppDependencies) {
</span>
</h3>
</EuiTitle>
<EuiText size="xs" color="subdued">
Here you list the users authenticated via an external authentication system such as LDAP server or Active
Directory. You can map an user to a role from{' '}
<EuiText size="s" color="subdued">
Here you list the users authenticated via an external authentication system such as
LDAP server or Active Directory. You can map an user to a role from{' '}
<EuiLink href={buildHashUrl(ResourceType.roles)}>Roles</EuiLink>
“Manage mapping” <ExternalLink href={DocLinks.BackendConfigurationAuthenticationDoc} />
“Manage mapping”
<ExternalLink href={DocLinks.BackendConfigurationAuthenticationDoc} />
</EuiText>
</EuiPageContentHeaderSection>
<EuiPageContentHeaderSection>
Expand Down
4 changes: 2 additions & 2 deletions public/apps/configuration/panels/user-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ export function UserList(props: AppDependencies) {
</h3>
</EuiTitle>
<EuiText size="xs" color="subdued">
The Security plugin includes an internal account database. Use this database in place of,
or in addition to, an external authentication system such as LDAP server or Active
The Security plugin includes an internal account database. Use this database in place
of, or in addition to, an external authentication system such as LDAP server or Active
Directory. You can map an internal account to a role from{' '}
<EuiLink href={buildHashUrl(ResourceType.roles)}>Roles</EuiLink>
. First, click into the detail page of the role. Then, under “Mapped users”, click
Expand Down
20 changes: 15 additions & 5 deletions public/apps/configuration/utils/internal-user-list-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@

import { map } from 'lodash';
import { HttpStart } from '../../../../../../src/core/public';
import { API_ENDPOINT_INTERNALACCOUNTS, API_ENDPOINT_INTERNALUSERS, API_ENDPOINT_SERVICEACCOUNTS } from '../constants';
import {DataObject, InternalUser, ObjectsMessage, ResourceType} from '../types';
import {
API_ENDPOINT_INTERNALACCOUNTS,
API_ENDPOINT_INTERNALUSERS,
API_ENDPOINT_SERVICEACCOUNTS,
} from '../constants';
import { DataObject, InternalUser, ObjectsMessage, ResourceType } from '../types';
import { httpDelete, httpGet } from './request-utils';
import { getResourceUrl } from './resource-utils';

Expand All @@ -34,11 +38,14 @@ export function transformUserData(rawData: DataObject<InternalUser>): InternalUs

export async function requestDeleteUsers(http: HttpStart, users: string[]) {
for (const user of users) {
await httpDelete(http, getResourceUrl( API_ENDPOINT_INTERNALUSERS, user));
await httpDelete(http, getResourceUrl(API_ENDPOINT_INTERNALUSERS, user));
}
}

async function getUserListRaw(http: HttpStart, userType: string ): Promise<ObjectsMessage<InternalUser>> {
async function getUserListRaw(
http: HttpStart,
userType: string
): Promise<ObjectsMessage<InternalUser>> {
let ENDPOINT = API_ENDPOINT_INTERNALACCOUNTS;
if (userType === ResourceType.serviceAccounts) {
ENDPOINT = API_ENDPOINT_SERVICEACCOUNTS;
Expand All @@ -47,7 +54,10 @@ async function getUserListRaw(http: HttpStart, userType: string ): Promise<Objec
return await httpGet<ObjectsMessage<InternalUser>>(http, ENDPOINT);
}

export async function getUserList(http: HttpStart, userType: string ): Promise<InternalUsersListing[]> {
export async function getUserList(
http: HttpStart,
userType: string
): Promise<InternalUsersListing[]> {
const rawData = await getUserListRaw(http, userType);
return transformUserData(rawData.data);
}
Expand Down
8 changes: 4 additions & 4 deletions server/backend/opensearch_security_configuration_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export default function (Client: any, config: any, components: any) {

Client.prototype.opensearch_security.prototype.listInternalAccounts = ca({
url: {
fmt: '/_plugins/_security/api/internalusers?filterBy=internal'
}
fmt: '/_plugins/_security/api/internalusers?filterBy=internal',
},
});
Client.prototype.opensearch_security.prototype.listServiceAccounts = ca({
url: {
fmt: '/_plugins/_security/api/internalusers?filterBy=service'
}
fmt: '/_plugins/_security/api/internalusers?filterBy=service',
},
});

/**
Expand Down
9 changes: 3 additions & 6 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,11 @@ export function defineRoutes(router: IRouter) {
const client = context.security_plugin.esClient.asScoped(request);
let esResp;
try {
console.log(request.params.resourceName)
if(request.params.resourceName == ResourceType.serviceAccounts.toLowerCase()){
if (request.params.resourceName === ResourceType.serviceAccounts.toLowerCase()) {
esResp = await client.callAsCurrentUser('opensearch_security.listServiceAccounts');
}
else if(request.params.resourceName == 'internalaccounts'){
} else if (request.params.resourceName === 'internalaccounts') {
esResp = await client.callAsCurrentUser('opensearch_security.listInternalAccounts');
}
else{
} else {
esResp = await client.callAsCurrentUser('opensearch_security.listResource', {
resourceName: request.params.resourceName,
});
Expand Down

0 comments on commit a3be5ef

Please sign in to comment.