Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
9bf9bb02
Commit
9bf9bb02
authored
Jul 18, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ldap): fixed issue with ldap group mappings to org roles sync, #1450
parent
5744c703
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
pkg/login/ldap.go
+9
-4
pkg/login/ldap_test.go
+20
-0
No files found.
pkg/login/ldap.go
View file @
9bf9bb02
...
@@ -130,14 +130,17 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
...
@@ -130,14 +130,17 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
return
err
return
err
}
}
//
remove or updat
e org roles
//
update or remov
e org roles
for
_
,
org
:=
range
orgsQuery
.
Result
{
for
_
,
org
:=
range
orgsQuery
.
Result
{
match
:=
false
for
_
,
group
:=
range
a
.
server
.
LdapGroups
{
for
_
,
group
:=
range
a
.
server
.
LdapGroups
{
if
org
.
OrgId
!=
group
.
OrgId
{
if
org
.
OrgId
!=
group
.
OrgId
{
continue
continue
}
}
if
ldapUser
.
isMemberOf
(
group
.
GroupDN
)
{
if
ldapUser
.
isMemberOf
(
group
.
GroupDN
)
{
match
=
true
if
org
.
Role
!=
group
.
OrgRole
{
if
org
.
Role
!=
group
.
OrgRole
{
// update role
// update role
cmd
:=
m
.
UpdateOrgUserCommand
{
OrgId
:
org
.
OrgId
,
UserId
:
user
.
Id
,
Role
:
group
.
OrgRole
}
cmd
:=
m
.
UpdateOrgUserCommand
{
OrgId
:
org
.
OrgId
,
UserId
:
user
.
Id
,
Role
:
group
.
OrgRole
}
...
@@ -147,15 +150,17 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
...
@@ -147,15 +150,17 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
}
}
// ignore subsequent ldap group mapping matches
// ignore subsequent ldap group mapping matches
break
break
}
else
{
}
// remove role
}
// remove role if no mappings match
if
!
match
{
cmd
:=
m
.
RemoveOrgUserCommand
{
OrgId
:
org
.
OrgId
,
UserId
:
user
.
Id
}
cmd
:=
m
.
RemoveOrgUserCommand
{
OrgId
:
org
.
OrgId
,
UserId
:
user
.
Id
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
err
return
err
}
}
}
}
}
}
}
// add missing org roles
// add missing org roles
for
_
,
group
:=
range
a
.
server
.
LdapGroups
{
for
_
,
group
:=
range
a
.
server
.
LdapGroups
{
...
...
pkg/login/ldap_test.go
View file @
9bf9bb02
...
@@ -139,6 +139,26 @@ func TestLdapAuther(t *testing.T) {
...
@@ -139,6 +139,26 @@ func TestLdapAuther(t *testing.T) {
})
})
})
})
ldapAutherScenario
(
"given org role is updated in config"
,
func
(
sc
*
scenarioContext
)
{
ldapAuther
:=
NewLdapAuthenticator
(
&
LdapServerConf
{
LdapGroups
:
[]
*
LdapGroupToOrgRole
{
{
GroupDN
:
"cn=admin"
,
OrgId
:
1
,
OrgRole
:
"Admin"
},
{
GroupDN
:
"cn=users"
,
OrgId
:
1
,
OrgRole
:
"Viewer"
},
},
})
sc
.
userOrgsQueryReturns
([]
*
m
.
UserOrgDTO
{{
OrgId
:
1
,
Role
:
m
.
ROLE_EDITOR
}})
err
:=
ldapAuther
.
syncOrgRoles
(
&
m
.
User
{},
&
ldapUserInfo
{
MemberOf
:
[]
string
{
"cn=users"
},
})
Convey
(
"Should update org role"
,
func
()
{
So
(
err
,
ShouldBeNil
)
So
(
sc
.
removeOrgUserCmd
,
ShouldBeNil
)
So
(
sc
.
updateOrgUserCmd
,
ShouldNotBeNil
)
})
})
ldapAutherScenario
(
"given multiple matching ldap groups"
,
func
(
sc
*
scenarioContext
)
{
ldapAutherScenario
(
"given multiple matching ldap groups"
,
func
(
sc
*
scenarioContext
)
{
ldapAuther
:=
NewLdapAuthenticator
(
&
LdapServerConf
{
ldapAuther
:=
NewLdapAuthenticator
(
&
LdapServerConf
{
LdapGroups
:
[]
*
LdapGroupToOrgRole
{
LdapGroups
:
[]
*
LdapGroupToOrgRole
{
...
...
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