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

[OAuth] Override all oauth2_provider models

This ensures we do not fall into teh same migration rabbit hole as
with the Application model :rabbit2:
parent d731800b
No related branches found
No related tags found
1 merge request!724Resolve "OAuth Provider: Allow several/all Grant Flows"
......@@ -30,7 +30,13 @@ from django_celery_results.models import TaskResult
from dynamic_preferences.models import PerInstancePreferenceModel
from model_utils import FieldTracker
from model_utils.models import TimeStampedModel
from oauth2_provider.models import AbstractApplication
from oauth2_provider.models import (
AbstractAccessToken,
AbstractApplication,
AbstractGrant,
AbstractIDToken,
AbstractRefreshToken,
)
from phonenumber_field.modelfields import PhoneNumberField
from polymorphic.models import PolymorphicModel
from templated_email import send_templated_mail
......@@ -1110,3 +1116,27 @@ class OAuthApplication(AbstractApplication):
allowed_grants = get_site_preferences()["auth__oauth_allowed_grants"]
return bool(set(allowed_grants) & grant_types)
class OAuthGrant(AbstractGrant):
"""Placeholder for customising the Grant model."""
pass
class OAuthAccessToken(AbstractAccessToken):
"""Placeholder for customising the AccessToken model."""
pass
class OAuthIDToken(AbstractIDToken):
"""Placeholder for customising the IDToken model."""
pass
class OAuthRefreshToken(AbstractRefreshToken):
"""Placeholder for customising the RefreshToken model."""
pass
......@@ -325,6 +325,10 @@ ACCOUNT_UNIQUE_EMAIL = _settings.get("auth.login.registration.unique_email", Tru
# Configuration for OAuth2 provider
OAUTH2_PROVIDER = {"SCOPES_BACKEND_CLASS": "aleksis.core.util.auth_helpers.AppScopes"}
OAUTH2_PROVIDER_APPLICATION_MODEL = "core.OAuthApplication"
OAUTH2_PROVIDER_GRANT_MODEL = "core.OAuthGrant"
OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL = "core.OAuthAccessToken"
OAUTH2_PROVIDER_ID_TOKEN_MODEL = "core.OAuthIDToken"
OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = "core.OAuthRefreshToken"
if _settings.get("oauth2.oidc.enabled", False):
with open(_settings.get("oauth2.oidc.rsa_key", "/etc/aleksis/oidc.pem"), "r") as f:
......
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