Debian Codegraph @

allauth/idp/oidc/migrations/0001_initial.py

raw
1 import django.db.models.deletion
2 import django.utils.timezone
3 from django.conf import settings
4 from django.db import migrations, models
5
6 import allauth.idp.oidc.models
7
8
9 class Migration(migrations.Migration):
10
11 initial = True
12
13 dependencies = [
14 migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15 ]
16
17 operations = [
18 migrations.CreateModel(
19 name="Client",
20 fields=[
21 (
22 "id",
23 models.CharField(
24 default=allauth.idp.oidc.models.default_client_id,
25 max_length=100,
26 primary_key=True,
27 serialize=False,
28 verbose_name="Client ID",
29 ),
30 ),
31 ("name", models.CharField(max_length=100)),
32 (
33 "secret",
34 models.CharField(
35 default=allauth.idp.oidc.models.default_client_secret,
36 max_length=200,
37 ),
38 ),
39 (
40 "scopes",
41 models.TextField(
42 default="openid",
43 help_text="The scope(s) the client is allowed to request. Provide one value per line, e.g.: openid(ENTER)profile(ENTER)email(ENTER)",
44 ),
45 ),
46 (
47 "type",
48 models.CharField(
49 choices=[
50 ("confidential", "Confidential"),
51 ("public", "Public"),
52 ],
53 default="confidential",
54 max_length=20,
55 ),
56 ),
57 (
58 "grant_types",
59 models.TextField(
60 default="authorization_code",
61 help_text="A list of allowed grant types. Provide one value per line, e.g.: authorization_code(ENTER)client_credentials(ENTER)refresh_token(ENTER)",
62 ),
63 ),
64 (
65 "redirect_uris",
66 models.TextField(
67 blank=True,
68 default="",
69 help_text="A list of allowed redirect (callback) URLs, one per line.",
70 ),
71 ),
72 (
73 "cors_origins",
74 models.TextField(
75 blank=True,
76 default="",
77 help_text="A list of allowed origins for cross-origin requests, one per line.",
78 verbose_name="CORS allowed origins",
79 ),
80 ),
81 (
82 "response_types",
83 models.TextField(
84 default="code",
85 help_text="A list of allowed response types. Provide one value per line, e.g.: code(ENTER)id_token token(ENTER)",
86 ),
87 ),
88 (
89 "skip_consent",
90 models.BooleanField(
91 default=False,
92 help_text="Flag to allow skip the consent screen for this client",
93 ),
94 ),
95 ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
96 ("data", models.JSONField(blank=True, default=None, null=True)),
97 (
98 "owner",
99 models.ForeignKey(
100 blank=True,
101 null=True,
102 on_delete=django.db.models.deletion.CASCADE,
103 to=settings.AUTH_USER_MODEL,
104 ),
105 ),
106 ],
107 options={
108 "verbose_name": "client",
109 "verbose_name_plural": "clients",
110 },
111 ),
112 migrations.CreateModel(
113 name="Token",
114 fields=[
115 (
116 "id",
117 models.BigAutoField(
118 auto_created=True,
119 primary_key=True,
120 serialize=False,
121 verbose_name="ID",
122 ),
123 ),
124 (
125 "type",
126 models.CharField(
127 choices=[
128 ("ia", "Initial access token"),
129 ("at", "Access token"),
130 ("rt", "Refresh token"),
131 ("ac", "Authorization code"),
132 ],
133 max_length=2,
134 ),
135 ),
136 ("hash", models.CharField(max_length=255)),
137 ("data", models.JSONField(blank=True, default=None, null=True)),
138 ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
139 (
140 "expires_at",
141 models.DateTimeField(blank=True, db_index=True, null=True),
142 ),
143 ("scopes", models.TextField(default="")),
144 (
145 "client",
146 models.ForeignKey(
147 blank=True,
148 null=True,
149 on_delete=django.db.models.deletion.CASCADE,
150 to="allauth_idp_oidc.client",
151 ),
152 ),
153 (
154 "user",
155 models.ForeignKey(
156 blank=True,
157 null=True,
158 on_delete=django.db.models.deletion.CASCADE,
159 to=settings.AUTH_USER_MODEL,
160 ),
161 ),
162 ],
163 options={
164 "unique_together": {("type", "hash")},
165 },
166 ),
167 ]