Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
939fed1d
authored
Feb 16, 2017
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: Add ldap support for GroupCodeMixin
parent
35ae5cdc
Pipeline
#374
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
circle/dashboard/views/group.py
+22
-2
circle/dashboard/views/util.py
+2
-1
No files found.
circle/dashboard/views/group.py
View file @
939fed1d
...
@@ -41,8 +41,11 @@ from ..forms import (
...
@@ -41,8 +41,11 @@ from ..forms import (
from
..models
import
FutureMember
,
GroupProfile
from
..models
import
FutureMember
,
GroupProfile
from
vm.models
import
Instance
,
InstanceTemplate
from
vm.models
import
Instance
,
InstanceTemplate
from
..tables
import
GroupListTable
from
..tables
import
GroupListTable
from
.util
import
(
CheckedDetailView
,
AclUpdateView
,
search_user
,
from
.util
import
(
saml_available
,
DeleteViewBase
,
external_auth_available
)
CheckedDetailView
,
AclUpdateView
,
search_user
,
saml_available
,
DeleteViewBase
,
external_auth_available
,
ldap_available
)
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -78,6 +81,23 @@ class GroupCodeMixin(object):
...
@@ -78,6 +81,23 @@ class GroupCodeMixin(object):
except
Group
.
DoesNotExist
:
except
Group
.
DoesNotExist
:
newgroups
.
append
(
group
)
newgroups
.
append
(
group
)
if
ldap_available
:
ldap_user
=
getattr
(
request
.
user
,
"ldap_user"
,
None
)
if
ldap_user
is
None
:
return
newgroups
from
..ldap_utils
import
owns
,
ldap_connect
user_dn
=
ldap_user
.
dn
.
upper
()
group_dns
=
map
(
unicode
.
upper
,
ldap_user
.
group_dns
)
# connection will close, when object destroys
# https://www.python-ldap.org/doc/html/ldap.html#ldap-objects
conn
=
ldap_connect
()
for
group
in
group_dns
:
try
:
GroupProfile
.
search
(
group
)
except
Group
.
DoesNotExist
:
if
owns
(
conn
,
user_dn
,
group
):
newgroups
.
append
(
group
)
return
newgroups
return
newgroups
...
...
circle/dashboard/views/util.py
View file @
939fed1d
...
@@ -58,10 +58,11 @@ from ..forms import TransferOwnershipForm
...
@@ -58,10 +58,11 @@ from ..forms import TransferOwnershipForm
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
ldap_available
=
hasattr
(
settings
,
"AUTH_LDAP_SERVER_URI"
)
def
external_auth_available
():
def
external_auth_available
():
return
saml_available
or
hasattr
(
settings
,
"AUTH_LDAP_SERVER_URI"
)
return
saml_available
or
ldap_available
class
RedirectToLoginMixin
(
AccessMixin
):
class
RedirectToLoginMixin
(
AccessMixin
):
...
...
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