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

Add Generated AUTH_API_KEY to .env file during seeds.exs (setup) #87

Closed
1 task done
nelsonic opened this issue Jul 24, 2020 · 2 comments
Closed
1 task done

Add Generated AUTH_API_KEY to .env file during seeds.exs (setup) #87

nelsonic opened this issue Jul 24, 2020 · 2 comments
Labels
enhancement New feature or enhancement of existing functionality

Comments

@nelsonic
Copy link
Member

nelsonic commented Jul 24, 2020

At present we have code that generates a New "Admin" AUTH_API_KEY in the seeds.exs script:

auth/priv/repo/seeds.exs

Lines 36 to 53 in fafc5e0

def create_apikey_for_admin(person) do
{:ok, key} =
%{
"name" => "system admin key",
"description" => "Created by /priv/repo/seeds.exs during setup.",
# the default host in %Plug.Conn
"url" => "www.example.com"
}
|> AuthWeb.ApikeyController.make_apikey(person.id)
|> Auth.Apikey.create_apikey()
api_key = key.client_id <> "/" <> key.client_secret
# Set the AUTH_API_KEY to a valid value that is in the DB:
System.put_env("AUTH_API_KEY", api_key)
IO.inspect(System.get_env("AUTH_API_KEY"), label: "AUTH_API_KEY")
IO.puts("- - - - - - - - - - - - - - - - - - - - - - ")
key
end

But we are having to manually copy this environment variable ... it's getting old.

Todo

  • Append the AUTH_API_KEY .env file and then source .env during execution of seeds.exs
@nelsonic nelsonic added the enhancement New feature or enhancement of existing functionality label Jul 24, 2020
@nelsonic
Copy link
Member Author

Having fun with this error:

** (FunctionClauseError) no function clause matching in Enum."-join/2-lists^foldl/2-0-"/3

😕

@nelsonic
Copy link
Member Author

This is included in PR #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant