-
Notifications
You must be signed in to change notification settings - Fork 30
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
Authorization requires compile time settings #51
Comments
It probably could be something simple like this: defmodule VerkBasicAuth do
@behaviour Plug
def init(_opts) do
if Application.get_env(:verk_web, :authorization) do
BasicAuth.init(use_config: {:verk_web, :authorization})
else
:no_auth
end
end
def call(conn, :no_auth), do: conn
def call(%{request_path: "/verk" <> _} = conn, opts), do: BasicAuth.call(conn, opts)
def call(conn, _), do: conn
end |
Ahh, actually this won't work, as stated in Plug docs |
@tlvenn, I don't think this issue is related to environment variables versus application configuration. I may be completely wrong here but the issue here is that the |
Good catch @edgurgel. With Phoenix 1.3, you can leverage
|
Since Endpoint is all macros it checks
:authorization
config during verk_web compile time. Since compiling dependency happens only once, changing config after dependencies have been compiled has no effect. I think the reasonable solution would be to have a plug that checks the config on init. BasicAuth does exactly that, but because of https://github.com/edgurgel/verk_web/blob/master/lib/verk_web/endpoint.ex#L39 it is not even loaded.The text was updated successfully, but these errors were encountered: