[PATCH conductor] BZ#864393 Fixed number of logins and number of failed logins for LDAP authentication
by Tomas Hrcka
http://bugzilla.redhat.com/show_bug.cgi?id=864393
---
src/app/models/user.rb | 6 +++++-
src/spec/models/user_spec.rb | 15 +++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/app/models/user.rb b/src/app/models/user.rb
index 5db8e95..41ac20b 100644
--- a/src/app/models/user.rb
+++ b/src/app/models/user.rb
@@ -122,9 +122,13 @@ class User < ActiveRecord::Base
def self.authenticate_using_ldap(username, password, ipaddress)
if Ldap.valid_ldap_authentication?(username, password)
u = User.find_by_username(username) || create_ldap_user!(username)
- u.login_count += 1
update_login_attributes(u, ipaddress)
else
+ u = User.find_by_username(username)
+ if u.present?
+ u.failed_login_count += 1
+ u.save!
+ end
u = nil
end
u.save! unless u.nil?
diff --git a/src/spec/models/user_spec.rb b/src/spec/models/user_spec.rb
index 9e38278..fbb8990 100644
--- a/src/spec/models/user_spec.rb
+++ b/src/spec/models/user_spec.rb
@@ -111,6 +111,21 @@ describe User do
u.id.should == user.id
end
+ it "should authenticate a existing user against LDAP and increment login count" do
+ user = FactoryGirl.create(:tuser, :ignore_password => true, :password => nil)
+ Ldap.should_receive(:valid_ldap_authentication?).and_return(true)
+ u = User.authenticate_using_ldap(user.username, 'random', user.last_login_ip)
+ u.login_count.should be(1)
+ end
+
+ it "should not authenticate a existing user against LDAP and increment failed login count" do
+ user = FactoryGirl.create(:tuser, :ignore_password => true, :password => nil)
+ Ldap.should_receive(:valid_ldap_authentication?).and_return(false)
+ User.authenticate_using_ldap(user.username, 'random', user.last_login_ip)
+ user.reload
+ user.failed_login_count.should be(1)
+ end
+
it "should authenticate a user with valid kerberos ticket" do
User.authenticate_using_krb('krbuser', '192.168.1.1').should_not be_nil
u = User.find_by_username('krbuser')
--
1.7.11.4
11 years, 6 months
[PATCH conductor] redmine #3601: whitelist all attributes as needing to be explicitly set by default
by Maros Zatko
From: Mo Morsi <mmorsi(a)redhat.com>
Note this patch requires rails 3.2 to work (which will be in Fedora soon [1])
This changes the application so that no mass assigments are permitted by default.
I added the neccessary model changes so that things should be working again with the
current mass assignments in place in the application (specs pass after this patch)
Obviously this still doesn't solve the mass assignment issue, but the items that should
be removed and explicitly set are marked with comments and thus we can tackle them one
by one in the various areas that they need to be set explicitly in the application
[1] http://lists.fedoraproject.org/pipermail/ruby-sig/2012-July/001077.html
---
src/app/models/session_entity.rb | 3 +++
src/app/models/user.rb | 2 ++
src/app/models/view_state.rb | 2 ++
3 files changed, 7 insertions(+)
diff --git a/src/app/models/session_entity.rb b/src/app/models/session_entity.rb
index 98ac974..9a2d23a 100644
--- a/src/app/models/session_entity.rb
+++ b/src/app/models/session_entity.rb
@@ -19,6 +19,9 @@ class SessionEntity < ActiveRecord::Base
belongs_to :entity
belongs_to :permission_session
+ attr_accessible :user, :session, :entity,
+ :user_id, :session_id, :entity_id
+
validates_presence_of :user_id
validates_presence_of :permission_session_id
validates_presence_of :entity_id
diff --git a/src/app/models/user.rb b/src/app/models/user.rb
index 5db8e95..937abd1 100644
--- a/src/app/models/user.rb
+++ b/src/app/models/user.rb
@@ -77,6 +77,8 @@ class User < ActiveRecord::Base
before_validation :strip_whitespace
after_save :update_entity
+ attr_accessible :login, :password, :password_confirmation, :first_name, :last_name, :quota, :email, :ignore_password
+
validate :validate_ldap_changes, :if => Proc.new {|user|
!user.new_record? && SETTINGS_CONFIG[:auth][:strategy] == "ldap"}
validates_presence_of :quota
diff --git a/src/app/models/view_state.rb b/src/app/models/view_state.rb
index bc1f0fe..bfa2171 100644
--- a/src/app/models/view_state.rb
+++ b/src/app/models/view_state.rb
@@ -33,6 +33,8 @@ class ViewState < ActiveRecord::Base
self.primary_key = :uuid
belongs_to :user
+ attr_accessible :name, :controller, :action, :station, :association
+
validates_presence_of :name
validates_uniqueness_of :name
validates_presence_of :user_id
--
1.7.11.4
11 years, 6 months
Sprint End 11-Oct, Demos and Repo Freeze
by steve linabery
Hi aeolus community,
The current upstream development sprint officially ends on Thursday, 11-Oct-2012.
In an ideal world all patches would be on list by COB on Monday. All patches should be reviewed and pushed by Tuesday. This gives us a little breathing room for testing before the demo.
Thank you in advance for your cooperation!
Steve|eggs
11 years, 6 months
[PATCH] BZ864513 allow for possibly deleted pool_family/pool associations
by Tzu-Mainn Chen
From: Tzu-Mainn Chen <tzumainn(a)redhat.com>
---
src/app/views/logs/_filter_view.html.haml | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/app/views/logs/_filter_view.html.haml b/src/app/views/logs/_filter_view.html.haml
index fd29d0b..6db5d8b 100644
--- a/src/app/views/logs/_filter_view.html.haml
+++ b/src/app/views/logs/_filter_view.html.haml
@@ -25,11 +25,13 @@
= filter_table(@header, @paginated_events) do |event|
- source = event.source
- provider_account = source.nil? ? nil : source.provider_account
+ - pool_family = source.nil? ? nil : source.pool_family
+ - pool = source.nil? ? nil : source.pool
%tr{:class => cycle('nostripe','stripe')}
%td= event.event_time.strftime("%d-%b-%Y %H:%M:%S")
%td= source.nil? ? t('logs.index.not_available') : source.name
%td= source.nil? ? t('logs.index.not_available') : source.state
- %td= source.nil? ? t('logs.index.not_available') : source.pool_family.name + "/" + source.pool.name
+ %td= (pool_family.nil? || pool.nil?) ? t('logs.index.not_available') : pool_family.name + "/" + pool.name
%td= provider_account.nil? ? t('logs.index.not_available') : provider_account.provider.name + "/" + provider_account.name
%td= source.nil? ? t('logs.index.not_available') : source.owner.username
%td= event.summary
--
1.7.6.5
11 years, 6 months
Wiki syntax when using < code > tag
by Petr Blaho
Hi all,
I know a few of us had a problems with displaying <code>sample</code> in XML examples on wiki pages.
I played a little and I found solution.
Use <pre></pre> as usual but include inner <code></code> around your
example without newlines between <pre> and <code> and your example.
Ex:
<pre><code><animal>
<name>Rozárka</name>
<species>cat</species>
</animal></code></pre>
You can check on https://www.aeolusproject.org/redmine/projects/aeolus/wiki/Providers where I edited 2 blocks with <code> tag in examples.
--
Petr Blaho
11 years, 6 months
How to deploy our new jekyll website
by Francesco Vollero
Hi everyone,
We (me and Mike Orazi) faced a "tiny" issue with the opportunity
to get hosted by github with pages.
The problem is that at the moment we have this setup:
An apache server with mod_proxy that :
on / : will return our website with nanoc
on /redmine : will redirect to our thin server with Redmine
Now, if we get hosted by github we will not have anymore
/redmine that will be redirected on redmine instance.
So we faced three possible ways:
1) Keep the current machine and have the git-hook that will care
about re-run jekyll and build the files)
2) Create a subdomain called web.aeolusproject.org for github pages
and our mod_proxy will just redirect us there
3) Create a subdomain called issues.aeolusproject.org for redmine
and have all the issues mapped there and the website on github
(This mean we gonna loose all the link to previous issues)
Looking forward to get your feedback on this,
Cheers,
- Francesco
11 years, 6 months