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
7a09c4a7
authored
Sep 09, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: hash too long SAML usernames
parent
87de80d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
circle/circle/settings/test.py
+2
-0
circle/common/backends.py
+8
-6
No files found.
circle/circle/settings/test.py
View file @
7a09c4a7
...
@@ -71,3 +71,5 @@ STORE_URL = ""
...
@@ -71,3 +71,5 @@ STORE_URL = ""
# buildbot doesn't love pipeline
# buildbot doesn't love pipeline
STATICFILES_STORAGE
=
'django.contrib.staticfiles.storage.StaticFilesStorage'
STATICFILES_STORAGE
=
'django.contrib.staticfiles.storage.StaticFilesStorage'
SAML_MAIN_ATTRIBUTE_MAX_LENGTH
=
0
# doctest on SAML2 backend runs either way
circle/common/backends.py
View file @
7a09c4a7
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
import
re
import
re
import
logging
import
logging
import
sha
from
django.conf
import
settings
from
django.conf
import
settings
from
djangosaml2.backends
import
Saml2Backend
as
Saml2BackendBase
from
djangosaml2.backends
import
Saml2Backend
as
Saml2BackendBase
...
@@ -48,14 +49,15 @@ class Saml2Backend(Saml2BackendBase):
...
@@ -48,14 +49,15 @@ class Saml2Backend(Saml2BackendBase):
attr
=
re
.
sub
(
r'[^\w.@-]'
,
replace
,
main_attribute
)
attr
=
re
.
sub
(
r'[^\w.@-]'
,
replace
,
main_attribute
)
max_length
=
settings
.
SAML_MAIN_ATTRIBUTE_MAX_LENGTH
max_length
=
settings
.
SAML_MAIN_ATTRIBUTE_MAX_LENGTH
if
max_length
>
0
and
len
(
attr
)
>
max_length
:
if
max_length
>
0
and
len
(
attr
)
>
max_length
:
logger
.
info
(
"Trimming main attribute:
%
s"
%
attr
)
logger
.
info
(
"Main attribute '
%
s' is too long."
%
attr
)
hashed
=
sha
.
new
(
attr
)
.
hexdigest
()
if
"@"
in
attr
:
if
"@"
in
attr
:
parts
=
attr
.
split
(
"@"
)
domain
=
attr
.
rsplit
(
"@"
,
1
)[
1
]
attr
=
"
%
s@
%
s"
%
(
parts
[
0
][:
max_length
-
1
-
len
(
parts
[
1
]
)],
attr
=
"
%
s@
%
s"
%
(
hashed
[:
max_length
-
1
-
len
(
domain
)],
parts
[
1
]
)
domain
)
else
:
else
:
attr
=
attr
[:
max_length
]
attr
=
hashed
[:
max_length
]
logger
.
info
(
"
Trimmed
main attribute:
%
s"
%
attr
)
logger
.
info
(
"
New
main attribute:
%
s"
%
attr
)
return
attr
return
attr
def
_set_attribute
(
self
,
obj
,
attr
,
value
):
def
_set_attribute
(
self
,
obj
,
attr
,
value
):
...
...
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