Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ssoauth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
django
ssoauth
Commits
546ca0ea
Commit
546ca0ea
authored
7 years ago
by
Art
Browse files
Options
Downloads
Patches
Plain Diff
Make Tim and Dennis more happy. Make Art less happy.
Also allow direct user permissions.
parent
5a93970f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ssoauth/auth_utils.py
+7
-4
7 additions, 4 deletions
ssoauth/auth_utils.py
ssoauth/checks.py
+0
-14
0 additions, 14 deletions
ssoauth/checks.py
ssoauth/views.py
+1
-0
1 addition, 0 deletions
ssoauth/views.py
with
8 additions
and
18 deletions
ssoauth/auth_utils.py
+
7
−
4
View file @
546ca0ea
...
...
@@ -83,10 +83,7 @@ def get_or_create_user(uuid, username):
if
not
user
:
user
=
create_user
(
uuid
,
username
)
# create if not present
# sanity check
if
user
and
user
.
user_permissions
.
all
().
count
():
logger
.
error
(
"
Who assigned permissions directly to user {user}?! Removing: {perms}
"
.
format
(
user
=
user
,
perms
=
"
,
"
.
join
(
str
(
p
)
for
p
in
user
.
user_permissions
)))
user
.
user_permissions
.
clear
()
cleanup_direct_permissions
(
user
)
return
user
...
...
@@ -124,6 +121,12 @@ def set_user_groups(user, group_dn_list):
user
=
user
,
g_n
=
len
(
groups
),
g_names
=
"
,
"
.
join
(
str
(
g
)
for
g
in
groups
),
dn_n
=
len
(
group_dn_list
)))
def
cleanup_direct_permissions
(
user
):
if
user
.
user_permissions
.
exists
():
logger
.
critical
(
"
Who attached permissions directly to {user} ?!?!
"
.
format
(
**
locals
()))
user
.
user_permissions
.
clear
()
def
set_user_compat_flags
(
user
):
is_active
=
True
user
.
is_staff
=
False
...
...
This diff is collapsed.
Click to expand it.
ssoauth/checks.py
+
0
−
14
View file @
546ca0ea
...
...
@@ -49,20 +49,6 @@ def compatible_user_model(app_configs, **kwargs):
return
errors
@register
(
Tags
.
security
)
@_ignore_db_errors
def
no_direct_user_permissions
(
app_configs
,
**
kwargs
):
errors
=
list
()
qs_bad_users
=
get_user_model
().
objects
.
filter
(
user_permissions__isnull
=
False
)
if
qs_bad_users
.
count
()
is
not
0
:
errors
.
append
(
Error
(
"
Detected directly assigned permissions. Truncate the User<->Permission table. Investigate the reason.
"
+
"
Bad users: {0}
"
.
format
(
"
,
"
.
join
(
u
.
username
for
u
in
qs_bad_users
)),
obj
=
get_user_model
(),
))
return
errors
@register
(
Tags
.
urls
)
def
auth_urls_configured
(
app_configs
,
**
kwargs
):
errors
=
list
()
...
...
This diff is collapsed.
Click to expand it.
ssoauth/views.py
+
1
−
0
View file @
546ca0ea
...
...
@@ -118,6 +118,7 @@ class ACSAuthNView(SAMLMixin, View):
user
=
user
,
group_dn_list
=
get_attr
(
"
idm_groups
"
,
nullable
=
True
,
multivalued
=
True
)
or
list
()
)
auth_utils
.
cleanup_direct_permissions
(
user
=
user
)
auth_utils
.
set_user_compat_flags
(
user
=
user
)
request
.
user
=
user
contrib_auth
.
login
(
request
,
user
)
...
...
This diff is collapsed.
Click to expand it.
Tim Fechner
@fechnert
·
7 years ago
I'm sorry for this
I'm sorry for this
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment