-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Handle missing permissions when creating standalone agent API keys #193218
[Fleet] Handle missing permissions when creating standalone agent API keys #193218
Conversation
Pinging @elastic/fleet (Team:Fleet) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
|
||
export function sendCreateStandaloneAgentAPIKey(body: PostStandaloneAgentAPIKeyRequest['body']) { | ||
return sendRequest<PostStandaloneAgentAPIKeyResponse>({ | ||
return sendRequestForRq<PostStandaloneAgentAPIKeyResponse>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sendRequestForRq
as it throws on error, sendRequest
return an error that was not handled
@@ -21,7 +21,7 @@ export const registerRoutes = (router: FleetAuthzRouter) => { | |||
path: CREATE_STANDALONE_AGENT_API_KEY_ROUTE, | |||
access: 'internal', | |||
fleetAuthz: { | |||
fleet: { all: true }, | |||
fleet: { addAgents: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should only have the addAgents permission and not all
@@ -210,12 +210,15 @@ export function useGetCreateApiKey() { | |||
const core = useStartServices(); | |||
|
|||
const [apiKey, setApiKey] = useState<string | undefined>(undefined); | |||
const [isLoading, setIsLoading] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a loading state, as it was weird to me to not have feedback while the API key is creating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
💚 Build Succeeded
The CI Stats report is too large to be displayed here, check out the CI build annotation for this information. To update your PR or re-run it, just comment with: cc @nchaulet |
… keys (elastic#193218) (cherry picked from commit 6a79e2d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…nt API keys (#193218) (#193292) # Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Handle missing permissions when creating standalone agent API keys (#193218)](#193218) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-18T13:06:09Z","message":"[Fleet] Handle missing permissions when creating standalone agent API keys (#193218)","sha":"6a79e2d0be4d1cb9155b32afcff5753e1860b801","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Fleet] Handle missing permissions when creating standalone agent API keys ","number":193218,"url":"https://github.com/elastic/kibana/pull/193218","mergeCommit":{"message":"[Fleet] Handle missing permissions when creating standalone agent API keys (#193218)","sha":"6a79e2d0be4d1cb9155b32afcff5753e1860b801"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193218","number":193218,"mergeCommit":{"message":"[Fleet] Handle missing permissions when creating standalone agent API keys (#193218)","sha":"6a79e2d0be4d1cb9155b32afcff5753e1860b801"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <[email protected]>
Description
Resolve #189150
We were not handling errors when creating standalone agent API keys in the Fleet UI.
That PR address that by:
UI Changes