Skip to content

Commit

Permalink
Fix after review: naming fleet_enroll instead of admin user
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Mar 20, 2020
1 parent 0d82d42 commit 8754694
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/common/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export interface NewOutput {
hosts?: string[];
ca_sha256?: string;
api_key?: string;
admin_username?: string;
admin_password?: string;
fleet_enroll_username?: string;
fleet_enroll_password?: string;
config?: Record<string, any>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface GetFleetSetupRequest {}

export interface CreateFleetSetupRequest {
body: {
admin_username: string;
admin_password: string;
fleet_enroll_username: string;
fleet_enroll_password: string;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ classDiagram
ca_sha256
config
// Encrypted - user to create API keys
admin_username
admin_password
fleet_enroll_username
fleet_enroll_password
}

4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/server/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export const savedObjectMappings = {
ca_sha256: { type: 'keyword' },
// FIXME_INGEST https://github.com/elastic/kibana/issues/56554
api_key: { type: 'keyword' },
admin_username: { type: 'binary' },
admin_password: { type: 'binary' },
fleet_enroll_username: { type: 'binary' },
fleet_enroll_password: { type: 'binary' },
config: { type: 'flattened' },
},
},
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/ingest_manager/server/services/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class OutputService {
.getEncryptedSavedObjects()
?.getDecryptedAsInternalUser<Output>(OUTPUT_SAVED_OBJECT_TYPE, defaultOutputId);

if (!so || !so.attributes.admin_username || !so.attributes.admin_password) {
if (!so || !so.attributes.fleet_enroll_username || !so.attributes.fleet_enroll_password) {
return null;
}

return {
username: so!.attributes.admin_username,
password: so!.attributes.admin_password,
username: so!.attributes.fleet_enroll_username,
password: so!.attributes.fleet_enroll_password,
};
}

Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { getPackageInfo } from './epm/packages';
import { datasourceService } from './datasource';
import { generateEnrollmentAPIKey } from './api_keys';

const FLEET_ADMIN_USERNAME = 'fleet_enroll';
const FLEET_ADMIN_ROLE = 'fleet_enroll';
const FLEET_ENROLL_USERNAME = 'fleet_enroll';
const FLEET_ENROLL_ROLE = 'fleet_enroll';

export async function setupIngestManager(
soClient: SavedObjectsClientContract,
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function setupFleet(
// This should be done directly in ES at some point
await callCluster('transport.request', {
method: 'PUT',
path: `/_security/role/${FLEET_ADMIN_ROLE}`,
path: `/_security/role/${FLEET_ENROLL_ROLE}`,
body: {
cluster: ['monitor', 'manage_api_key'],
indices: [
Expand All @@ -88,17 +88,17 @@ export async function setupFleet(
// Create fleet enroll user
await callCluster('transport.request', {
method: 'PUT',
path: `/_security/user/${FLEET_ADMIN_USERNAME}`,
path: `/_security/user/${FLEET_ENROLL_USERNAME}`,
body: {
password,
roles: [FLEET_ADMIN_ROLE],
roles: [FLEET_ENROLL_ROLE],
},
});

// save fleet admin user
await outputService.updateOutput(soClient, await outputService.getDefaultOutputId(soClient), {
admin_username: FLEET_ADMIN_USERNAME,
admin_password: password,
fleet_enroll_username: FLEET_ENROLL_USERNAME,
fleet_enroll_password: password,
});

// Generate default enrollment key
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/server/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const OutputBaseSchema = {
type: schema.oneOf([schema.literal(OutputType.Elasticsearch)]),
hosts: schema.maybe(schema.arrayOf(schema.string())),
api_key: schema.maybe(schema.string()),
admin_username: schema.maybe(schema.string()),
admin_password: schema.maybe(schema.string()),
fleet_enroll_username: schema.maybe(schema.string()),
fleet_enroll_password: schema.maybe(schema.string()),
config: schema.maybe(schema.recordOf(schema.string(), schema.any())),
};

Expand Down

0 comments on commit 8754694

Please sign in to comment.