Skip to content

feat(apikeys): list keys with the signed-in session - #274

Closed
LorrisSaintGenez wants to merge 7 commits into
feat/api-keys-search-get-createfrom
feat/apikeys-list-session
Closed

feat(apikeys): list keys with the signed-in session#274
LorrisSaintGenez wants to merge 7 commits into
feat/api-keys-search-get-createfrom
feat/apikeys-list-session

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

algolia apikeys list no longer requires an admin API key: being signed in with an application selected is enough.

  • List through the dashboard Public API when no API key is passed explicitly, following pagination.
  • Keep the Search API path when --api-key, --admin-api-key, ALGOLIA_API_KEY or ALGOLIA_ADMIN_API_KEY is set, which still lists every key of the application.
  • Drop the acls: admin annotation that made the command unreachable for a signed-in user.
  • Move the routing decision to Profile.HasExplicitAPIKey(), shared with apikeys create. It now also covers ALGOLIA_ADMIN_API_KEY, which the create-side helper was missing.

The two paths don't return the same set. The Public API only knows the keys created through the dashboard or the CLI, so the session path lists those; the Search API lists every key of the engine. The session path also reports no expiry — the Public API serializer hardcodes validity to nil — so VALIDITY shows - there.

Table rendering is now shared by both paths, which fixes a column shift: a key with no description used to render one field short, misaligning every following column.

Requires algolia/AlgoliaWeb#29489 to be deployed. Stacked on #273.

Test

Sign in first, with an application selected:

algolia auth login
algolia application select

List the keys of the current application:

algolia apikeys list

Expect one row per key created by the CLI, with VALIDITY at -. Create one and list again to see it appear:

algolia apikeys create --acl search -d "list check"
algolia apikeys list

Structured output:

algolia apikeys list -o json

Expect an array of objects carrying uuid, value, acl, indexes, referers and created_at.

Error paths:

algolia apikeys list --application-id devDOESNOTEXIST
algolia apikeys list --api-key <non-admin-key>

Expect application devDOESNOTEXIST doesn't exist, or your account doesn't have access to it, then a 403 followed by This API key isn't an admin key.

Admin key path still lists everything, including keys created outside the CLI:

algolia apikeys list --api-key <admin-key>

GROUT-438

@LorrisSaintGenez LorrisSaintGenez self-assigned this Jul 27, 2026
@codacy-production

codacy-production Bot commented Jul 27, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 22 complexity · 137 duplication

Metric Results
Complexity 22
Duplication 137

View in Codacy

TIP This summary will be updated as you push new changes.

@LorrisSaintGenez
LorrisSaintGenez requested review from a team, dylantientcheu and levimichael and removed request for a team July 27, 2026 18:27
@LorrisSaintGenez
LorrisSaintGenez marked this pull request as ready for review July 27, 2026 18:30
@LorrisSaintGenez
LorrisSaintGenez force-pushed the feat/api-keys-search-get-create branch from c940e41 to 6de9ed3 Compare July 27, 2026 19:42
@LorrisSaintGenez
LorrisSaintGenez force-pushed the feat/apikeys-list-session branch from 80b5264 to e7e3125 Compare July 27, 2026 19:42
@LorrisSaintGenez
LorrisSaintGenez force-pushed the feat/api-keys-search-get-create branch from 6de9ed3 to 557d2e4 Compare July 27, 2026 19:53
@LorrisSaintGenez
LorrisSaintGenez force-pushed the feat/apikeys-list-session branch 5 times, most recently from d0d5420 to 452f111 Compare July 27, 2026 21:32

@dylantientcheu dylantientcheu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR.

I see tests were deleted. The trickiest code in the PR and it's the part that ended up with no tests. Can we restore them?

@LorrisSaintGenez

Copy link
Copy Markdown
Contributor Author

@dylantientcheu Didn't want the PR to get too big, and planned on doing a follow-up PR, but will restore them

@LorrisSaintGenez
LorrisSaintGenez force-pushed the feat/apikeys-list-session branch from 452f111 to f22247b Compare July 28, 2026 17:44
@LorrisSaintGenez

Copy link
Copy Markdown
Contributor Author

Not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants