Skip to content

Commit

Permalink
[8.11] action oauth : quieter logs (elastic#171210) (elastic#171244)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.11`:
- [action oauth : quieter logs
(elastic#171210)](elastic#171210)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Pierre
Gayvallet","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-11-14T21:19:38Z","message":"action
oauth : quieter logs (elastic#171210)\n\n## Summary\r\n\r\nRemove unnecessary
details from warning log when fetching an oauth token\r\nthrows an
error.","sha":"6ebad69948c9a50b7d6c1c9d790d9e89dc71ba21","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","backport:prev-MAJOR","v8.12.0"],"number":171210,"url":"https://github.com/elastic/kibana/pull/171210","mergeCommit":{"message":"action
oauth : quieter logs (elastic#171210)\n\n## Summary\r\n\r\nRemove unnecessary
details from warning log when fetching an oauth token\r\nthrows an
error.","sha":"6ebad69948c9a50b7d6c1c9d790d9e89dc71ba21"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/171210","number":171210,"mergeCommit":{"message":"action
oauth : quieter logs (elastic#171210)\n\n## Summary\r\n\r\nRemove unnecessary
details from warning log when fetching an oauth token\r\nthrows an
error.","sha":"6ebad69948c9a50b7d6c1c9d790d9e89dc71ba21"}}]}]
BACKPORT-->

Co-authored-by: Pierre Gayvallet <[email protected]>
  • Loading branch information
kibanamachine and pgayvallet authored Nov 14, 2023
1 parent 3942628 commit 8d16b46
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('requestOAuthClientCredentialsToken', () => {

expect(mockLogger.warn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"error thrown getting the access token from https://test for params: {\\"scope\\":\\"test\\",\\"client_id\\":\\"123456\\",\\"client_secret\\":\\"secrert123\\"}: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
"error thrown getting the access token from https://test: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
]
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('requestOAuthJWTToken', () => {

expect(mockLogger.warn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"error thrown getting the access token from https://test for params: {\\"assertion\\":\\"someJWTvalueishere\\",\\"scope\\":\\"test\\",\\"client_id\\":\\"client-id-1\\",\\"client_secret\\":\\"some-client-secret\\"}: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
"error thrown getting the access token from https://test: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
]
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('requestOAuthToken', () => {

expect(mockLogger.warn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"error thrown getting the access token from https://test for params: {\\"client_id\\":\\"123456\\",\\"client_secret\\":\\"secrert123\\",\\"some_additional_param\\":\\"test\\"}: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
"error thrown getting the access token from https://test: {\\"error\\":\\"invalid_scope\\",\\"error_description\\":\\"AADSTS70011: The provided value for the input parameter 'scope' is not valid.\\"}",
]
`);
});
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/actions/server/lib/request_oauth_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ export async function requestOAuthToken<T>(
};
} else {
const errString = stringify(res.data);
logger.warn(
`error thrown getting the access token from ${tokenUrl} for params: ${JSON.stringify(
bodyRequest
)}: ${errString}`
);
logger.warn(`error thrown getting the access token from ${tokenUrl}: ${errString}`);
throw new Error(errString);
}
}

0 comments on commit 8d16b46

Please sign in to comment.