Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9ba74dd1
authored
Feb 05, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: create user profile on saml logon
Closes #42
parent
6d5b7363
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
circle/circle/settings/base.py
+4
-0
circle/dashboard/models.py
+15
-0
No files found.
circle/circle/settings/base.py
View file @
9ba74dd1
...
@@ -382,3 +382,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
...
@@ -382,3 +382,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'DJANGO_SAML_ATTRIBUTE_MAPPING'
,
'DJANGO_SAML_ATTRIBUTE_MAPPING'
,
'{"mail": ["email"], "sn": ["last_name"], '
'{"mail": ["email"], "sn": ["last_name"], '
'"uid": ["username"], "cn": ["first_name"]}'
))
'"uid": ["username"], "cn": ["first_name"]}'
))
SAML_CREATE_UNKNOWN_USER
=
True
if
get_env_variable
(
'DJANGO_SAML_ORG_ID_ATTRIBUTE'
,
None
)
is
not
None
:
SAML_ORG_ID_ATTRIBUTE
=
get_env_variable
(
'DJANGO_SAML_ORG_ID_ATTRIBUTE'
)
circle/dashboard/models.py
View file @
9ba74dd1
...
@@ -20,3 +20,18 @@ class Profile(Model):
...
@@ -20,3 +20,18 @@ class Profile(Model):
org_id
=
CharField
(
# may be populated from eduPersonOrgId field
org_id
=
CharField
(
# may be populated from eduPersonOrgId field
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
if
hasattr
(
settings
,
'SAML_ORG_ID_ATTRIBUTE'
):
from
djangosaml2.signals
import
pre_user_save
def
save_org_id
(
sender
,
attributes
,
user_modified
):
atr
=
settings
.
SAML_ORG_ID_ATTRIBUTE
value
=
attributes
[
atr
]
profile
,
created
=
Profile
.
objects
.
get_or_create
(
user
=
sender
)
if
created
or
profile
.
org_id
!=
value
:
profile
.
org_id
=
value
profile
.
save
()
return
False
pre_user_save
.
connect
(
save_org_id
,
weak
=
False
)
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