ruby-activeldap 0.8.3 → 0.8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +431 -0
- data/COPYING +340 -0
- data/LICENSE +58 -0
- data/README +104 -0
- data/Rakefile +165 -0
- data/TODO +22 -0
- data/benchmark/bench-al.rb +202 -0
- data/benchmark/config.yaml.sample +5 -0
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/README +182 -0
- data/examples/al-admin/Rakefile +10 -0
- data/examples/al-admin/app/controllers/account_controller.rb +50 -0
- data/examples/al-admin/app/controllers/application.rb +15 -0
- data/examples/al-admin/app/controllers/directory_controller.rb +22 -0
- data/examples/al-admin/app/controllers/users_controller.rb +38 -0
- data/examples/al-admin/app/controllers/welcome_controller.rb +4 -0
- data/examples/al-admin/app/helpers/account_helper.rb +2 -0
- data/examples/al-admin/app/helpers/application_helper.rb +6 -0
- data/examples/al-admin/app/helpers/directory_helper.rb +2 -0
- data/examples/al-admin/app/helpers/users_helper.rb +13 -0
- data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
- data/examples/al-admin/app/models/entry.rb +19 -0
- data/examples/al-admin/app/models/ldap_user.rb +49 -0
- data/examples/al-admin/app/models/user.rb +91 -0
- data/examples/al-admin/app/views/account/login.rhtml +12 -0
- data/examples/al-admin/app/views/account/sign_up.rhtml +22 -0
- data/examples/al-admin/app/views/directory/index.rhtml +5 -0
- data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
- data/examples/al-admin/app/views/layouts/application.rhtml +41 -0
- data/examples/al-admin/app/views/users/_attribute_information.rhtml +22 -0
- data/examples/al-admin/app/views/users/_entry.rhtml +12 -0
- data/examples/al-admin/app/views/users/_form.rhtml +29 -0
- data/examples/al-admin/app/views/users/_object_class_information.rhtml +23 -0
- data/examples/al-admin/app/views/users/edit.rhtml +10 -0
- data/examples/al-admin/app/views/users/index.rhtml +9 -0
- data/examples/al-admin/app/views/users/show.rhtml +3 -0
- data/examples/al-admin/app/views/welcome/index.rhtml +16 -0
- data/examples/al-admin/config/boot.rb +45 -0
- data/examples/al-admin/config/database.yml.example +19 -0
- data/examples/al-admin/config/environment.rb +68 -0
- data/examples/al-admin/config/environments/development.rb +21 -0
- data/examples/al-admin/config/environments/production.rb +18 -0
- data/examples/al-admin/config/environments/test.rb +19 -0
- data/examples/al-admin/config/ldap.yml.example +21 -0
- data/examples/al-admin/config/routes.rb +26 -0
- data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
- data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
- data/examples/al-admin/lib/authenticated_system.rb +131 -0
- data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
- data/examples/al-admin/lib/tasks/gettext.rake +35 -0
- data/examples/al-admin/po/en/al-admin.po +190 -0
- data/examples/al-admin/po/ja/al-admin.po +190 -0
- data/examples/al-admin/po/nl/al-admin.po +202 -0
- data/examples/al-admin/public/.htaccess +40 -0
- data/examples/al-admin/public/404.html +30 -0
- data/examples/al-admin/public/500.html +30 -0
- data/examples/al-admin/public/dispatch.cgi +10 -0
- data/examples/al-admin/public/dispatch.fcgi +24 -0
- data/examples/al-admin/public/dispatch.rb +10 -0
- data/examples/al-admin/public/favicon.ico +0 -0
- data/examples/al-admin/public/images/rails.png +0 -0
- data/examples/al-admin/public/javascripts/application.js +2 -0
- data/examples/al-admin/public/javascripts/controls.js +833 -0
- data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
- data/examples/al-admin/public/javascripts/effects.js +1088 -0
- data/examples/al-admin/public/javascripts/prototype.js +2515 -0
- data/examples/al-admin/public/robots.txt +1 -0
- data/examples/al-admin/public/stylesheets/rails.css +35 -0
- data/examples/al-admin/public/stylesheets/screen.css +52 -0
- data/examples/al-admin/script/about +3 -0
- data/examples/al-admin/script/breakpointer +3 -0
- data/examples/al-admin/script/console +3 -0
- data/examples/al-admin/script/destroy +3 -0
- data/examples/al-admin/script/generate +3 -0
- data/examples/al-admin/script/performance/benchmarker +3 -0
- data/examples/al-admin/script/performance/profiler +3 -0
- data/examples/al-admin/script/plugin +3 -0
- data/examples/al-admin/script/process/inspector +3 -0
- data/examples/al-admin/script/process/reaper +3 -0
- data/examples/al-admin/script/process/spawner +3 -0
- data/examples/al-admin/script/runner +3 -0
- data/examples/al-admin/script/server +3 -0
- data/examples/al-admin/test/fixtures/users.yml +9 -0
- data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
- data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
- data/examples/al-admin/test/run-test.sh +3 -0
- data/examples/al-admin/test/test_helper.rb +28 -0
- data/examples/al-admin/test/unit/user_test.rb +13 -0
- data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
- data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
- data/examples/config.yaml.example +5 -0
- data/examples/example.der +0 -0
- data/examples/example.jpg +0 -0
- data/examples/groupadd +41 -0
- data/examples/groupdel +35 -0
- data/examples/groupls +49 -0
- data/examples/groupmod +42 -0
- data/examples/lpasswd +55 -0
- data/examples/objects/group.rb +13 -0
- data/examples/objects/ou.rb +4 -0
- data/examples/objects/user.rb +20 -0
- data/examples/ouadd +38 -0
- data/examples/useradd +45 -0
- data/examples/useradd-binary +50 -0
- data/examples/userdel +34 -0
- data/examples/userls +50 -0
- data/examples/usermod +42 -0
- data/examples/usermod-binary-add +47 -0
- data/examples/usermod-binary-add-time +51 -0
- data/examples/usermod-binary-del +48 -0
- data/examples/usermod-lang-add +43 -0
- data/lib/active_ldap.rb +978 -0
- data/lib/active_ldap/adapter/base.rb +512 -0
- data/lib/active_ldap/adapter/ldap.rb +233 -0
- data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
- data/lib/active_ldap/adapter/net_ldap.rb +290 -0
- data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
- data/lib/active_ldap/association/belongs_to.rb +47 -0
- data/lib/active_ldap/association/belongs_to_many.rb +42 -0
- data/lib/active_ldap/association/collection.rb +83 -0
- data/lib/active_ldap/association/has_many.rb +31 -0
- data/lib/active_ldap/association/has_many_utils.rb +35 -0
- data/lib/active_ldap/association/has_many_wrap.rb +46 -0
- data/lib/active_ldap/association/proxy.rb +102 -0
- data/lib/active_ldap/associations.rb +172 -0
- data/lib/active_ldap/attributes.rb +211 -0
- data/lib/active_ldap/base.rb +1256 -0
- data/lib/active_ldap/callbacks.rb +19 -0
- data/lib/active_ldap/command.rb +48 -0
- data/lib/active_ldap/configuration.rb +114 -0
- data/lib/active_ldap/connection.rb +234 -0
- data/lib/active_ldap/distinguished_name.rb +250 -0
- data/lib/active_ldap/escape.rb +12 -0
- data/lib/active_ldap/get_text/parser.rb +142 -0
- data/lib/active_ldap/get_text_fallback.rb +53 -0
- data/lib/active_ldap/get_text_support.rb +12 -0
- data/lib/active_ldap/helper.rb +23 -0
- data/lib/active_ldap/ldap_error.rb +74 -0
- data/lib/active_ldap/object_class.rb +93 -0
- data/lib/active_ldap/operations.rb +419 -0
- data/lib/active_ldap/populate.rb +44 -0
- data/lib/active_ldap/schema.rb +427 -0
- data/lib/active_ldap/timeout.rb +75 -0
- data/lib/active_ldap/timeout_stub.rb +17 -0
- data/lib/active_ldap/user_password.rb +93 -0
- data/lib/active_ldap/validations.rb +112 -0
- data/po/en/active-ldap.po +3011 -0
- data/po/ja/active-ldap.po +3044 -0
- data/rails/plugin/active_ldap/README +54 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +7 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +21 -0
- data/rails/plugin/active_ldap/init.rb +19 -0
- data/test/al-test-utils.rb +362 -0
- data/test/command.rb +62 -0
- data/test/config.yaml.sample +6 -0
- data/test/run-test.rb +31 -0
- data/test/test-unit-ext.rb +4 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/backtrace-filter.rb +17 -0
- data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
- data/test/test-unit-ext/priority.rb +163 -0
- metadata +211 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# In the development environment your application's code is reloaded on
|
|
4
|
+
# every request. This slows down response time but is perfect for development
|
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
6
|
+
config.cache_classes = false
|
|
7
|
+
|
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
|
9
|
+
config.whiny_nils = true
|
|
10
|
+
|
|
11
|
+
# Enable the breakpoint server that script/breakpointer connects to
|
|
12
|
+
config.breakpoint_server = true
|
|
13
|
+
|
|
14
|
+
# Show full error reports and disable caching
|
|
15
|
+
config.action_controller.consider_all_requests_local = true
|
|
16
|
+
config.action_controller.perform_caching = false
|
|
17
|
+
config.action_view.cache_template_extensions = false
|
|
18
|
+
config.action_view.debug_rjs = true
|
|
19
|
+
|
|
20
|
+
# Don't care if the mailer can't send
|
|
21
|
+
config.action_mailer.raise_delivery_errors = false
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# The production environment is meant for finished, "live" apps.
|
|
4
|
+
# Code is not reloaded between requests
|
|
5
|
+
config.cache_classes = true
|
|
6
|
+
|
|
7
|
+
# Use a different logger for distributed setups
|
|
8
|
+
# config.logger = SyslogLogger.new
|
|
9
|
+
|
|
10
|
+
# Full error reports are disabled and caching is turned on
|
|
11
|
+
config.action_controller.consider_all_requests_local = false
|
|
12
|
+
config.action_controller.perform_caching = true
|
|
13
|
+
|
|
14
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
|
15
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
|
16
|
+
|
|
17
|
+
# Disable delivery errors, bad email addresses will be ignored
|
|
18
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# The test environment is used exclusively to run your application's
|
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
7
|
+
config.cache_classes = true
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Tell ActionMailer not to deliver emails to the real world.
|
|
17
|
+
# The :test delivery method accumulates sent emails in the
|
|
18
|
+
# ActionMailer::Base.deliveries array.
|
|
19
|
+
config.action_mailer.delivery_method = :test
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
development:
|
|
2
|
+
host: 127.0.0.1
|
|
3
|
+
port: 389
|
|
4
|
+
base: dc=devel,dc=local,dc=net
|
|
5
|
+
bind_dn: cn=admin,dc=local,dc=net
|
|
6
|
+
password: secret
|
|
7
|
+
|
|
8
|
+
test:
|
|
9
|
+
host: 127.0.0.1
|
|
10
|
+
port: 389
|
|
11
|
+
base: dc=test,dc=local,dc=net
|
|
12
|
+
bind_dn: cn=admin,dc=local,dc=net
|
|
13
|
+
password: secret
|
|
14
|
+
|
|
15
|
+
production:
|
|
16
|
+
host: 127.0.0.1
|
|
17
|
+
port: 389
|
|
18
|
+
method: :tls
|
|
19
|
+
base: dc=production,dc=local,dc=net
|
|
20
|
+
bind_dn: cn=admin,dc=local,dc=net
|
|
21
|
+
password: secret
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
3
|
+
|
|
4
|
+
# Sample of regular route:
|
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
7
|
+
|
|
8
|
+
# Sample of named route:
|
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
|
11
|
+
|
|
12
|
+
# You can have the root of your site routed by hooking up ''
|
|
13
|
+
# -- just remember to delete public/index.html.
|
|
14
|
+
map.top '', :controller => "welcome"
|
|
15
|
+
|
|
16
|
+
map.login 'login', :controller => "account", :action => "login"
|
|
17
|
+
map.logout 'logout', :controller => "account", :action => "logout"
|
|
18
|
+
|
|
19
|
+
# Allow downloading Web Service WSDL as a file with an extension
|
|
20
|
+
# instead of a file named 'wsdl'
|
|
21
|
+
map.connect ':controller/service.wsdl', :action => 'wsdl'
|
|
22
|
+
|
|
23
|
+
# Install the default route as the lowest priority.
|
|
24
|
+
map.connect ':controller/:action/:id.:format'
|
|
25
|
+
map.connect ':controller/:action/:id'
|
|
26
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table "users", :force => true do |t|
|
|
4
|
+
t.column :login, :string
|
|
5
|
+
t.column :dn, :string
|
|
6
|
+
t.column :updated_at, :datetime
|
|
7
|
+
t.column :salt, :string
|
|
8
|
+
t.column :remember_token, :string
|
|
9
|
+
t.column :remember_token_expires_at, :datetime
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.down
|
|
14
|
+
drop_table "users"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module ActionController
|
|
2
|
+
class AbstractRequest
|
|
3
|
+
def relative_url_root_with_accept_http_rails_relative_url_root
|
|
4
|
+
@env["RAILS_RELATIVE_URL_ROOT"] ||= @env["HTTP_RAILS_RELATIVE_URL_ROOT"]
|
|
5
|
+
relative_url_root_without_accept_http_rails_relative_url_root
|
|
6
|
+
end
|
|
7
|
+
alias_method_chain :relative_url_root, :accept_http_rails_relative_url_root
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module AuthenticatedSystem
|
|
2
|
+
protected
|
|
3
|
+
# Returns true or false if the user is logged in.
|
|
4
|
+
# Preloads @current_user with the user model if they're logged in.
|
|
5
|
+
def logged_in?
|
|
6
|
+
current_user != :false
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def check_connectivity
|
|
10
|
+
if logged_in? and !current_user.connected?
|
|
11
|
+
self.current_user = :false
|
|
12
|
+
end
|
|
13
|
+
true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Accesses the current user from the session.
|
|
17
|
+
def current_user
|
|
18
|
+
@current_user ||= (session[:user] && User.find_by_id(session[:user])) || :false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Store the given user in the session.
|
|
22
|
+
def current_user=(new_user)
|
|
23
|
+
session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id
|
|
24
|
+
@current_user = new_user
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Check if the user is authorized.
|
|
28
|
+
#
|
|
29
|
+
# Override this method in your controllers if you want to restrict access
|
|
30
|
+
# to only a few actions or if you want to check if the user
|
|
31
|
+
# has the correct rights.
|
|
32
|
+
#
|
|
33
|
+
# Example:
|
|
34
|
+
#
|
|
35
|
+
# # only allow nonbobs
|
|
36
|
+
# def authorize?
|
|
37
|
+
# current_user.login != "bob"
|
|
38
|
+
# end
|
|
39
|
+
def authorized?
|
|
40
|
+
true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Filter method to enforce a login requirement.
|
|
44
|
+
#
|
|
45
|
+
# To require logins for all actions, use this in your controllers:
|
|
46
|
+
#
|
|
47
|
+
# before_filter :login_required
|
|
48
|
+
#
|
|
49
|
+
# To require logins for specific actions, use this in your controllers:
|
|
50
|
+
#
|
|
51
|
+
# before_filter :login_required, :only => [ :edit, :update ]
|
|
52
|
+
#
|
|
53
|
+
# To skip this in a subclassed controller:
|
|
54
|
+
#
|
|
55
|
+
# skip_before_filter :login_required
|
|
56
|
+
#
|
|
57
|
+
def login_required
|
|
58
|
+
username, passwd = get_auth_data
|
|
59
|
+
self.current_user ||= User.authenticate(username, passwd) || :false if username && passwd
|
|
60
|
+
logged_in? && authorized? ? true : access_denied
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Redirect as appropriate when an access request fails.
|
|
64
|
+
#
|
|
65
|
+
# The default action is to redirect to the login screen.
|
|
66
|
+
#
|
|
67
|
+
# Override this method in your controllers if you want to have special
|
|
68
|
+
# behavior in case the user is not authorized
|
|
69
|
+
# to access the requested action. For example, a popup window might
|
|
70
|
+
# simply close itself.
|
|
71
|
+
def access_denied
|
|
72
|
+
respond_to do |accepts|
|
|
73
|
+
accepts.html do
|
|
74
|
+
store_location
|
|
75
|
+
flash.now[:notice] = _("Please login.")
|
|
76
|
+
redirect_to :controller => '/account', :action => 'login'
|
|
77
|
+
end
|
|
78
|
+
accepts.xml do
|
|
79
|
+
headers["Status"] = "Unauthorized"
|
|
80
|
+
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
|
|
81
|
+
render :text => "Could't authenticate you", :status => '401 Unauthorized'
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
false
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Store the URI of the current request in the session.
|
|
88
|
+
#
|
|
89
|
+
# We can return to this location by calling #redirect_back_or_default.
|
|
90
|
+
def store_location
|
|
91
|
+
session[:return_to] = url_for(params.merge(:only_path => false))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Redirect to the URI stored by the most recent store_location call or
|
|
95
|
+
# to the passed default.
|
|
96
|
+
def redirect_back_or_default(default)
|
|
97
|
+
session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default)
|
|
98
|
+
session[:return_to] = nil
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Inclusion hook to make #current_user and #logged_in?
|
|
102
|
+
# available as ActionView helper methods.
|
|
103
|
+
def self.included(base)
|
|
104
|
+
base.send :helper_method, :current_user, :logged_in?
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# When called with before_filter :login_from_cookie will check for an :auth_token
|
|
108
|
+
# cookie and log the user back in if apropriate
|
|
109
|
+
def login_from_cookie
|
|
110
|
+
return unless cookies[:auth_token] && !logged_in?
|
|
111
|
+
user = User.find_by_remember_token(cookies[:auth_token])
|
|
112
|
+
if user && user.remember_token?
|
|
113
|
+
user.remember_me
|
|
114
|
+
self.current_user = user
|
|
115
|
+
cookies[:auth_token] = {
|
|
116
|
+
:value => current_user.remember_token,
|
|
117
|
+
:expires => current_user.remember_token_expires_at
|
|
118
|
+
}
|
|
119
|
+
flash.now[:notice] = _("Logged in successfully")
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
@@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
|
|
125
|
+
# gets BASIC auth info
|
|
126
|
+
def get_auth_data
|
|
127
|
+
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
|
|
128
|
+
auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
|
|
129
|
+
return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
module AuthenticatedTestHelper
|
|
2
|
+
# Sets the current user in the session from the user fixtures.
|
|
3
|
+
def login_as(user)
|
|
4
|
+
@request.session[:user] = user ? users(user).id : nil
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def content_type(type)
|
|
8
|
+
@request.env['Content-Type'] = type
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def accept(accept)
|
|
12
|
+
@request.env["HTTP_ACCEPT"] = accept
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def authorize_as(user)
|
|
16
|
+
if user
|
|
17
|
+
@request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("#{users(user).login}:test")}"
|
|
18
|
+
accept 'application/xml'
|
|
19
|
+
content_type 'application/xml'
|
|
20
|
+
else
|
|
21
|
+
@request.env["HTTP_AUTHORIZATION"] = nil
|
|
22
|
+
accept nil
|
|
23
|
+
content_type nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# http://project.ioni.st/post/217#post-217
|
|
28
|
+
#
|
|
29
|
+
# def test_new_publication
|
|
30
|
+
# assert_difference(Publication, :count) do
|
|
31
|
+
# post :create, :publication => {...}
|
|
32
|
+
# # ...
|
|
33
|
+
# end
|
|
34
|
+
# end
|
|
35
|
+
#
|
|
36
|
+
def assert_difference(object, method = nil, difference = 1)
|
|
37
|
+
initial_value = object.send(method)
|
|
38
|
+
yield
|
|
39
|
+
assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def assert_no_difference(object, method, &block)
|
|
43
|
+
assert_difference object, method, 0, &block
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Assert the block redirects to the login
|
|
47
|
+
#
|
|
48
|
+
# assert_requires_login(:bob) { |c| c.get :edit, :id => 1 }
|
|
49
|
+
#
|
|
50
|
+
def assert_requires_login(login = nil)
|
|
51
|
+
yield HttpLoginProxy.new(self, login)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def assert_http_authentication_required(login = nil)
|
|
55
|
+
yield XmlLoginProxy.new(self, login)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def reset!(*instance_vars)
|
|
59
|
+
instance_vars = [:controller, :request, :response] unless instance_vars.any?
|
|
60
|
+
instance_vars.collect! { |v| "@#{v}".to_sym }
|
|
61
|
+
instance_vars.each do |var|
|
|
62
|
+
instance_variable_set(var, instance_variable_get(var).class.new)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class BaseLoginProxy
|
|
68
|
+
attr_reader :controller
|
|
69
|
+
attr_reader :options
|
|
70
|
+
def initialize(controller, login)
|
|
71
|
+
@controller = controller
|
|
72
|
+
@login = login
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
def authenticated
|
|
77
|
+
raise NotImplementedError
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def check
|
|
81
|
+
raise NotImplementedError
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def method_missing(method, *args)
|
|
85
|
+
@controller.reset!
|
|
86
|
+
authenticate
|
|
87
|
+
@controller.send(method, *args)
|
|
88
|
+
check
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
class HttpLoginProxy < BaseLoginProxy
|
|
93
|
+
protected
|
|
94
|
+
def authenticate
|
|
95
|
+
@controller.login_as @login if @login
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def check
|
|
99
|
+
@controller.assert_redirected_to :controller => 'account', :action => 'login'
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class XmlLoginProxy < BaseLoginProxy
|
|
104
|
+
protected
|
|
105
|
+
def authenticate
|
|
106
|
+
@controller.accept 'application/xml'
|
|
107
|
+
@controller.authorize_as @login if @login
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def check
|
|
111
|
+
@controller.assert_response 401
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
desc "Update *.po/*.pot files and create *.mo from *.po files"
|
|
4
|
+
task :gettext => ["gettext:po:update", "gettext:mo:create"]
|
|
5
|
+
|
|
6
|
+
namespace :gettext do
|
|
7
|
+
namespace :environment do
|
|
8
|
+
desc "Setup environment for GetText"
|
|
9
|
+
task :setup => :environment do
|
|
10
|
+
require "gettext/utils"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
namespace :po do
|
|
15
|
+
desc "Update po/pot files (GetText)"
|
|
16
|
+
task :update => "gettext:environment:setup" do
|
|
17
|
+
require 'active_ldap/get_text/parser'
|
|
18
|
+
options = {
|
|
19
|
+
# :extract_schema => true, # use this if you have any extra schema.
|
|
20
|
+
}
|
|
21
|
+
GetText::RGetText.add_parser(ActiveLdap::GetText::Parser.new(options))
|
|
22
|
+
|
|
23
|
+
files = Dir.glob("{app,lib,components}/**/*.{rb,rhtml,rxml}")
|
|
24
|
+
GetText.update_pofiles("al-admin", files,
|
|
25
|
+
"AL Admin #{ActiveLdap::VERSION}")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
namespace :mo do
|
|
30
|
+
desc "Create *.mo from *.po (GetText)"
|
|
31
|
+
task :create => "gettext:environment:setup" do
|
|
32
|
+
GetText.create_mofiles(false, 'po', 'locale')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# English translations for AL Admin package.
|
|
2
|
+
# Copyright (C) 2007 Kouhei Sutou
|
|
3
|
+
# This file is distributed under the same license as the AL Admin package.
|
|
4
|
+
# Kouhei Sutou <kou@cozmixng.org>, 2007.
|
|
5
|
+
#
|
|
6
|
+
msgid ""
|
|
7
|
+
msgstr ""
|
|
8
|
+
"Project-Id-Version: AL Admin 0.8.3\n"
|
|
9
|
+
"POT-Creation-Date: 2007-08-24 22:25+0900\n"
|
|
10
|
+
"PO-Revision-Date: 2007-08-19 09:44+0900\n"
|
|
11
|
+
"Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
|
|
12
|
+
"Language-Team: English\n"
|
|
13
|
+
"MIME-Version: 1.0\n"
|
|
14
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
|
15
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
16
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
17
|
+
|
|
18
|
+
#: app/models/ldap_user.rb:8
|
|
19
|
+
msgid "LdapUser|Password"
|
|
20
|
+
msgstr ""
|
|
21
|
+
|
|
22
|
+
#: app/models/ldap_user.rb:9
|
|
23
|
+
msgid "LdapUser|Password confirmation"
|
|
24
|
+
msgstr ""
|
|
25
|
+
|
|
26
|
+
#: app/models/user.rb:-
|
|
27
|
+
msgid "User|Dn"
|
|
28
|
+
msgstr ""
|
|
29
|
+
|
|
30
|
+
#: app/models/user.rb:-
|
|
31
|
+
msgid "User|Login"
|
|
32
|
+
msgstr ""
|
|
33
|
+
|
|
34
|
+
#: app/models/user.rb:-
|
|
35
|
+
msgid "User|Remember token"
|
|
36
|
+
msgstr ""
|
|
37
|
+
|
|
38
|
+
#: app/models/user.rb:-
|
|
39
|
+
msgid "User|Remember token expires at"
|
|
40
|
+
msgstr ""
|
|
41
|
+
|
|
42
|
+
#: app/models/user.rb:-
|
|
43
|
+
msgid "User|Salt"
|
|
44
|
+
msgstr ""
|
|
45
|
+
|
|
46
|
+
#: app/models/user.rb:-
|
|
47
|
+
msgid "User|Updated at"
|
|
48
|
+
msgstr ""
|
|
49
|
+
|
|
50
|
+
#: app/models/entry.rb:17
|
|
51
|
+
msgid "disable saving"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
54
|
+
#: app/models/entry.rb:-
|
|
55
|
+
msgid "entry"
|
|
56
|
+
msgstr ""
|
|
57
|
+
|
|
58
|
+
#: app/models/ldap_user.rb:-
|
|
59
|
+
msgid "ldap user"
|
|
60
|
+
msgstr ""
|
|
61
|
+
|
|
62
|
+
#: app/models/user.rb:-
|
|
63
|
+
msgid "user"
|
|
64
|
+
msgstr ""
|
|
65
|
+
|
|
66
|
+
#: app/controllers/account_controller.rb:22 lib/authenticated_system.rb:119
|
|
67
|
+
msgid "Logged in successfully"
|
|
68
|
+
msgstr ""
|
|
69
|
+
|
|
70
|
+
#: app/controllers/account_controller.rb:24
|
|
71
|
+
msgid "Login or Password is incorrect"
|
|
72
|
+
msgstr ""
|
|
73
|
+
|
|
74
|
+
#: app/controllers/account_controller.rb:36
|
|
75
|
+
msgid "Thanks for signing up!"
|
|
76
|
+
msgstr ""
|
|
77
|
+
|
|
78
|
+
#: app/controllers/account_controller.rb:47
|
|
79
|
+
msgid "You have been logged out."
|
|
80
|
+
msgstr ""
|
|
81
|
+
|
|
82
|
+
#: app/controllers/users_controller.rb:26
|
|
83
|
+
msgid "User was successfully updated."
|
|
84
|
+
msgstr ""
|
|
85
|
+
|
|
86
|
+
#: app/controllers/directory_controller.rb:18
|
|
87
|
+
msgid "Populating is only for initialization"
|
|
88
|
+
msgstr ""
|
|
89
|
+
|
|
90
|
+
#: app/views/layouts/application.rhtml:25
|
|
91
|
+
msgid "Top"
|
|
92
|
+
msgstr ""
|
|
93
|
+
|
|
94
|
+
#: app/views/users/show.rhtml:3 app/views/users/edit.rhtml:10
|
|
95
|
+
msgid "Menu|Back"
|
|
96
|
+
msgstr ""
|
|
97
|
+
|
|
98
|
+
#: app/views/users/_form.rhtml:6 app/views/account/sign_up.rhtml:7
|
|
99
|
+
#: app/views/account/login.rhtml:5
|
|
100
|
+
msgid "Password"
|
|
101
|
+
msgstr ""
|
|
102
|
+
|
|
103
|
+
#: app/views/users/_form.rhtml:13 app/views/account/sign_up.rhtml:10
|
|
104
|
+
msgid "Confirm Password"
|
|
105
|
+
msgstr ""
|
|
106
|
+
|
|
107
|
+
#: app/views/users/edit.rhtml:5
|
|
108
|
+
msgid "Command|Update"
|
|
109
|
+
msgstr ""
|
|
110
|
+
|
|
111
|
+
#: app/views/users/edit.rhtml:9
|
|
112
|
+
msgid "Menu|Show"
|
|
113
|
+
msgstr ""
|
|
114
|
+
|
|
115
|
+
#: app/views/users/index.rhtml:2
|
|
116
|
+
msgid "No user."
|
|
117
|
+
msgstr ""
|
|
118
|
+
|
|
119
|
+
#: app/views/users/_object_class_information.rhtml:9
|
|
120
|
+
msgid "objectClass name"
|
|
121
|
+
msgstr ""
|
|
122
|
+
|
|
123
|
+
#: app/views/users/_object_class_information.rhtml:10
|
|
124
|
+
#: app/views/users/_attribute_information.rhtml:8
|
|
125
|
+
msgid "description"
|
|
126
|
+
msgstr ""
|
|
127
|
+
|
|
128
|
+
#: app/views/users/_attribute_information.rhtml:6
|
|
129
|
+
msgid "attribute name"
|
|
130
|
+
msgstr ""
|
|
131
|
+
|
|
132
|
+
#: app/views/users/_attribute_information.rhtml:7
|
|
133
|
+
msgid "value"
|
|
134
|
+
msgstr ""
|
|
135
|
+
|
|
136
|
+
#: app/views/welcome/index.rhtml:3
|
|
137
|
+
msgid "Menu|Users list"
|
|
138
|
+
msgstr ""
|
|
139
|
+
|
|
140
|
+
#: app/views/welcome/index.rhtml:4
|
|
141
|
+
msgid "Menu|Logout"
|
|
142
|
+
msgstr ""
|
|
143
|
+
|
|
144
|
+
#: app/views/welcome/index.rhtml:5
|
|
145
|
+
msgid "Menu|Directory"
|
|
146
|
+
msgstr ""
|
|
147
|
+
|
|
148
|
+
#: app/views/welcome/index.rhtml:7
|
|
149
|
+
msgid "Menu|Login"
|
|
150
|
+
msgstr ""
|
|
151
|
+
|
|
152
|
+
#: app/views/welcome/index.rhtml:8
|
|
153
|
+
msgid "Menu|Sign up"
|
|
154
|
+
msgstr ""
|
|
155
|
+
|
|
156
|
+
#: app/views/welcome/index.rhtml:12
|
|
157
|
+
msgid "Menu|Populate"
|
|
158
|
+
msgstr ""
|
|
159
|
+
|
|
160
|
+
#: app/views/welcome/index.rhtml:14
|
|
161
|
+
msgid "OK?"
|
|
162
|
+
msgstr ""
|
|
163
|
+
|
|
164
|
+
#: app/views/account/sign_up.rhtml:4 app/views/account/login.rhtml:2
|
|
165
|
+
msgid "Login"
|
|
166
|
+
msgstr ""
|
|
167
|
+
|
|
168
|
+
#: app/views/account/sign_up.rhtml:13 app/views/account/sign_up.rhtml:21
|
|
169
|
+
msgid "Sign up"
|
|
170
|
+
msgstr ""
|
|
171
|
+
|
|
172
|
+
#: app/views/account/login.rhtml:8
|
|
173
|
+
msgid "Remember me:"
|
|
174
|
+
msgstr ""
|
|
175
|
+
|
|
176
|
+
#: app/views/account/login.rhtml:11
|
|
177
|
+
msgid "Log in"
|
|
178
|
+
msgstr ""
|
|
179
|
+
|
|
180
|
+
#: app/views/directory/populate.rhtml:1
|
|
181
|
+
msgid "Done."
|
|
182
|
+
msgstr ""
|
|
183
|
+
|
|
184
|
+
#: app/views/directory/populate.rhtml:2
|
|
185
|
+
msgid "Menu|Index"
|
|
186
|
+
msgstr ""
|
|
187
|
+
|
|
188
|
+
#: lib/authenticated_system.rb:75
|
|
189
|
+
msgid "Please login."
|
|
190
|
+
msgstr ""
|