0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/spec
Sam 5458a5f150
FEATURE: User API key device authorization flow (#40189)
Adds an OAuth-style device authorization flow for user API keys so
applications that can't open a browser (CLIs, headless tools, IoT
clients) can request a key by displaying a short user-facing code.

The client POSTs to `/user-api-key/device` to obtain a device code,
a user code, and a verification URL. The user visits the URL,
authenticates, confirms the application and scopes, and either
approves or denies the request. Meanwhile the client polls
`/user-api-key/device/poll` until it receives the encrypted key
payload, a denial, or expiry.

The flow is implemented as a `UserApiKey::DeviceAuth` namespace of
service objects (`CreateRequest`, `Authorize`, `Deny`, `Poll`,
`Store`, `Crypto`, `ApprovalTokenStore`, `GrantPresenter`). Pending
grants live in Redis with a short TTL and are rate limited per IP
and per user code. Encrypted payload generation is shared with the
existing redirect-based flow.

Also adds first-class expiration for user API keys:

- New `expires_at` column on `user_api_keys`.
- New `max_user_api_key_expiry_days` site setting (default 365).
- Clients can request a key lifetime via `expires_in_seconds`, which
  is surfaced to the user on the authorization screen and serialized
  back to the client.
- A `user_api_key` rake task for listing, inspecting, expiring, and
  revoking keys from the console.

---------

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
2026-06-10 16:09:44 -04:00
..
db FIX: Prevent backslash accumulation in upload markdown labels (#39461) 2026-06-03 18:10:38 +02:00
fabricators FIX: Backfill normalized referrer for historical browser pageviews (#40357) 2026-06-09 09:04:57 +08:00
fixtures DEV: Allow plugins to register admin-panel-specific CSS (#40345) 2026-05-28 11:03:38 +01:00
generator DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
helpers DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
import_export
initializers Revert "FEATURE: discourse-workflows (#39704)" (#40366) 2026-05-28 13:59:42 +01:00
integration FIX: Correctly rescue failed embed_mode parsing (#40298) 2026-05-26 15:29:48 +01:00
integrity DEV: Make upcoming change CSS classes opt-in (#40669) 2026-06-10 12:12:58 +10:00
jobs FIX: Match webhook-related messagebus audience to controller audience (#40693) 2026-06-09 18:22:26 +01:00
lib FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
mailers FIX: allow custom email sender name via translation overrides (#40674) 2026-06-09 14:03:03 +04:00
migrations FEATURE: Exclude small actions from topic counters and unread tracking (#40481) 2026-06-08 08:03:55 +02:00
models FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
multisite DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
queries/reports FEATURE: Activity by category section of the new dashboard's engagement section (#40227) 2026-05-22 13:10:38 +08:00
requests FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
script/import_scripts
serializers FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
services FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
support FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
system FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
tasks DEV: update GIFs migration script (#40741) 2026-06-10 22:46:26 +04:00
views
rails_helper.rb DEV: Finish extracting rails spec helpers (#40552) 2026-06-04 14:11:14 +02:00
regenerate_swagger_docs
swagger_helper.rb