Skip to content
Snippets Groups Projects

Resolve "Allow apps to register OAuth scopes"

Merged Nik | Klampfradler requested to merge 495-allow-apps-to-register-oauth-scopes into master
All threads resolved!
5 files
+ 103
8
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 28
1
from importlib import metadata
from importlib import metadata
from typing import Any, Optional, Sequence
from typing import TYPE_CHECKING, Any, Optional, Sequence
import django.apps
import django.apps
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.contrib.auth.signals import user_logged_in, user_logged_out
@@ -12,6 +12,9 @@ from spdx_license_list import LICENSES
@@ -12,6 +12,9 @@ from spdx_license_list import LICENSES
from .core_helpers import copyright_years
from .core_helpers import copyright_years
 
if TYPE_CHECKING:
 
from oauth2_provider.models import AbstractApplication
 
class AppConfig(django.apps.AppConfig):
class AppConfig(django.apps.AppConfig):
"""An extended version of DJango's AppConfig container."""
"""An extended version of DJango's AppConfig container."""
@@ -214,6 +217,30 @@ class AppConfig(django.apps.AppConfig):
@@ -214,6 +217,30 @@ class AppConfig(django.apps.AppConfig):
"""
"""
pass
pass
 
def get_all_scopes(self) -> dict[str, str]:
 
"""Return all OAuth scopes and their descriptions for this app."""
 
return {}
 
 
def get_available_scopes(
 
self,
 
application: Optional["AbstractApplication"] = None,
 
request: Optional[HttpRequest] = None,
 
*args,
 
**kwargs,
 
) -> list[str]:
 
"""Return a list of all OAuth scopes available to the request and application."""
 
return list(self.get_all_scopes().keys())
 
 
def get_default_scopes(
 
self,
 
application: Optional["AbstractApplication"] = None,
 
request: Optional[HttpRequest] = None,
 
*args,
 
**kwargs,
 
) -> list[str]:
 
"""Return a list of all OAuth scopes to always include for this request and application."""
 
return []
 
def _maintain_default_data(self):
def _maintain_default_data(self):
from django.contrib.auth.models import Permission
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.models import ContentType
Loading