jumpserver/apps/authentication/models/sso_token.py

21 lines
808 B
Python
Raw Normal View History

import uuid
from django.db import models
2023-07-24 03:52:25 +00:00
from django.utils.translation import gettext_lazy as _
2022-12-05 10:54:12 +00:00
from common.db.models import BaseCreateUpdateModel, CASCADE_SIGNAL_SKIP
class SSOToken(BaseCreateUpdateModel):
"""
类似腾讯企业邮的 [单点登录](https://exmail.qq.com/qy_mng_logic/doc#10036)
出于安全考虑这里的 `token` 使用一次随即过期但我们保留每一个生成过的 `token`
"""
authkey = models.UUIDField(primary_key=True, default=uuid.uuid4, verbose_name=_('Token'))
expired = models.BooleanField(default=False, verbose_name=_('Expired'))
2022-12-05 10:54:12 +00:00
user = models.ForeignKey('users.User', on_delete=CASCADE_SIGNAL_SKIP, verbose_name=_('User'),
db_constraint=False)
class Meta:
verbose_name = _('SSO token')