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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/vmpooler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ 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'
unless ENV['VMPOOLER_DEBUG']
warning = [
"Dummy authentication should not be used outside of debug mode",
"please set environment variable VMPOOLER_DEBUG to 'true' if you want to use dummy authentication",
]

raise warning.join(";\s")
end
end

# Set some configuration defaults
parsed_config[:redis] ||= {}
parsed_config[:redis]['server'] ||= 'localhost'
Expand Down
2 changes: 2 additions & 0 deletions lib/vmpooler/api/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def authorized?

def authenticate(auth, username_str, password_str)
case auth['provider']
when 'dummy'
return (username_str != password_str)
when 'ldap'
require 'rubygems'
require 'net/ldap'
Expand Down
27 changes: 24 additions & 3 deletions vmpooler.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,22 @@
# This section contains information related to authenticating users
# for token operations.
#
# Currently the only supported provider is LDAP; the following parameters
# will all be under an ':ldap:' subsection (see example below).
# Supported Auth Providers:
# - Dummy
# - LDAP
#
# - Dummy Auth Provider
# The Dummy Authentication provider should only be used during development or testing
# If the Username and Password are different then validation succeeds
# If the Username and Password are the same then validation fails
#
# Example:
# :auth:
# provider: 'dummy'
#
# - LDAP Auth Provider
# The LDAP Authentication provider will validate usernames and passwords against an
# existing LDAP service
#
# Available configuration parameters:
#
Expand All @@ -154,8 +168,15 @@
#
# - user_object
# The LDAP object-type used to designate a user object.

#
# Example:
# :auth:
# provider: 'ldap'
# :ldap:
# host: 'localhost'
# port: 389
# base: 'ou=users,dc=company,dc=com'
# user_object: 'uid'

:auth:
provider: 'ldap'
Expand Down