-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodels.py
49 lines (37 loc) · 1.32 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from django.db import models
from oauth2_provider.models import (
AbstractAccessToken,
AbstractApplication,
AbstractGrant,
AbstractRefreshToken,
)
from oauth2_provider.settings import oauth2_settings
class BaseTestApplication(AbstractApplication):
allowed_schemes = models.TextField(blank=True)
def get_allowed_schemes(self):
if self.allowed_schemes:
return self.allowed_schemes.split()
return super().get_allowed_schemes()
class SampleApplication(AbstractApplication):
custom_field = models.CharField(max_length=255)
class SampleAccessToken(AbstractAccessToken):
custom_field = models.CharField(max_length=255)
source_refresh_token = models.OneToOneField(
# unique=True implied by the OneToOneField
oauth2_settings.REFRESH_TOKEN_MODEL,
on_delete=models.SET_NULL,
blank=True,
null=True,
related_name="s_refreshed_access_token",
)
class SampleRefreshToken(AbstractRefreshToken):
custom_field = models.CharField(max_length=255)
access_token = models.OneToOneField(
oauth2_settings.ACCESS_TOKEN_MODEL,
on_delete=models.SET_NULL,
blank=True,
null=True,
related_name="s_refresh_token",
)
class SampleGrant(AbstractGrant):
custom_field = models.CharField(max_length=255)