Commit 6b0b7393 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Beat Rubocop's PerceivedComplexity

parent 6c02dc40
......@@ -67,22 +67,21 @@ class Projects::GitHttpController < Projects::ApplicationController
@user = find_kerberos_user(spnego_token)
if user
set_www_authenticate(spnego_challenge) if spnego_response_token
send_final_spnego_response
return # Allow access
end
end
# Authentication failed. Challenge the client to provide credentials.
challenges = []
challenges << 'Basic realm="GitLab"' if allow_basic_auth?
challenges << spnego_challenge if allow_kerberos_spnego_auth?
set_www_authenticate(challenges.join("\n"))
send_challenges
render plain: "HTTP Basic: Access denied\n", status: 401
end
def set_www_authenticate(value)
headers['Www-Authenticate'] = value
def send_challenges
challenges = []
challenges << 'Basic realm="GitLab"' if allow_basic_auth?
challenges << spnego_challenge if allow_kerberos_spnego_auth?
headers['Www-Authenticate'] = challenges.join("\n") if challenges.any?
end
def ensure_project_found!
......
......@@ -35,6 +35,10 @@ module KerberosSpnegoHelper
request.authorization.present? && (auth_scheme(request) == 'Negotiate')
end
def send_final_spnego_response
headers['Www-Authenticate'] = spnego_challenge if spnego_response_token
end
def find_kerberos_user(spnego_token)
krb_principal = spnego_credentials!(spnego_token)
return unless krb_principal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment