2.5 KiB
Integration authorization: extension vs. dev server
Dashtab connects to integrations through a small authorization layer
(app/auth/):
- Providers (
app/auth/providers/*) implement the protocol for an integration type. Discourse uses its user-api-key flow (RSA public key in, encrypted payload out) rather than OAuth2; other providers can be added without touching the transport. - Transport (
app/auth/transport.js) decides how the browser gets to the provider:- Browser extension →
identity.getRedirectURL(providerId)plusidentity.launchWebAuthFlow, which opens a browser-managed auth window and intercepts the redirect to a browser-owned domain. - Development server (no identity API) → full-page redirect to
${origin}${provider.webCallbackPath}(e.g./auth/discourse/callback).
- Browser extension →
Dashtab ships as a browser extension; the dev-server path exists only for development convenience. The choice is made at runtime by feature-detecting the identity API, so the same build works in both contexts.
Forum configuration
Discourse only accepts a redirect that matches the
allowed_user_api_auth_redirects site setting. Its default is
https://api.discourse.org/api/auth_redirect|discourse://auth_redirect, so an
admin must add the redirects Dashtab uses:
- Development server — the dev origin plus callback path, e.g.
http://localhost:4200/auth/discourse/callback. - Chrome / Chromium extension —
https://<extension-id>.chromiumapp.org/discourse, or the wildcardhttps://*.chromiumapp.org/*. - Firefox extension —
https://<host>.extensions.allizom.org/discourse(the host is derived from the add-on id), or the wildcardhttps://*.extensions.allizom.org/*.
allowed_user_api_auth_redirects supports * wildcards in the scheme, host,
path and query, so the wildcard entries are the least brittle option for a
publicly distributed extension. The exact redirect URL is whatever
browser.identity.getRedirectURL('discourse') returns; it is stable because the
extension ids are pinned (extension/manifest.chrome.json key and
extension/manifest.firefox.json browser_specific_settings.gecko.id).
Security note
Allowing https://*.chromiumapp.org/* makes it possible for any installed
extension to run the authorization flow. That does not leak keys: Discourse
encrypts the generated user API key to the public key supplied by the requesting
client, so only the client holding the matching private key can decrypt it. The
user still has to explicitly approve each request on the forum.