Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 2, 2020
1 parent 7fcf2c8 commit 016f664
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"It is not recommended to disable xsrf protections for API endpoints via [server.xsrf.whitelist].It will be removed in 8.0 release. Instead, supply the \\"kbn-xsrf\\" header.",
"It is not recommended to disable xsrf protections for API endpoints via [server.xsrf.whitelist]. It will be removed in 8.0 release. Instead, supply the \\"kbn-xsrf\\" header.",
]
`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const xsrfDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
get<unknown[]>(settings, 'server.xsrf.whitelist').length > 0
) {
log(
'It is not recommended to disable xsrf protections for API endpoints via [server.xsrf.whitelist].' +
'It is not recommended to disable xsrf protections for API endpoints via [server.xsrf.whitelist]. ' +
'It will be removed in 8.0 release. Instead, supply the "kbn-xsrf" header.'
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/server/http/http_server.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({

return KibanaRequest.from<P, Q, B>(
createRawRequestMock({
app: kibanaRouteState,
headers,
params,
query,
Expand All @@ -84,7 +83,7 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({
search: queryString ? `?${queryString}` : queryString,
},
route: {
settings: { tags: routeTags, auth: routeAuthRequired },
settings: { tags: routeTags, auth: routeAuthRequired, app: kibanaRouteState },
},
raw: {
req: { socket },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe('core lifecycle handlers', () => {
});

it('accepts requests on a route with disabled xsrf protection', async () => {
await getSupertest(method.toLowerCase(), whitelistedTestPath).expect(200, 'ok');
await getSupertest(method.toLowerCase(), xsrfDisabledTestPath).expect(200, 'ok');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/router/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class KibanaRequest<
const options = ({
authRequired: request.route.settings.auth !== false,
// some places in LP call KibanaRequest.from(request) manually. remove fallback to true before v8
xsrfRequired: (request.app as KibanaRouteState)?.xsrfRequired ?? true,
xsrfRequired: (request.route.settings.app as KibanaRouteState)?.xsrfRequired ?? true,
tags: request.route.settings.tags || [],
body: ['get', 'options'].includes(method)
? undefined
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/router/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface RouteConfigOptions<Method extends RouteMethod> {

/**
* Defines xsrf protection requirements for a route:
* - true. Requires an incoming request to contain `kbn-xsrf` header.
* - true. Requires an incoming POST/PUT/DELETE request to contain `kbn-xsrf` header.
* - false. Disables xsrf protection.
*
* Set to true by default
Expand Down

0 comments on commit 016f664

Please sign in to comment.