Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
5ff806b4
Verified
Commit
5ff806b4
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
[OAuth] Make AppScopes schoices lazy to work around circular import
parent
802665a7
No related branches found
Branches containing commit
No related tags found
1 merge request
!759
Resolve "[OAuth] Allow limiting scopes per application"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/models.py
+7
-3
7 additions, 3 deletions
aleksis/core/models.py
with
7 additions
and
3 deletions
aleksis/core/models.py
+
7
−
3
View file @
5ff806b4
...
...
@@ -20,7 +20,7 @@ from django.dispatch import receiver
from
django.forms.widgets
import
Media
from
django.urls
import
reverse
from
django.utils
import
timezone
from
django.utils.functional
import
classproperty
from
django.utils.functional
import
classproperty
,
lazy
from
django.utils.text
import
slugify
from
django.utils.translation
import
gettext_lazy
as
_
...
...
@@ -59,7 +59,6 @@ from .mixins import (
SchoolTermRelatedExtensibleModel
,
)
from
.tasks
import
send_notification
from
.util.auth_helpers
import
AppScopes
from
.util.core_helpers
import
get_site_preferences
,
now_tomorrow
from
.util.model_helpers
import
ICONS
...
...
@@ -1106,6 +1105,11 @@ class TaskUserAssignment(ExtensibleModel):
verbose_name_plural
=
_
(
"
Task user assignments
"
)
def
get_scopes_choices
():
from
.util.auth_helpers
import
AppScopes
return
list
(
AppScopes
().
get_all_scopes
().
items
())
get_scopes_choices_lazy
=
lazy
(
get_scopes_choices
,
list
)
class
OAuthApplication
(
AbstractApplication
):
"""
Modified OAuth application class that supports Grant Flows configured in preferences.
"""
...
...
@@ -1116,7 +1120,7 @@ class OAuthApplication(AbstractApplication):
# Optional list of alloewd scopes
allowed_scopes
=
ArrayField
(
models
.
CharField
(
max_length
=
32
,
choices
=
list
(
AppScopes
().
get_all_scopes
().
items
()
))
models
.
CharField
(
max_length
=
32
,
choices
=
get_scopes_choices_lazy
(
))
)
def
allows_grant_type
(
self
,
*
grant_types
:
set
[
str
])
->
bool
:
...
...
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