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

[OSQuery Plugin] Migrate usage og authc.getCurrentUser to coreContext.security #187014

Merged
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 @@ -42,9 +42,10 @@ export const updateAssetsRoute = (router: IRouter, osqueryContext: OsqueryAppCon
},
},
},
async (context, request, response) => {
const savedObjectsClient = (await context.core).savedObjects.client;
const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
async (context, _request, response) => {
const coreContext = await context.core;
const savedObjectsClient = coreContext.savedObjects.client;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;

let installation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const createLiveQueryRoute = (router: IRouter, osqueryContext: OsqueryApp
},
async (context, request, response) => {
const [coreStartServices] = await osqueryContext.getStartServices();
const soClient = (await context.core).savedObjects.client;
const coreContext = await context.core;
const soClient = coreContext.savedObjects.client;

const {
osquery: { writeLiveQueries, runSavedQueries },
Expand Down Expand Up @@ -106,7 +107,7 @@ export const createLiveQueryRoute = (router: IRouter, osqueryContext: OsqueryApp
}

try {
const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;
const { response: osqueryAction, fleetActionsCount } = await createActionHandler(
osqueryContext,
request.body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const createPackRoute = (router: IRouter, osqueryContext: OsqueryAppConte
const agentPolicyService = osqueryContext.service.getAgentPolicyService();

const packagePolicyService = osqueryContext.service.getPackagePolicyService();
const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;

// eslint-disable-next-line @typescript-eslint/naming-convention
const { name, description, queries, enabled, policy_ids, shards = {} } = request.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const updatePackRoute = (router: IRouter, osqueryContext: OsqueryAppConte
);
const agentPolicyService = osqueryContext.service.getAgentPolicyService();
const packagePolicyService = osqueryContext.service.getPackagePolicyService();
const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;

// eslint-disable-next-line @typescript-eslint/naming-convention
const { name, description, queries, enabled, policy_ids, shards = {} } = request.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const createSavedQueryRoute = (router: IRouter, osqueryContext: OsqueryAp
ecs_mapping,
} = request.body;

const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;

const conflictingEntries = await savedObjectsClient.find<SavedQuerySavedObject>({
type: savedQuerySavedObjectType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const updateSavedQueryRoute = (router: IRouter, osqueryContext: OsqueryAp
async (context, request, response) => {
const coreContext = await context.core;
const savedObjectsClient = coreContext.savedObjects.client;
const currentUser = await osqueryContext.security.authc.getCurrentUser(request)?.username;
const currentUser = coreContext.security.authc.getCurrentUser()?.username;

const {
id,
Expand Down