Skip to content

No way to obtain an API token without Rails console access #450

Description

@l3x4

Problem

The REST API (/api/v1/*, Bearer auth) is great — but there is currently no way for a user to obtain a token without server console access:

  • The README's bootstrap is user.regenerate_api_token! via Rails console.
  • PATCH /api/v1/api_token can only rotate a token you already have (it sits behind Bearer auth itself).
  • The API deliberately rejects session-cookie auth, and there is no token section anywhere in the web UI.

So on a hosted instance (e.g. stemplin.no), ordinary users cannot start using the API at all.

Desired outcome

A small "API token" section on the account page (/users/edit):

  • Shows whether a token exists (api_token_digest?) — never the token itself after creation.
  • A Generate / Regenerate button (with a confirm when regenerating — the old token stops working) that calls the existing User#regenerate_api_token! and shows the new token once, with a copy-friendly presentation, mirroring the README's "save this — it's only shown once" semantics.
  • Session-authenticated controller action (this is the web UI, not the API), covered by tests.

No changes to the API itself — the digest storage model and PATCH /api/v1/api_token stay as they are.


Issue created by Claude on behalf of @l3x4.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions