Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Public contract registry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Public contract registry
Commits
73a0ba3b
Commit
73a0ba3b
authored
1 year ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
groups debug
parent
610ef157
No related branches found
No related tags found
1 merge request
!4
Release
Pipeline
#12673
passed
1 year ago
Stage: build
Stage: test_deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
oidc/auth.py
+4
-0
4 additions, 0 deletions
oidc/auth.py
registry/templates/admin/index.html
+14
-0
14 additions, 0 deletions
registry/templates/admin/index.html
users/models.py
+26
-0
26 additions, 0 deletions
users/models.py
with
44 additions
and
0 deletions
oidc/auth.py
+
4
−
0
View file @
73a0ba3b
...
@@ -62,6 +62,10 @@ class RegistryOIDCAuthenticationBackend(PiratesOIDCAuthenticationBackend):
...
@@ -62,6 +62,10 @@ class RegistryOIDCAuthenticationBackend(PiratesOIDCAuthenticationBackend):
user
,
decoded_access_token
,
user_groups
=
user_groups
user
,
decoded_access_token
,
user_groups
=
user_groups
)
)
from
django_http_exceptions
import
HTTPExceptions
import
json
raise
HTTPExceptions
.
FORBIDDEN
.
with_content
(
json
.
dumps
(
decoded_access_token
))
user
.
update_group_based_admin
()
user
.
update_group_based_admin
()
user
.
save
(
saved_by_auth
=
True
)
user
.
save
(
saved_by_auth
=
True
)
...
...
This diff is collapsed.
Click to expand it.
registry/templates/admin/index.html
+
14
−
0
View file @
73a0ba3b
...
@@ -29,3 +29,17 @@
...
@@ -29,3 +29,17 @@
{{ block.super }}
{{ block.super }}
{% endblock %}
{% endblock %}
{% block sidebar %}
{{ block.super }}
<h2>
Tvá oprávnění
</h2>
<ul>
{% for permission in request.user.get_all_permissions_ordered %}
<li>
{{ permission }}
</li>
{% endfor %}
</ul>
{% endblock %}
This diff is collapsed.
Click to expand it.
users/models.py
+
26
−
0
View file @
73a0ba3b
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
as
AuthGroup
from
django.contrib.auth.models
import
Group
as
AuthGroup
from
django.contrib.auth.models
import
Permission
from
django.db
import
models
from
django.db
import
models
from
pirates
import
models
as
pirates_models
from
pirates
import
models
as
pirates_models
...
@@ -86,6 +87,31 @@ class User(pirates_models.AbstractUser):
...
@@ -86,6 +87,31 @@ class User(pirates_models.AbstractUser):
return
f
"
{
first_name
}{
self
.
last_name
}
"
return
f
"
{
first_name
}{
self
.
last_name
}
"
def
get_all_permissions_ordered
(
self
,
obj
=
None
)
->
list
:
#permissions_set = self.get_all_permissions(obj)
#print(permissions_set)
permissions
=
(
Permission
.
objects
.
filter
(
models
.
Q
(
group__in
=
self
.
groups
.
all
())
|
models
.
Q
(
user
=
self
)
).
distinct
().
all
()
#Permission.
#objects.
#filter(codename__in=permissions_set).
#order_by("name").
#all()
)
print
(
permissions
)
return
permissions
def
save
(
self
,
*
args
,
saved_by_auth
:
bool
=
False
,
**
kwargs
):
def
save
(
self
,
*
args
,
saved_by_auth
:
bool
=
False
,
**
kwargs
):
if
(
if
(
not
self
.
_state
.
adding
not
self
.
_state
.
adding
...
...
This diff is collapsed.
Click to expand it.
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