-
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
[Alerting] Replaced single invalidateApiKey request with the bulk. #87401
[Alerting] Replaced single invalidateApiKey request with the bulk. #87401
Conversation
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
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 with few nits, thanks!
x-pack/plugins/security/server/authentication/api_keys/api_keys.ts
Outdated
Show resolved
Hide resolved
@@ -253,10 +260,10 @@ export class APIKeys { | |||
} | |||
|
|||
/** | |||
* Tries to invalidate an API key by using the internal user. | |||
* @param params The params to invalidate an API key. | |||
* Tries to invalidate an API keys by using the internal user. |
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.
question: would you mind updating the signature/log-messages/etc for invalidate
method as well to keep them consistent? I see only one place in fleet
that uses invalidate
, so hopefully it won't require too much work. But if not, feel free to keep it as is and I'll update it in the follow-up.
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! Left some minor comments about updating the log message and maybe adding a check for whether there are keys to invalidate before calling the bulk invalidate request.
x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
Outdated
Show resolved
Hide resolved
…fleets plugin usage of this API.
Pinging @elastic/ingest-management (Team:Ingest Management) |
@@ -64,7 +64,7 @@ export async function authenticate(callCluster: CallESAsCurrentUser) { | |||
} | |||
} | |||
|
|||
export async function invalidateAPIKey(soClient: SavedObjectsClientContract, id: string) { | |||
export async function invalidateAPIKey(soClient: SavedObjectsClientContract, ids: string[]) { |
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.
Since this now accepts ids: string[]
I think the function should be pluralized to invalidateAPIKeys
💚 Build SucceededMetrics [docs]Distributable file count
History
To update your PR or re-run it, just comment with: |
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.
🚚 Thanks!
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.
Changes in the alerts plugin LGTM!
if (apiKeyIds.length > 0) { | ||
const response = await invalidateAPIKeys({ ids: apiKeyIds }, securityPluginStart); | ||
if (response.apiKeysEnabled === true && response.result.error_count > 0) { | ||
logger.error(`Failed to invalidate API Keys [ids="${apiKeyIds.join(', ')}"]`); |
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.
nit: I think the intent was to join with double quotes?
logger.error(`Failed to invalidate API Keys [ids="${apiKeyIds.join(', ')}"]`); | |
logger.error(`Failed to invalidate API Keys [ids="${apiKeyIds.join(", ")}"]`); |
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.
TS formatter trying to replace back to a single quotes.
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.
Ohh I see, I was thinking the quotes were part of the logs, oops. All good.
Changes introduced based on the adding support to invalidate API keys in a bulk operation.
Extended methods invalidate:
and invalidateAsInternalUser:
of
x-pack/plugins/security/server/authentication/api_keys/api_keys.ts
to support invalidation by multiple ids parameters.Introduced proper changes in the plugins which are using this API.
Resolves #83224