Changeset View
Changeset View
Standalone View
Standalone View
swh/web/auth/models.py
# Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from django.db import models | from django.db import models | ||||
from swh.auth.django.models import OIDCUser as OIDCUserBase | |||||
class OIDCUser(OIDCUserBase): | |||||
""" | |||||
Custom User proxy model for remote users storing OpenID Connect | |||||
related data: profile containing authentication tokens. | |||||
The model is also not saved to database as all users are already stored | |||||
in the Keycloak one. | |||||
""" | |||||
class Meta: | |||||
app_label = "swh_web_auth" | |||||
proxy = True | |||||
auto_created = True # prevent model to be created in database by migrations | |||||
class OIDCUserOfflineTokens(models.Model): | class OIDCUserOfflineTokens(models.Model): | ||||
""" | """ | ||||
Model storing encrypted bearer tokens generated by users. | Model storing encrypted bearer tokens generated by users. | ||||
""" | """ | ||||
user_id = models.CharField(max_length=50) | user_id = models.CharField(max_length=50) | ||||
creation_date = models.DateTimeField(auto_now_add=True) | creation_date = models.DateTimeField(auto_now_add=True) | ||||
offline_token = models.BinaryField() | offline_token = models.BinaryField() | ||||
class Meta: | class Meta: | ||||
app_label = "swh_web_auth" | app_label = "swh_web_auth" | ||||
db_table = "oidc_user_offline_tokens" | db_table = "oidc_user_offline_tokens" |