Skip to content

Commit

Permalink
Minor changes to the algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ctria committed Dec 29, 2009
1 parent 13897bf commit c249500
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/authlogic_x509/session.rb
Expand Up @@ -55,19 +55,9 @@ def authenticating_with_x509?
end

def validate_by_x509

if controller.local_request?
self.x509_subject_dn = "/CN=Local Request"
elsif controller.request.env['SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['SSL_CLIENT_S_DN']
elsif controller.request.env['REDIRECT_SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['REDIRECT_SSL_CLIENT_S_DN']
elsif controller.request.env['HTTP_REDIRECT_SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['HTTP_REDIRECT_SSL_CLIENT_S_DN']
end

self.x509_subject_dn = get_subject_dn
if self.x509_subject_dn
self.attempted_record = klass.send(find_by_x509_login_method, x509_subject_dn)
self.attempted_record = search_for_record(find_by_x509_login_method, x509_subject_dn)
errors.add(:x509_subject_dn, I18n.t('error_messages.x509_subject_dn_not_found', :default => "does not exist")) if attempted_record.blank?
else
errors.add_to_base("Subject DN not found")
Expand All @@ -77,6 +67,18 @@ def validate_by_x509
def find_by_x509_login_method
self.class.find_by_x509_login_method
end

def get_subject_dn
if controller.local_request?
self.x509_subject_dn = "/CN=Local Request"
elsif controller.request.env['SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['SSL_CLIENT_S_DN']
elsif controller.request.env['REDIRECT_SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['REDIRECT_SSL_CLIENT_S_DN']
elsif controller.request.env['HTTP_REDIRECT_SSL_CLIENT_S_DN'] =~ /CN/
self.x509_subject_dn = controller.request.env['HTTP_REDIRECT_SSL_CLIENT_S_DN']
end
end
end
end
end

0 comments on commit c249500

Please sign in to comment.