This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an introduction to LDAP support. There are some questions that need to be addressed, but at least the basic structure is in place now. Fixes #150 Signed-off-by: Miquel Sabaté Solà <[email protected]>
- Loading branch information
Showing
21 changed files
with
564 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ gem "mysql2" | |
gem "search_cop" | ||
gem "kaminari" | ||
gem "crono" | ||
gem "net-ldap" | ||
|
||
# Assets group. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
|
||
# TODO: (mssola) move this into its own file in the `lib` directory. | ||
# TODO: (mssola) take advantage of YAML syntax for inheriting values. This way | ||
# we could define different values for different environments (useful for | ||
# testing). | ||
|
||
config = File.join(Rails.root, "config", "config.yml") | ||
local = File.join(Rails.root, "config", "config-local.yml") | ||
|
||
app_config = YAML.load_file(config)["settings"] || {} | ||
app_config = YAML.load_file(config) || {} | ||
|
||
if File.exist?(local) | ||
# Check for bad user input in the local config.yml file. | ||
local_config = YAML.load_file(local)["settings"] | ||
local_config = YAML.load_file(local) | ||
if local_config.nil? || !local_config.is_a?(Hash) | ||
raise StandardError, "Wrong format for the config-local file!" | ||
end | ||
|
||
app_config = app_config.merge(local_config) | ||
end | ||
|
||
class << app_config | ||
# The `enabled?` method is a convenient method that checks whether a specific | ||
# feature is enabled or not. This method takes advantage of the convention | ||
# that each feature has the "enabled" key inside of it. If this key exists in | ||
# the checked feature, and it's set to true, then this method will return | ||
# true. It returns false otherwise. | ||
def enabled?(feature) | ||
return false if !self[feature] || self[feature].empty? | ||
self[feature]["enabled"].eql?(true) | ||
end | ||
end | ||
|
||
APP_CONFIG = app_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "portus/ldap" | ||
Warden::Strategies.add(:ldap_authenticatable, Portus::LDAP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddLdapNameToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :ldap_name, :string, default: nil | ||
add_index :users, :ldap_name, unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.