Skip to content
Snippets Groups Projects
Verified Commit 5ff806b4 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[OAuth] Make AppScopes schoices lazy to work around circular import

parent 802665a7
No related branches found
No related tags found
1 merge request!759Resolve "[OAuth] Allow limiting scopes per application"
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment