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

(POOLER-71) Add dummy authentication provider #180

Merged
merged 2 commits into from
Feb 10, 2017

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Feb 5, 2017

Previously it was difficult to do local development as VMPooler requires an LDAP
service for authentication. This commit adds a dummy authentication provider.
The provider has passes authentication if the username and password are
different, and fails if the username and password are the same. This commit
also updates the documentation in the config YML file.

@shermdog
Copy link
Contributor

shermdog commented Feb 7, 2017

👍

@glennsarti
Copy link
Contributor Author

I can rebase onto master if it's easier.

Copy link
Contributor

@mckern mckern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broadly like this, but can the dummy auth be confined to only run in development or test mode? It seems like there's nothing stopping it from running in production mode and that's kind of horrifying.

Gemfile Outdated

# Evaluate Gemfile.local if it exists
if File.exists? "#{__FILE__}.local"
eval(File.read("#{__FILE__}.local"), binding)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not generally a fan of the Gemfile.local pattern, but it's not something I feel strongly enough about to push back on.

BUT! You can eschew the passing of binding if you use instance_eval instead:

instance_eval(File.read("#{__FILE__}.local")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll piggyback these comments over to #177

@glennsarti
Copy link
Contributor Author

@mckern Actually I can do one of a few things. As part of #177 I added a VMPOOLER_DEBUG environment variable.

  1. I can make the authentication fail if the dummy auth is used but the VMPOOLER_DEBUG env var doesn't exist, and of course log a verbose message
  2. I can make the authentication proceed but log a console warning that this should be used in development
  3. I can modify the API entry point (https://github.com/puppetlabs/vmpooler/blob/master/lib/vmpooler.rb) where it loads the configuration, and fail to even start the API server if dummy auth is configured but the VMPOOLER_DEBUG env var is missing.

I'm leaning towards option 3. Fail hard, fail fast.

@glennsarti glennsarti force-pushed the ticket/maint/add-dummy-auth branch from e847137 to 3c441ac Compare February 9, 2017 01:38
@glennsarti
Copy link
Contributor Author

Rebased off of master now. The PR ordering just served to confuse things.

Previously it was difficult to do local development as VMPooler requires an LDAP
service for authentication. This commit adds a dummy authentication provider.
The provider has passes authentication if the username and password are
different, and fails if the username and password are the same.  This commit
also updates the documentation in the config YML file.
@mckern mckern force-pushed the ticket/maint/add-dummy-auth branch from a82b243 to 2c74f4f Compare February 10, 2017 00:23
lib/vmpooler.rb Outdated
@@ -32,6 +32,17 @@ def self.config(filepath='vmpooler.yaml')
parsed_config = YAML.load_file(config_file)
end

# Bail out if someone attempts to start vmpooler with dummy authentication
# without enbaling debug mode.
if parsed_config[:auth]['provider'] == 'dummy' && ENV['VMPOOLER_DEBUG']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this needs to be fixed. Good job, me!

@mckern mckern force-pushed the ticket/maint/add-dummy-auth branch from c8e591d to c1216d4 Compare February 10, 2017 00:25
If a user attempts to start vmpooler using dummy authentication
without setting the environment variable VMPOOLER_DEBUG, the vmpooler
will now refuse to start.
@mckern mckern force-pushed the ticket/maint/add-dummy-auth branch from c1216d4 to eb67cca Compare February 10, 2017 00:27
@glennsarti
Copy link
Contributor Author

Changes are fine by me. LGTM

@shrug shrug merged commit d67db2d into puppetlabs:master Feb 10, 2017
@glennsarti glennsarti deleted the ticket/maint/add-dummy-auth branch February 13, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants