Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
76633c04
Commit
76633c04
authored
Jul 12, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add omniauth_kerberos_spnego
parent
174b48e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
1 deletion
+70
-1
app/controllers/omniauth_kerberos_spnego_controller.rb
app/controllers/omniauth_kerberos_spnego_controller.rb
+17
-0
app/helpers/kerberos_spnego_helper.rb
app/helpers/kerberos_spnego_helper.rb
+4
-1
app/views/errors/kerberos_denied.html.haml
app/views/errors/kerberos_denied.html.haml
+7
-0
config/initializers/omniauth.rb
config/initializers/omniauth.rb
+5
-0
config/routes.rb
config/routes.rb
+1
-0
lib/omniauth/strategies/kerberos_spnego.rb
lib/omniauth/strategies/kerberos_spnego.rb
+36
-0
No files found.
app/controllers/omniauth_kerberos_spnego_controller.rb
0 → 100644
View file @
76633c04
class
OmniauthKerberosSpnegoController
<
ApplicationController
include
KerberosSpnegoHelper
skip_before_action
:authenticate_user!
def
negotiate
if
spnego_provided?
&&
(
krb_principal
=
spnego_credentials!
(
spnego_token
))
session
[
:kerberos_spnego_principal_name
]
=
krb_principal
send_final_spnego_response
redirect_to
user_kerberos_spnego_omniauth_callback_path
return
end
headers
[
'Www-Authenticate'
]
=
spnego_challenge
render
'errors/kerberos_denied.html.haml'
,
layout:
'errors'
,
status:
401
end
end
app/helpers/kerberos_spnego_helper.rb
View file @
76633c04
...
...
@@ -42,7 +42,6 @@ module KerberosSpnegoHelper
end
def
find_kerberos_user
spnego_token
=
Base64
.
strict_decode64
(
auth_param
(
request
))
krb_principal
=
spnego_credentials!
(
spnego_token
)
return
unless
krb_principal
...
...
@@ -77,4 +76,8 @@ module KerberosSpnegoHelper
Rails
.
logger
.
error
"
#{
self
.
class
.
name
}
: failed to process Negotiate/Kerberos authentication:
#{
ex
.
message
}
"
false
end
def
spnego_token
Base64
.
strict_decode64
(
auth_param
(
request
))
end
end
app/views/errors/kerberos_denied.html.haml
0 → 100644
View file @
76633c04
-
page_title
"Kerberos SPNEGO access denied"
%h1
401
%h3
Kerberos SPNEGO authentication failed
%hr
%p
Return to the
=
succeed
"."
do
=
link_to
new_user_session_path
,
'sign-in page'
config/initializers/omniauth.rb
View file @
76633c04
...
...
@@ -14,6 +14,11 @@ if Gitlab::LDAP::Config.enabled?
end
end
if
Gitlab
.
config
.
kerberos
.
enabled
require
'omniauth/strategies/kerberos_spnego'
Gitlab
.
config
.
omniauth
.
providers
<<
{
'name'
=>
'kerberos_spnego'
}
end
OmniAuth
.
config
.
full_host
=
Settings
.
gitlab
[
'base_url'
]
OmniAuth
.
config
.
allowed_request_methods
=
[
:post
]
# In case of auto sign-in, the GET method is used (users don't get to click on a button)
...
...
config/routes.rb
View file @
76633c04
...
...
@@ -498,6 +498,7 @@ Rails.application.routes.draw do
devise_scope
:user
do
get
'/users/auth/:provider/omniauth_error'
=>
'omniauth_callbacks#omniauth_error'
,
as: :omniauth_error
get
'/users/almost_there'
=>
'confirmations#almost_there'
get
'/users/auth/kerberos_spnego/negotiate'
=>
'omniauth_kerberos_spnego#negotiate'
end
root
to:
"root#index"
...
...
lib/omniauth/strategies/kerberos_spnego.rb
0 → 100644
View file @
76633c04
require
'omniauth'
module
OmniAuth
module
Strategies
class
KerberosSpnego
include
OmniAuth
::
Strategy
include
Gitlab
::
Routing
.
url_helpers
option
:name
,
'kerberos_spnego'
uid
{
username
}
info
do
{
username:
username
,
email:
email
}
end
def
username
principal_name
.
split
(
'@'
)[
0
]
end
def
email
username
+
'@'
+
principal_name
.
split
(
'@'
)[
1
].
downcase
end
def
principal_name
return
@principal_name
if
defined?
(
@principal_name
)
@principal_name
=
session
.
delete
(
:kerberos_spnego_principal_name
)
end
def
request_phase
redirect
users_auth_kerberos_spnego_negotiate_path
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment