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
1ddc6102
Commit
1ddc6102
authored
Apr 23, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group SAML adds user to Group
parent
f99d6d75
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
0 deletions
+79
-0
ee/lib/gitlab/auth/group_saml/identity_linker.rb
ee/lib/gitlab/auth/group_saml/identity_linker.rb
+10
-0
ee/lib/gitlab/auth/group_saml/membership_updater.rb
ee/lib/gitlab/auth/group_saml/membership_updater.rb
+28
-0
ee/spec/lib/gitlab/auth/group_saml/identity_linker_spec.rb
ee/spec/lib/gitlab/auth/group_saml/identity_linker_spec.rb
+12
-0
ee/spec/lib/gitlab/auth/group_saml/membership_updater_spec.rb
...pec/lib/gitlab/auth/group_saml/membership_updater_spec.rb
+29
-0
No files found.
ee/lib/gitlab/auth/group_saml/identity_linker.rb
View file @
1ddc6102
...
...
@@ -10,6 +10,12 @@ module Gitlab
@saml_provider
=
saml_provider
end
def
link
super
update_group_membership
unless
failed?
end
protected
def
identity
...
...
@@ -18,6 +24,10 @@ module Gitlab
extern_uid:
uid
.
to_s
)
.
first_or_initialize
end
def
update_group_membership
MembershipUpdater
.
new
(
current_user
,
saml_provider
).
execute
end
end
end
end
...
...
ee/lib/gitlab/auth/group_saml/membership_updater.rb
0 → 100644
View file @
1ddc6102
module
Gitlab
module
Auth
module
GroupSaml
class
MembershipUpdater
attr_reader
:user
,
:saml_provider
delegate
:group
,
to: :saml_provider
def
initialize
(
user
,
saml_provider
)
@user
=
user
@saml_provider
=
saml_provider
end
def
execute
return
if
group
.
member?
(
@user
)
group
.
add_user
(
@user
,
default_membership_level
)
end
private
def
default_membership_level
:guest
end
end
end
end
end
ee/spec/lib/gitlab/auth/group_saml/identity_linker_spec.rb
View file @
1ddc6102
...
...
@@ -21,6 +21,12 @@ describe Gitlab::Auth::GroupSaml::IdentityLinker do
expect
(
subject
).
not_to
be_changed
end
it
'adds user to group'
do
subject
.
link
expect
(
saml_provider
.
group
.
member?
(
user
)).
to
eq
(
true
)
end
end
context
'identity needs to be created'
do
...
...
@@ -51,5 +57,11 @@ describe Gitlab::Auth::GroupSaml::IdentityLinker do
expect
(
subject
).
to
be_changed
end
it
'adds user to group'
do
subject
.
link
expect
(
saml_provider
.
group
.
member?
(
user
)).
to
eq
(
true
)
end
end
end
ee/spec/lib/gitlab/auth/group_saml/membership_updater_spec.rb
0 → 100644
View file @
1ddc6102
require
'spec_helper'
describe
Gitlab
::
Auth
::
GroupSaml
::
MembershipUpdater
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:saml_provider
)
{
create
(
:saml_provider
)
}
let
(
:group
)
{
saml_provider
.
group
}
it
"adds the user to the group"
do
described_class
.
new
(
user
,
saml_provider
).
execute
expect
(
group
.
users
).
to
include
(
user
)
end
it
"doesn't duplicate group membership"
do
group
.
add_guest
(
user
)
described_class
.
new
(
user
,
saml_provider
).
execute
expect
(
group
.
members
.
count
).
to
eq
1
end
it
"doesn't overwrite existing membership level"
do
group
.
add_master
(
user
)
described_class
.
new
(
user
,
saml_provider
).
execute
expect
(
group
.
members
.
pluck
(
:access_level
)).
to
eq
([
Gitlab
::
Access
::
MASTER
])
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