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
87de80d5
authored
Sep 09, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: trim long usernames from SAML
parent
54c501cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
+18
-1
circle/circle/settings/base.py
+2
-0
circle/common/backends.py
+16
-1
No files found.
circle/circle/settings/base.py
View file @
87de80d5
...
...
@@ -505,6 +505,8 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
if
get_env_variable
(
'DJANGO_SAML_ORG_ID_ATTRIBUTE'
,
False
)
is
not
False
:
SAML_ORG_ID_ATTRIBUTE
=
get_env_variable
(
'DJANGO_SAML_ORG_ID_ATTRIBUTE'
)
SAML_MAIN_ATTRIBUTE_MAX_LENGTH
=
int
(
get_env_variable
(
"DJANGO_SAML_MAIN_ATTRIBUTE_MAX_LENGTH"
,
0
))
LOGIN_REDIRECT_URL
=
"/"
...
...
circle/common/backends.py
View file @
87de80d5
...
...
@@ -17,9 +17,13 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
import
re
import
logging
from
django.conf
import
settings
from
djangosaml2.backends
import
Saml2Backend
as
Saml2BackendBase
logger
=
logging
.
getLogger
(
__name__
)
class
Saml2Backend
(
Saml2BackendBase
):
u"""
...
...
@@ -41,7 +45,18 @@ class Saml2Backend(Saml2BackendBase):
if
isinstance
(
main_attribute
,
str
):
main_attribute
=
main_attribute
.
decode
(
'UTF-8'
)
assert
isinstance
(
main_attribute
,
unicode
)
return
re
.
sub
(
r'[^\w.@-]'
,
replace
,
main_attribute
)
attr
=
re
.
sub
(
r'[^\w.@-]'
,
replace
,
main_attribute
)
max_length
=
settings
.
SAML_MAIN_ATTRIBUTE_MAX_LENGTH
if
max_length
>
0
and
len
(
attr
)
>
max_length
:
logger
.
info
(
"Trimming main attribute:
%
s"
%
attr
)
if
"@"
in
attr
:
parts
=
attr
.
split
(
"@"
)
attr
=
"
%
s@
%
s"
%
(
parts
[
0
][:
max_length
-
1
-
len
(
parts
[
1
])],
parts
[
1
])
else
:
attr
=
attr
[:
max_length
]
logger
.
info
(
"Trimmed main attribute:
%
s"
%
attr
)
return
attr
def
_set_attribute
(
self
,
obj
,
attr
,
value
):
if
attr
==
'username'
:
...
...
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