From c4d9eaae2f5d2f2df8bf5dacc903c252dcd5668b Mon Sep 17 00:00:00 2001 From: mahdavi Date: Fri, 2 Sep 2022 12:12:26 +0430 Subject: [PATCH] start rewrite --- apps/gooyal_oauth2/migrations/0001_initial.py | 91 ++++++++++++++++++- requirements.txt | 6 +- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/apps/gooyal_oauth2/migrations/0001_initial.py b/apps/gooyal_oauth2/migrations/0001_initial.py index 2e7c79f..7e76893 100644 --- a/apps/gooyal_oauth2/migrations/0001_initial.py +++ b/apps/gooyal_oauth2/migrations/0001_initial.py @@ -1,9 +1,11 @@ -# Generated by Django 3.0.6 on 2020-06-08 05:26 +# Generated by Django 4.1 on 2022-08-17 19:05 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import oauth2_provider.generators +import oauth2_provider.models +import uuid class Migration(migrations.Migration): @@ -15,10 +17,24 @@ class Migration(migrations.Migration): ] dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ + migrations.CreateModel( + name='AccessToken', + fields=[ + ('id', models.BigAutoField(primary_key=True, serialize=False)), + ('token', models.CharField(max_length=255, unique=True)), + ('expires', models.DateTimeField()), + ('scope', models.TextField(blank=True)), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('detail', models.JSONField(blank=True, null=True)), + ], + options={ + 'abstract': False, + }, + ), migrations.CreateModel( name='Application', fields=[ @@ -26,17 +42,82 @@ class Migration(migrations.Migration): ('client_id', models.CharField(db_index=True, default=oauth2_provider.generators.generate_client_id, max_length=100, unique=True)), ('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated')), ('client_type', models.CharField(choices=[('confidential', 'Confidential'), ('public', 'Public')], max_length=32)), - ('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')], max_length=32)), - ('client_secret', models.CharField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, max_length=255)), + ('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials'), ('openid-hybrid', 'OpenID connect hybrid')], max_length=32)), + ('client_secret', oauth2_provider.models.ClientSecretField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, help_text='Hashed on Save. Copy it now if this is a new secret.', max_length=255)), ('name', models.CharField(blank=True, max_length=255)), ('skip_authorization', models.BooleanField(default=False)), ('created', models.DateTimeField(auto_now_add=True)), ('updated', models.DateTimeField(auto_now=True)), + ('algorithm', models.CharField(blank=True, choices=[('', 'No OIDC support'), ('RS256', 'RSA with SHA-2 256'), ('HS256', 'HMAC with SHA-2 256')], default='', max_length=5)), ('allowed_scope', models.TextField(blank=True)), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='gooyal_oauth_application', to=settings.AUTH_USER_MODEL)), ], options={ 'abstract': False, }, ), + migrations.CreateModel( + name='Grant', + fields=[ + ('id', models.BigAutoField(primary_key=True, serialize=False)), + ('code', models.CharField(max_length=255, unique=True)), + ('expires', models.DateTimeField()), + ('redirect_uri', models.TextField()), + ('scope', models.TextField(blank=True)), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('code_challenge', models.CharField(blank=True, default='', max_length=128)), + ('code_challenge_method', models.CharField(blank=True, choices=[('plain', 'plain'), ('S256', 'S256')], default='', max_length=10)), + ('nonce', models.CharField(blank=True, default='', max_length=255)), + ('claims', models.TextField(blank=True)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='IDToken', + fields=[ + ('id', models.BigAutoField(primary_key=True, serialize=False)), + ('jti', models.UUIDField(default=uuid.uuid4, editable=False, unique=True, verbose_name='JWT Token ID')), + ('expires', models.DateTimeField()), + ('scope', models.TextField(blank=True)), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='RefreshToken', + fields=[ + ('id', models.BigAutoField(primary_key=True, serialize=False)), + ('token', models.CharField(max_length=255)), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('revoked', models.DateTimeField(null=True)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Resource', + fields=[ + ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), + ('name', models.CharField(max_length=255)), + ('expires', models.DateTimeField()), + ], + ), + migrations.CreateModel( + name='Scope', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text='The name of the scope.', max_length=255, unique=True)), + ('description', models.TextField(help_text='A brief description of the scope. This text is displayed to users when authorising access for the scope.')), + ('is_default', models.BooleanField(default=False, help_text='Indicates if this scope should be included in the default scopes.')), + ('application', models.ForeignKey(blank=True, help_text='The application to which the scope belongs.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='scopes', to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)), + ('resource', models.ForeignKey(blank=True, help_text='The resource of scope.', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='scopes', to='gooyal_oauth2.resource')), + ], + ), ] diff --git a/requirements.txt b/requirements.txt index 2e8910f..0cb7911 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile requirements.in +# pip-compile # amqp==5.1.1 # via kombu @@ -20,7 +20,7 @@ certifi==2022.6.15 # via requests cffi==1.15.1 # via cryptography -charset-normalizer==2.1.0 +charset-normalizer==2.1.1 # via requests click==8.1.3 # via @@ -78,7 +78,7 @@ importlib-metadata==4.12.0 # via markdown inflection==0.5.1 # via drf-spectacular -jsonschema==4.10.0 +jsonschema==4.14.0 # via drf-spectacular jwcrypto==1.3.1 # via django-oauth-toolkit