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
0
Merge Requests
0
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
Boxiang Sun
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
lib/gitlab/saml/auth_hash.rb
lib/gitlab/saml/auth_hash.rb
+17
-0
lib/gitlab/saml/config.rb
lib/gitlab/saml/config.rb
+22
-0
lib/gitlab/saml/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
...
@@ -7,6 +7,11 @@ module Gitlab
module
Saml
module
Saml
class
User
<
Gitlab
::
OAuth
::
User
class
User
<
Gitlab
::
OAuth
::
User
def
initialize
(
auth_hash
)
super
update_user_attributes
end
def
save
def
save
super
(
'SAML'
)
super
(
'SAML'
)
end
end
...
@@ -18,7 +23,7 @@ module Gitlab
...
@@ -18,7 +23,7 @@ module Gitlab
@user
||=
find_or_create_ldap_user
@user
||=
find_or_create_ldap_user
end
end
if
auto_link_saml_
enabled
?
if
auto_link_saml_
user
?
@user
||=
find_by_email
@user
||=
find_by_email
end
end
...
@@ -37,11 +42,45 @@ module Gitlab
...
@@ -37,11 +42,45 @@ module Gitlab
end
end
end
end
def
changed?
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
end
protected
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
Gitlab
.
config
.
omniauth
.
auto_link_saml_user
end
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
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