-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Summary
Users currently need to create OAuth2 clients via manual curl calls to the /auth/register endpoint.
This is error-prone, hard to discover, and offers no way to review or revoke existing clients.
The proposal is to introduce an "OAuth2 Clients" section inside Twake instance Settings (under "Security & data access") where users can create, list and revoke OAuth2 clients using mechanisms already provided by the stack.
Context
This need came from a previous project for a custom N8N node for TwakeDrive. Today, for a user to create an OAuth2 client typically requires:
- Calling the
/auth/registerendpoint manually. - Crafting JSON payloads and HTTP headers.
- Reading documentation outside the platform (for example, n8n integration guides).
Problems in practice:
- Users must rely on external documentation.
- Manual JSON and HTTP crafting is error-prone.
- There is no UI to:
- view existing OAuth2 clients,
- revoke a client,
- inspect redirect URIs or other metadata.
- OAuth clients are sensitive security objects that users logically expect to manage like “Connected apps”.
On the stack side:
- Dynamic Client Registration endpoints already exist:
POST/auth/register, PUT/auth/register/:id, DELETE/auth/register/:id. - OAuth clients are stored as documents of type
io.cozy.oauth.clients. - Cozy-stack-client exposes
OAuthClientsCollection, which uses/settings/clientsto list and delete clients.
In short: the backend building blocks already exist, they just are not surfaced in Settings.
Proposal
Add a new section in Settings:
Settings → Security & data access → OAuth2 clients
1. UI: Create client
A minimal creation form:
- Client name (required)
- Redirect URI (required)
- Client kind (dropdown ?, any case by default "web")
- Software ID (optional but recommended I suppose ?)
On submit:
- The UI sends a POST to
/auth/registerusing the same fields as manual curl usage. - The response shows:
- the generated
client_id, - and the
client_secretif applicable (visible once).
- the generated
- Provide copy-to-clipboard helpers.
Editing is intentionally out of scope for MVP.
If the redirect URI needs to change, the user deletes and recreates the client.
2. UI: List existing clients
Using OAuthClientsCollection.all() (backed by /settings/clients), the UI displays:
- Client name
- Redirect URI(s)
- Software ID
- Client kind
- Creation or update timestamp (whatever is exposed)
A simple table layout is sufficient.
3. UI: Revoke client
Each entry includes a Delete / Revoke action:
- Internally calls
OAuthClientsCollection.destroy(doc)(DELETE on/settings/clients/:id). - Tokens associated with the client are invalidated according to stack behavior.
- The entry disappears after confirmation.
Technical implementation
Creation:
- Reuse existing Dynamic Client Registration:
- POST
/auth/register - Payload includes:
client_name,redirect_uris,client_kind,software_id
- POST
Listing and deletion:
- Reuse
OAuthClientsCollection:- GET
/settings/clients - DELETE
/settings/clients/:id
- GET
No new backend endpoints are strictly required for MVP in my opinion.
Open questions
-
Recommended payload for
/auth/register
Areclient_kindandsoftware_idrequired, optional, or recommended?
Any fields that should be exposed or hidden in the UI? -
Secret handling
Shouldclient_secretbe shown only once?
Should the UI prevent redisplay?
I vote for a display at creation, but never after a "confirmation" that the user has saved hisclient_secret, but open to discussion. -
Revocation semantics
When a client is deleted, are its refresh tokens always invalidated?
Any UX messaging the UI should include?
Out of scope for MVP
- Editing existing clients
- Multiple redirect URIs
- Scopes management ? For now with the N8N project, we only need access to
io.cozy.files, but for other services we may need other permissions - Anything beyond “create / list / revoke” that comes in mind ?