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

Provide utilities to create 'fake' requests #52978

Closed
pgayvallet opened this issue Dec 13, 2019 · 2 comments
Closed

Provide utilities to create 'fake' requests #52978

pgayvallet opened this issue Dec 13, 2019 · 2 comments
Labels
discuss Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@pgayvallet
Copy link
Contributor

Some plugins (reporting for starters) needs to fake the user authentication to impersonate them during some deferred work.

Reporting for example encrypt and store an incoming request's authentication headers to be able to have the reporting job impersonate the user when accessing SO or other ES endpoints.

const fakeRequest: any = {
headers: conditionalHeaders.headers,
// This is used by the spaces SavedObjectClientWrapper to determine the existing space.
// We use the basePath from the saved job, which we'll have post spaces being implemented;
// or we use the server base path, which uses the default space
getBasePath: () => job.basePath || serverBasePath,
path: '/',
route: { settings: {} },
url: {
href: '/',
},
raw: {
req: {
url: '/',
},
},
};
const savedObjects = server.savedObjects;
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(fakeRequest);

In legacy platform, they forge the request themselves. Technically, they still could do the same in NP, However this seems fragile and relies on the underlying implementation.

Should we ease this process by providing utility methods (static on KibanaRequest or a proper API on the http service for example)?

@pgayvallet pgayvallet added discuss Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Dec 13, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@pgayvallet
Copy link
Contributor Author

Superseeded by #39430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

2 participants