2022-06-05 19:45:42 +00:00
|
|
|
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.utils.crypto import get_random_string
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
|
|
|
|
|
|
|
|
class OauthIntegration(models.Model):
|
|
|
|
owned_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
|
|
name_text = models.CharField("name of the application", max_length=100)
|
|
|
|
client_id_uuid = models.UUIDField(
|
|
|
|
"client UUID", default=uuid.uuid4, editable=False, unique=True, primary_key=True
|
|
|
|
)
|
|
|
|
client_secret_text = models.CharField(
|
|
|
|
"client secret",
|
|
|
|
unique=True,
|
|
|
|
max_length=32,
|
|
|
|
default=get_random_string(32),
|
|
|
|
blank=True,
|
|
|
|
editable=False,
|
|
|
|
)
|
|
|
|
privacy_policy_uri = models.URLField(
|
2022-06-05 22:48:31 +00:00
|
|
|
"privacy policy of the application", default=None, blank=True, null=True
|
2022-06-05 19:45:42 +00:00
|
|
|
)
|
|
|
|
redirect_uri = models.URLField("uri where user is to be redirected", unique=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.name_text}: {self.client_id_uuid}"
|