feat: def models for oauth integrations
parent
9c5f4d2a92
commit
3f02c4f03b
|
@ -0,0 +1,19 @@
|
|||
# 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/>.
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import OauthIntegration
|
||||
|
||||
admin.site.register(OauthIntegration)
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class IntegrationsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "oauth.integrations"
|
|
@ -0,0 +1,70 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-05 19:37
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="OauthIntegration",
|
||||
fields=[
|
||||
(
|
||||
"name_text",
|
||||
models.CharField(
|
||||
max_length=100, verbose_name="name of the application"
|
||||
),
|
||||
),
|
||||
(
|
||||
"client_id_uuid",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="client UUID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"client_secret_text",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default="7CM6lfbQ0j1NuWdYhd8HRLMkeWywQUtX",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
(
|
||||
"privacy_policy_uri",
|
||||
models.URLField(
|
||||
default=None, verbose_name="privacy policy of the application"
|
||||
),
|
||||
),
|
||||
(
|
||||
"redirect_uri",
|
||||
models.URLField(
|
||||
unique=True, verbose_name="uri where user is to be redirected"
|
||||
),
|
||||
),
|
||||
(
|
||||
"owned_by",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-05 19:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="9HBaBiYERc1ogWvwHGWAb9lUKKco8brN",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-05 19:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0002_alter_oauthintegration_client_secret_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="xTHXiGYQ0yn1f3SbDOy8wh7YolrsySnu",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="privacy_policy_uri",
|
||||
field=models.URLField(
|
||||
blank=True,
|
||||
default=None,
|
||||
verbose_name="privacy policy of the application",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-05 19:42
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0003_alter_oauthintegration_client_secret_text_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="bUqiljhkmFh845B68APhXDoV9ui9iQwS",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-05 19:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0004_alter_oauthintegration_client_secret_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="B4siYj3YEZjyF94IfLihJPHNuYOJWds6",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,45 @@
|
|||
# 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(
|
||||
"privacy policy of the application", default=None, blank=True
|
||||
)
|
||||
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}"
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,20 @@
|
|||
# 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/>.
|
||||
|
||||
from django.urls import path, include
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [path("", views.index, name="index")]
|
|
@ -0,0 +1,23 @@
|
|||
# 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/>.
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.contrib.auth import authenticate
|
||||
|
||||
# Create your views here.
|
||||
def index(request):
|
||||
return HttpResponse("Integrations bar")
|
Loading…
Reference in New Issue