0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-10 23:00:09 +08:00
discourse/config
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
..
environments DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
initializers DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
locales FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
application.rb DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
boot.rb DEV: Change test formatters (#39427) 2026-04-22 12:26:07 +02:00
cdn.yml.sample
database.yml DEV: Support per-unicorn-worker DB variable overrides (#35615) 2025-10-27 13:45:27 +08:00
deploy.rb.sample
dev_defaults.yml DEV: Add admin_dashboard:populate rake task to seed Site Traffic (#39775) 2026-05-06 12:07:47 +08:00
discourse.config.sample
discourse.pill.sample DEV: Move puma to test-only dependency (#38652) 2026-03-18 05:23:12 +08:00
discourse_defaults.conf FEATURE: Add opt-in IAM role assumption for S3 operations (#39174) 2026-04-15 04:29:50 +08:00
environment.rb DEV: Add env var for local email port (#36900) 2025-12-31 14:25:02 +10:00
logrotate.conf
multisite.yml.production-sample
nginx.sample.conf FIX: Add CORS header for all /assets/* (#39031) 2026-04-01 11:00:18 +01:00
official_plugins.json DEV: Drop d-teambuild from CI (#39417) 2026-04-21 17:43:19 +01:00
pitchfork.conf.rb DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
projections.json DEV: Prepare for rename of app/assets/javascripts/ -> frontend/ 2025-10-22 16:24:11 +01:00
routes.rb FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
sidekiq.yml
site_settings.yml FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
spring.rb
thin.yml.sample
unicorn_launcher DEV: Enable Pitchfork by default (#37679) 2026-02-11 11:52:39 +01:00