Skip to content
Snippets Groups Projects
Verified Commit 019d4a4c authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Jonathan Weth
Browse files

Turn get_*_scopes methods into classmethods

(cherry picked from commit 6593c34b)
parent b4db5802
No related branches found
No related tags found
1 merge request!733Prepare release 2.0rc6
......@@ -136,3 +136,19 @@ class CoreConfig(AppConfig):
if has_person(user):
# Save the associated person to pick up defaults
user.person.save()
@classmethod
def get_all_scopes(cls) -> dict[str, str]:
scopes = {
"read": "Read anything the resource owner can read",
"write": "Write anything the resource owner can write",
}
if settings.OAUTH2_PROVIDER.get("OIDC_ENABLED", False):
scopes |= {
"openid": _("OpenID Connect scope"),
"profile": _("Given name, family name, link to profile and picture if existing."),
"address": _("Full home postal address"),
"email": _("Email address"),
"phone": _("Home and mobile phone"),
}
return scopes
......@@ -214,6 +214,33 @@ class AppConfig(django.apps.AppConfig):
"""
pass
@classmethod
def get_all_scopes(cls) -> dict[str, str]:
"""Return all OAuth scopes and their descriptions for this app."""
return {}
@classmethod
def get_available_scopes(
cls,
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(cls.get_all_scopes().keys())
@classmethod
def get_default_scopes(
cls,
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):
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
......
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