Parsing of email address from Debian client cert CN fixed
This commit is contained in:
parent
3bc317b572
commit
bf96a72158
1 changed files with 8 additions and 2 deletions
|
|
@ -25,8 +25,14 @@ class ApplicationController < ActionController::Base
|
|||
# Only run if the user is not yet logged in
|
||||
if not user_signed_in?
|
||||
if debian_sso_dn = request.env['HTTP_X_DEBIAN_SSO_DN']
|
||||
debian_sso_dn =~ /^CN=(.+),/
|
||||
debian_email = $1
|
||||
|
||||
# Turn
|
||||
# "/O=Debian SSO client certificate/CN=haas@debian.org"
|
||||
# into
|
||||
# haas@debian.org
|
||||
debian_email = debian_sso_dn.split('/').grep(/^CN/).first.split('=').last
|
||||
|
||||
raise "No valid certificate CN found" unless debian_email.include? '@'
|
||||
|
||||
@user = User.where(provider: 'debian-sso', email: debian_email).first_or_create do |user|
|
||||
user.provider = 'debian-sso'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue