Protect API behind a bearer token
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ config :music_library,
|
||||
ecto_repos: [MusicLibrary.Repo],
|
||||
generators: [timestamp_type: :utc_datetime, binary_id: true]
|
||||
|
||||
config :music_library, MusicLibraryWeb, login_password: "change me"
|
||||
config :music_library, MusicLibraryWeb, login_password: "change me", api_token: "change me"
|
||||
|
||||
# Configures the endpoint
|
||||
config :music_library, MusicLibraryWeb.Endpoint,
|
||||
|
||||
+7
-1
@@ -69,10 +69,16 @@ if config_env() == :prod do
|
||||
environment variable LOGIN_PASSWORD is missing.
|
||||
"""
|
||||
|
||||
api_token =
|
||||
System.get_env("API_TOKEN") ||
|
||||
raise """
|
||||
environment variable API_TOKEN is missing.
|
||||
"""
|
||||
|
||||
host = System.get_env("PHX_HOST") || "example.com"
|
||||
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||
|
||||
config :music_library, MusicLibraryWeb, login_password: login_password
|
||||
config :music_library, MusicLibraryWeb, login_password: login_password, api_token: api_token
|
||||
|
||||
config :music_library, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user