Skip to content

Passing secrets as environment variables #1105

@happysalada

Description

@happysalada

There is another discussion that I'm not sure where it's the best place to take.
This discussion is around secret environment variables. It seems the consensus is that you cannot have secrets inside environment variables because they can be read by others.
Ideally secrets should be put in files, that will be read by the application.
I'm linking to that discussion in systemd systemd/systemd#19604
I'm not sure how you feel about this. I can open a new issue if you want to discuss more.
Basically the change would look like (multiplied by every secret env var)

secret_key_base =
  cond do
    not is_nil(System.get_env("SECRET_KEY_BASE_FILE) ->
       secret_key_base = File.read(System.get_env("SECRET_KEY_BASE_FILE"))
    not is_nil(System.get_env("SECRET_KEY_BASE)) ->
       secret_key_base = System.get_env("SECRET_KEY_BASE")
   true ->
      raise "SECRET_KEY_BASE or SECRET_KEY_BASE_FILE configuration option is required. See https://plausible.io/docs/self-hosting-configuration#server"
  end

if byte_size(secret_key_base) < 64 do
         raise "SECRET_KEY_BASE must be at least 64 bytes long. See https://plausible.io/docs/self-hosting-configuration#server"
end
...

I'm not sure if you are open to such a change or how you feel about the issue.

Let me know if you need/want more information, and I'll be happy to provide.

Metadata

Metadata

Assignees

No one assigned

    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