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
f77be391
Commit
f77be391
authored
Dec 14, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'improve/ldap_respect_group_access' of /home/git/repositories/gitlab/gitlab-ee
parents
9124acc1
d3844662
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+10
-1
spec/lib/gitlab/ldap/ldap_access_spec.rb
spec/lib/gitlab/ldap/ldap_access_spec.rb
+34
-0
No files found.
lib/gitlab/ldap/access.rb
View file @
f77be391
...
...
@@ -40,13 +40,22 @@ module Gitlab
end
end
# Add user to GitLab group
# In case user already exists: update his access level
# only if existing permissions are lower than ldap one.
def
add_user_to_groups
(
user_id
,
group_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
group_cn
)
groups
.
each
do
|
group
|
group
.
add_users
([
user_id
],
group
.
ldap_access
)
if
group
.
ldap_access
.
present?
next
unless
group
.
ldap_access
.
present?
group_access
=
group
.
users_groups
.
find_by_user_id
(
user_id
)
next
if
group_access
&&
group_access
.
group_access
>=
group
.
ldap_access
group
.
add_users
([
user_id
],
group
.
ldap_access
)
end
end
# Remove user from GitLab group
def
remove_user_from_groups
(
user_id
,
group_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
group_cn
)
groups
.
each
do
|
group
|
...
...
spec/lib/gitlab/ldap/ldap_access_spec.rb
0 → 100644
View file @
f77be391
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Access
do
let
(
:access
)
{
Gitlab
::
LDAP
::
Access
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
ldap_cn:
'oss'
,
ldap_access:
Gitlab
::
Access
::
DEVELOPER
)
}
before
do
group
end
describe
:add_user_to_groups
do
it
"should add user to group"
do
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
member
=
group
.
members
.
first
member
.
user
.
should
==
user
member
.
group_access
.
should
==
Gitlab
::
Access
::
DEVELOPER
end
it
"should respect higher permissions"
do
group
.
add_owner
(
user
)
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
group
.
owners
.
should
include
(
user
)
end
it
"should update lower permissions"
do
group
.
add_user
(
user
,
Gitlab
::
Access
::
REPORTER
)
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
member
=
group
.
members
.
first
member
.
user
.
should
==
user
member
.
group_access
.
should
==
Gitlab
::
Access
::
DEVELOPER
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