Skip to content
Snippets Groups Projects
Verified Commit 4775332c authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[OAuth] Remove grant types from application form

parent a05667cc
No related branches found
No related tags found
1 merge request!724Resolve "OAuth Provider: Allow several/all Grant Flows"
# Generated by Django 3.2.8 on 2021-11-04 09:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0023_oauth_application_model'),
]
operations = [
migrations.AlterField(
model_name='oauthapplication',
name='authorization_grant_type',
field=models.CharField(blank=True, choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials'), ('openid-hybrid', 'OpenID connect hybrid')], max_length=32, null=True),
),
]
......@@ -1101,6 +1101,11 @@ class TaskUserAssignment(ExtensibleModel):
class OAuthApplication(AbstractApplication):
"""Modified OAuth application class that supports Grant Flows configured in preferences."""
# Override grant types to make field optional
authorization_grant_type = models.CharField(
max_length=32, choices=AbstractApplication.GRANT_TYPES, blank=True, null=True
)
def allows_grant_type(self, *grant_types: set[str]) -> bool:
allowed_grants = get_site_preferences()["auth__oauth_allowed_grants"]
......
......@@ -1080,14 +1080,7 @@ class OAuth2Update(PermissionRequiredMixin, UpdateView):
"""Return the form class for the application model."""
return modelform_factory(
OAuthApplication,
fields=(
"name",
"client_id",
"client_secret",
"client_type",
"authorization_grant_type",
"redirect_uris",
),
fields=("name", "client_id", "client_secret", "client_type", "redirect_uris",),
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment