Skip to content

[Feature]: Declarative API key provisioning #4490

Description

@vleksis

Feature Summary

Add a supported, non-interactive way to provision API keys declaratively

What problem does this feature solve?

Miniflux API keys currently have to be created after the application is running, either through the UI or via POST /v1/api-keys. This makes fully declarative deployments unnecessarily difficult.

For example, on NixOS I would like to deploy Miniflux together with another service that consumes the Miniflux API (I use it to enable homepage widget).

As far as I can tell, there is currently:

  • no configuration/environment option for defining an API key;
  • no *_FILE option for reading an API key from a secret file;

As a result, configuration-management systems such as NixOS, need an additional imperative bootstrap step:

  1. Start Miniflux.
  2. Authenticate using the user's password.
  3. Query existing API keys.
  4. Determine whether the desired key already exists.
  5. Create it if necessary.
  6. Extract the generated token.
  7. Store the token somewhere outside Miniflux.
  8. Start the dependent service.

This works, but requires custom logic for something that could be handled directly by Miniflux.

Proposed Solution

Add a supported mechanism for non-interactive and idempotent API key provisioning.

I don't have a strong preference for the exact interface. Any of the following would solve the problem.

CLI

For example:

miniflux -create-api-key \
  -username admin \
  -description homepage \
  -token-file /run/secrets/miniflux-homepage-api-key

Ideally the command would be idempotent.

Configuration / environment

Another possibility would be a file-based configuration option, for example:

API_KEY_DESCRIPTION=homepage
API_KEY_FILE=/run/secrets/miniflux-homepage-api-key

Using a file rather than passing the secret directly through an environment variable or command-line argument would work well with secret-management tools.

API

Alternatively, POST /v1/api-keys could optionally accept a caller-provided token instead of always generating one.

Alternatives Considered

The existing REST API can be used as a workaround. A provisioning service/script can authenticate to Miniflux using the user's username/password, call /v1/api-keys, look for a key with a particular description, create one if it does not exist, and then save the generated token to a local secret/state file.

This is workable, but every deployment system then has to implement and maintain its own bootstrap logic. For declarative systems such as NixOS this also introduces mutable state outside the normal configuration flow.

Another option is to create the API key manually in the UI, but that prevents a deployment from being reproduced automatically.

Additional Context

My immediate use case is NixOS, where Miniflux and services consuming its API are configured declaratively.

NixOS already supports supplying the initial Miniflux admin credentials from a file, so a similar mechanism for API credentials would fit well with secret-management tools such as sops-nix.

This is not specifically a NixOS request, though. The same functionality would be useful for Kubernetes, Ansible, Terraform, container-based deployments, and other automated configuration-management systems.

Checklist

  • I have searched existing issues to ensure this feature hasn't been requested before.
  • I understand that feature requests are not guaranteed to be implemented.
  • I agree to follow the project's contribution guidelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions