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

Option to skip authentication if no credentials provided #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ivalentinee
Copy link

Kind of specific to my development experience case but sometimes it's useful to just skip authentication if no credentials are provided instead of raising an error. Not sure if someone else needs this :/

If just one of credentials is set I intend to raise an error, because, well, it's strange to skip authentication with just missing password or username.

As i'm not experienced in elixir/plug/phoenix any suggestions are more than welcome =)

(didn't bump version in mix.exs)

@ivalentinee ivalentinee force-pushed the feature/skip_authentication_if_no_credentials_provided branch from 9dedbe4 to 6e2e0fb Compare February 22, 2018 12:54
@ivalentinee ivalentinee changed the title Options to skip authentication if no credentials provided Option to skip authentication if no credentials provided Feb 22, 2018
@nashby
Copy link

nashby commented Mar 2, 2018

@Vemperor hey, isn't it easier to just have something like

if System.get_env('BASIC_AUTH_USERNAME') do
  plug BasicAuth, ...
end

@ivalentinee
Copy link
Author

@nashby probably, but

  1. You have to duplicate ENV variable names in case of plain System.get_env.
  2. Оr use trickery if application config uses {:system, "BASIC_AUTH_USERNAME"}.

@paulanthonywilson
Copy link
Owner

Sorry, we haven't commented on this yet. Thanks for the PR @Vemperor.

I'm interested to know what you circumstances are that you want this? (My guess is that it is something along the lines of you want to secure a staging deployment but not the production deployment.)

@nashby I think the main issue with conditionally including the plug is that it gets compiled in so reflects the compilation environment rather than the deployment environment.

@ivalentinee
Copy link
Author

ivalentinee commented Mar 2, 2018

@paulanthonywilson 2 cases:

  1. We (me and my colleagues at work) are used to configure application via ENV as much as possible (including basic auth), because we don't even know who and where will setup the application (exploitating guys don't know a thing about elixir - they are not programmers).
  2. Every opensource project should be easy to configure to use basic auth via non-programming-language specific means (like in the first case), e.g. ENV variables or plain config. I prefer ENV variables =)

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 this pull request may close these issues.

3 participants