Skip to content

Use environment variables for superuser credentials #22

@pawcoding

Description

@pawcoding

Use case

To improve security and flexibility, we should avoid hardcoding superuser credentials into the Astro config that is committed to repositories. Instead, it would be better to use credentials provided via a .env file.

Currently, you can already achieve this by importing credentials from Astro's environment variable API and passing them into the loader (as described in #17).

To simplify this process, we could define some environment variables globally instead of requiring them to be passed to each loader instance.

Advantages

  1. Define the variables once globally instead of passing them to every collection separately.
  2. The same variables can also be used in Use environment variables for superuser credentials astro-integration-pocketbase#4.

Requirements

  • Use ALP_SUPERUSER_EMAIL and ALP_SUPERUSER_PASSWORD instead of config.superuserCredentials.x.
  • Use ALP_SERVER_URL instead of config.url.

Not sure about the naming of these yet.

This change can be non-breaking if we keep the current configuration options as a fallback when no environment variables are defined.

  • Environment variables will serve as the base configuration.
  • Configuration options will take precedence, allowing developers to override the environment variables if needed (e.g., when using multiple PocketBase instances).

Bonus:
If possible, make the environment variables used by the loader type-safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/medium[internal] This is not a priority right now but will be done eventuallyteam/for-starters[internal] This can be done by someone external who wants to start contributingtype/featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions