Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for loading credentials from $CREDENTIALS_DIRECTORY #41

Open
Munksgaard opened this issue May 3, 2024 · 3 comments · May be fixed by #42
Open

Support for loading credentials from $CREDENTIALS_DIRECTORY #41

Munksgaard opened this issue May 3, 2024 · 3 comments · May be fixed by #42
Milestone

Comments

@Munksgaard
Copy link

This feature would make it easier to support the workflow around LoadCredentials and friends as described here: https://systemd.io/CREDENTIALS/

@hauleth
Copy link
Owner

hauleth commented May 3, 2024

That makes sense and it should be quite simple to add.

@Munksgaard
Copy link
Author

For reference, I have something like the following in my utils file:

  defp path_from_credentials_dir(name) do
    if credentials_directory = System.get_env("CREDENTIALS_DIRECTORY") do
      path =
        Path.join(credentials_directory, name)

      if File.regular?(path) do
        path
      else
        nil
      end
    else
      nil
    end
  end

It's not much and it's not a big problem to have that in my own code, but this package seems like a natural place for it to live.

@hauleth
Copy link
Owner

hauleth commented May 4, 2024

It looks interesting, however I would remove the second check in the body. So it would return paths even to non-existent credentials.

hauleth added a commit that referenced this issue May 4, 2024
This adds new function `systemd:credentials/1` which returns path for
credentials' files. This function checks if the `$CREDENTIALS_DIRECTORY`
variable was set and if it was set, then the path is always returned. It
is left up to the user to check if the file is existing and/or correct
one.

Close #41
@hauleth hauleth linked a pull request May 4, 2024 that will close this issue
hauleth added a commit that referenced this issue May 4, 2024
This adds new function `systemd:credentials/1` which returns path for
credentials' files. This function checks if the `$CREDENTIALS_DIRECTORY`
variable was set and if it was set, then the path is always returned. It
is left up to the user to check if the file is existing and/or correct
one.

Close #41
@hauleth hauleth added this to the 0.7.0 milestone May 4, 2024
hauleth added a commit that referenced this issue May 4, 2024
This adds new function `systemd:credentials/1` which returns path for
credentials' files. This function checks if the `$CREDENTIALS_DIRECTORY`
variable was set and if it was set, then the path is always returned. It
is left up to the user to check if the file is existing and/or correct
one.

Close #41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants