2022-12-10 20:03:14 -08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Token(models.Model):
|
|
|
|
"""
|
|
|
|
An (access) token to call the API with.
|
|
|
|
|
|
|
|
Can be either tied to a user, or app-level only.
|
|
|
|
"""
|
|
|
|
|
|
|
|
application = models.ForeignKey(
|
|
|
|
"api.Application",
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name="tokens",
|
|
|
|
)
|
|
|
|
|
|
|
|
user = models.ForeignKey(
|
|
|
|
"users.User",
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name="tokens",
|
|
|
|
)
|
|
|
|
|
|
|
|
identity = models.ForeignKey(
|
|
|
|
"users.Identity",
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
related_name="tokens",
|
|
|
|
)
|
|
|
|
|
2023-01-01 10:46:55 -08:00
|
|
|
token = models.CharField(max_length=500, unique=True)
|
2022-12-10 20:03:14 -08:00
|
|
|
scopes = models.JSONField()
|
|
|
|
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
updated = models.DateTimeField(auto_now=True)
|
2023-01-01 10:46:55 -08:00
|
|
|
revoked = models.DateTimeField(blank=True, null=True)
|