diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 9d570a9a..514e9923 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -20,9 +20,9 @@ class AccountController < ApplicationController
# Login request and validation
def login
- if request.get?
- logout_user
- else
+ if User.current.logged?
+ redirect_to home_url
+ elsif request.post?
authenticate_user
end
end
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index c83e972d..c74c0041 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -173,6 +173,7 @@ class WikiController < ApplicationController
def annotate
@annotate = @page.annotate(params[:version])
render_404 unless @annotate
+ @editable = editable?
end
verify :method => :delete, :only => [:destroy], :redirect_to => { :action => :show }
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index d009ae33..3536b4f6 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -21,6 +21,7 @@ class AuthSourceLdap < AuthSource
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_nil => true
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
validates_numericality_of :port, :only_integer => true
+ validate :custom_filter_should_be_valid_ldap_filter_syntax
before_validation :strip_ldap_attributes
@@ -101,10 +102,17 @@ class AuthSourceLdap < AuthSource
ldap_con = initialize_ldap_con(self.account, self.account_password)
login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
- attrs = {}
+ custom_ldap_filter = custom_filter_to_ldap
- ldap_con.search( :base => self.base_dn,
- :filter => object_filter & login_filter,
+ if custom_ldap_filter.present?
+ search_filters = object_filter & login_filter & custom_ldap_filter
+ else
+ search_filters = object_filter & login_filter
+ end
+ attrs = {}
+
+ ldap_con.search( :base => self.base_dn,
+ :filter => search_filters,
:attributes=> search_attributes) do |entry|
if onthefly_register?
@@ -119,6 +127,27 @@ class AuthSourceLdap < AuthSource
attrs
end
+ def custom_filter_to_ldap
+ return nil unless custom_filter.present?
+
+ begin
+ return Net::LDAP::Filter.construct(custom_filter)
+ rescue Net::LDAP::LdapError # Filter syntax error
+ logger.debug "LDAP custom filter syntax error for: #{custom_filter}" if logger && logger.debug?
+ return nil
+ end
+ end
+
+ def custom_filter_should_be_valid_ldap_filter_syntax
+ return true unless custom_filter.present?
+
+ begin
+ return Net::LDAP::Filter.construct(custom_filter)
+ rescue Net::LDAP::LdapError # Filter syntax error
+ errors.add(:custom_filter, :invalid)
+ end
+ end
+
def self.get_attr(entry, attr_name)
if !attr_name.blank?
entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
diff --git a/app/views/ldap_auth_sources/_form.rhtml b/app/views/ldap_auth_sources/_form.rhtml
index 9ffffafc..8699a2cd 100644
--- a/app/views/ldap_auth_sources/_form.rhtml
+++ b/app/views/ldap_auth_sources/_form.rhtml
@@ -25,6 +25,9 @@
<%= check_box 'auth_source', 'onthefly_register' %>
+
+
+<%= text_field 'auth_source', 'custom_filter', :size => 60 %>