forked from Hostea/dashboard
feat: def util fn gen_secret and port models
parent
ce56bfd91f
commit
8c272baff4
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0009_alter_oauthintegration_client_secret_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="PIwNX3xbeo12bycsY9PNfNv5Lf7fKKH9",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0010_alter_oauthintegration_client_secret_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="IIrQcB1pSUVn0bp4Vjfk5oFWbYrcRhyC",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import oauth.integrations.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("integrations", "0011_alter_oauthintegration_client_secret_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="oauthintegration",
|
||||
name="client_secret_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default=oauth.integrations.utils.gen_secret,
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="client secret",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -19,6 +19,8 @@ from django.db import models
|
|||
from django.contrib.auth.models import User
|
||||
from django.utils.crypto import get_random_string
|
||||
|
||||
from .utils import gen_secret
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
|
@ -32,7 +34,7 @@ class OauthIntegration(models.Model):
|
|||
"client secret",
|
||||
unique=True,
|
||||
max_length=32,
|
||||
default=get_random_string(32),
|
||||
default=gen_secret,
|
||||
blank=True,
|
||||
editable=False,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# 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.utils.crypto import get_random_string
|
||||
|
||||
|
||||
def gen_secret() -> str:
|
||||
"""
|
||||
Generate random secret
|
||||
"""
|
||||
return get_random_string(32)
|
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("oauth", "0009_alter_authorizationgrant_code_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="authorizationgrant",
|
||||
name="code_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="ux3IcNewIwTqAETA21WzcYjifZtEYIo2",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="Authorization Code",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("oauth", "0010_alter_authorizationgrant_code_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="authorizationgrant",
|
||||
name="code_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default="oUNYnC8RnLlEebpt0QcEQvcgSGVctJ7U",
|
||||
editable=False,
|
||||
max_length=32,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="Authorization Code",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 4.0.3 on 2022-06-06 04:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import oauth.integrations.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("oauth", "0011_alter_authorizationgrant_code_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="authorizationgrant",
|
||||
name="code_text",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
default=oauth.integrations.utils.gen_secret,
|
||||
editable=False,
|
||||
max_length=32,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="Authorization Code",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -17,6 +17,7 @@ from django.db import models
|
|||
from django.utils.crypto import get_random_string
|
||||
|
||||
from .integrations.models import OauthIntegration
|
||||
from .integrations.utils import gen_secret
|
||||
|
||||
|
||||
class AuthorizationGrant(models.Model):
|
||||
|
@ -26,7 +27,7 @@ class AuthorizationGrant(models.Model):
|
|||
primary_key=True,
|
||||
unique=True,
|
||||
max_length=32,
|
||||
default=get_random_string(32),
|
||||
default=gen_secret,
|
||||
blank=True,
|
||||
editable=False,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue