BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1a168279
Commit
1a168279
authored
Apr 04, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare SAML for group retrieval
parent
67136007
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
auth_hash.rb
lib/gitlab/saml/auth_hash.rb
+17
-0
config.rb
lib/gitlab/saml/config.rb
+22
-0
user.rb
lib/gitlab/saml/user.rb
+41
-2
No files found.
lib/gitlab/saml/auth_hash.rb
0 → 100644
View file @
1a168279
module
Gitlab
module
Saml
class
AuthHash
<
Gitlab
::
OAuth
::
AuthHash
def
groups
get_raw
(
Gitlab
::
Saml
::
Config
.
groups
)
end
private
def
get_raw
(
key
)
auth_hash
.
extra
[
:raw_info
][
key
]
end
end
end
end
lib/gitlab/saml/config.rb
0 → 100644
View file @
1a168279
# Load a specific server configuration
module
Gitlab
module
Saml
class
Config
class
<<
self
def
options
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'saml'
}
end
def
groups
options
[
'groups_attribute'
]
end
def
external_groups
options
[
'external_groups'
]
end
end
end
end
end
lib/gitlab/saml/user.rb
View file @
1a168279
...
...
@@ -7,6 +7,11 @@ module Gitlab
module
Saml
class
User
<
Gitlab
::
OAuth
::
User
def
initialize
(
auth_hash
)
super
update_user_attributes
end
def
save
super
(
'SAML'
)
end
...
...
@@ -18,7 +23,7 @@ module Gitlab
@user
||=
find_or_create_ldap_user
end
if
auto_link_saml_
enabled
?
if
auto_link_saml_
user
?
@user
||=
find_by_email
end
...
...
@@ -37,11 +42,45 @@ module Gitlab
end
end
def
changed?
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
end
protected
def
auto_link_saml_enabled?
def
build_new_user
user
=
super
if
external_users_enabled?
unless
(
auth_hash
.
groups
&
Gitlab
::
Saml
::
Config
.
external_groups
).
empty?
user
.
external
=
true
end
end
user
end
def
auto_link_saml_user?
Gitlab
.
config
.
omniauth
.
auto_link_saml_user
end
def
external_users_enabled?
!
Gitlab
::
Saml
::
Config
.
external_groups
.
nil?
end
def
auth_hash
=
(
auth_hash
)
@auth_hash
=
Gitlab
::
Saml
::
AuthHash
.
new
(
auth_hash
)
end
def
update_user_attributes
if
persisted?
if
external_users_enabled?
if
(
auth_hash
.
groups
&
Gitlab
::
Saml
::
Config
.
external_groups
).
empty?
gl_user
.
external
=
false
else
gl_user
.
external
=
true
end
end
end
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