authentik.providers.oauth2.migrations.0032_oauth2provider_grant_types
1# Generated by Django 5.2.11 on 2026-02-17 11:04 2 3import django.contrib.postgres.fields 4from django.db import migrations, models 5 6 7def migrate_default_grant_types(): 8 from authentik.providers.oauth2.models import GrantType 9 10 return [ 11 GrantType.AUTHORIZATION_CODE, 12 GrantType.HYBRID, 13 GrantType.IMPLICIT, 14 GrantType.CLIENT_CREDENTIALS, 15 GrantType.PASSWORD, 16 GrantType.DEVICE_CODE, 17 GrantType.REFRESH_TOKEN, 18 ] 19 20 21class Migration(migrations.Migration): 22 23 dependencies = [ 24 ( 25 "authentik_providers_oauth2", 26 "0031_remove_oauth2provider_backchannel_logout_uri_and_more", 27 ), 28 ] 29 30 operations = [ 31 migrations.AddField( 32 model_name="oauth2provider", 33 name="grant_types", 34 field=django.contrib.postgres.fields.ArrayField( 35 base_field=models.TextField( 36 choices=[ 37 ("authorization_code", "Authorization Code"), 38 ("implicit", "Implicit"), 39 ("hybrid", "Hybrid"), 40 ("refresh_token", "Refresh Token"), 41 ("client_credentials", "Client Credentials"), 42 ("password", "Password"), 43 ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"), 44 ] 45 ), 46 default=migrate_default_grant_types, 47 size=None, 48 ), 49 ), 50 migrations.AlterField( 51 model_name="oauth2provider", 52 name="grant_types", 53 field=django.contrib.postgres.fields.ArrayField( 54 base_field=models.TextField( 55 choices=[ 56 ("authorization_code", "Authorization Code"), 57 ("implicit", "Implicit"), 58 ("hybrid", "Hybrid"), 59 ("refresh_token", "Refresh Token"), 60 ("client_credentials", "Client Credentials"), 61 ("password", "Password"), 62 ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"), 63 ] 64 ), 65 default=list, 66 size=None, 67 ), 68 ), 69 ]
def
migrate_default_grant_types():
8def migrate_default_grant_types(): 9 from authentik.providers.oauth2.models import GrantType 10 11 return [ 12 GrantType.AUTHORIZATION_CODE, 13 GrantType.HYBRID, 14 GrantType.IMPLICIT, 15 GrantType.CLIENT_CREDENTIALS, 16 GrantType.PASSWORD, 17 GrantType.DEVICE_CODE, 18 GrantType.REFRESH_TOKEN, 19 ]
class
Migration(django.db.migrations.migration.Migration):
22class Migration(migrations.Migration): 23 24 dependencies = [ 25 ( 26 "authentik_providers_oauth2", 27 "0031_remove_oauth2provider_backchannel_logout_uri_and_more", 28 ), 29 ] 30 31 operations = [ 32 migrations.AddField( 33 model_name="oauth2provider", 34 name="grant_types", 35 field=django.contrib.postgres.fields.ArrayField( 36 base_field=models.TextField( 37 choices=[ 38 ("authorization_code", "Authorization Code"), 39 ("implicit", "Implicit"), 40 ("hybrid", "Hybrid"), 41 ("refresh_token", "Refresh Token"), 42 ("client_credentials", "Client Credentials"), 43 ("password", "Password"), 44 ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"), 45 ] 46 ), 47 default=migrate_default_grant_types, 48 size=None, 49 ), 50 ), 51 migrations.AlterField( 52 model_name="oauth2provider", 53 name="grant_types", 54 field=django.contrib.postgres.fields.ArrayField( 55 base_field=models.TextField( 56 choices=[ 57 ("authorization_code", "Authorization Code"), 58 ("implicit", "Implicit"), 59 ("hybrid", "Hybrid"), 60 ("refresh_token", "Refresh Token"), 61 ("client_credentials", "Client Credentials"), 62 ("password", "Password"), 63 ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"), 64 ] 65 ), 66 default=list, 67 size=None, 68 ), 69 ), 70 ]
The base class for all migrations.
Migration files will import this from django.db.migrations.Migration and subclass it as a class called Migration. It will have one or more of the following attributes:
- operations: A list of Operation instances, probably from django.db.migrations.operations
- dependencies: A list of tuples of (app_path, migration_name)
- run_before: A list of tuples of (app_path, migration_name)
- replaces: A list of migration_names
Note that all migrations come out of migrations and into the Loader or Graph as instances, having been initialized with their app label and name.