forked from ansible/django-ansible-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doing this properly with RBAC depends on ansible#424. For now, we limit Application views to superusers. We limit Token views using a custom DRF permission class based on what was specified in AWX's access.py Signed-off-by: Rick Elrod <[email protected]>
- Loading branch information
Showing
6 changed files
with
466 additions
and
10 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
ansible_base/oauth2_provider/migrations/0004_alter_oauth2accesstoken_scope.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.11 on 2024-06-04 12:32 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dab_oauth2_provider', '0003_remove_oauth2application_logo_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='oauth2accesstoken', | ||
name='scope', | ||
field=models.CharField(blank=True, default='write', help_text="Allowed scopes, further restricts user's permissions. Must be a simple space-separated string with allowed scopes ['read', 'write'].", max_length=32), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
from rest_framework import permissions | ||
from rest_framework.viewsets import ModelViewSet | ||
|
||
from ansible_base.lib.utils.views.django_app_api import AnsibleBaseDjangoAppApiView | ||
from ansible_base.lib.utils.views.permissions import IsSuperuser | ||
from ansible_base.oauth2_provider.models import OAuth2Application | ||
from ansible_base.oauth2_provider.serializers import OAuth2ApplicationSerializer | ||
|
||
|
||
class OAuth2ApplicationViewSet(AnsibleBaseDjangoAppApiView, ModelViewSet): | ||
queryset = OAuth2Application.objects.all() | ||
serializer_class = OAuth2ApplicationSerializer | ||
permission_classes = [permissions.IsAuthenticated] | ||
permission_classes = [IsSuperuser] | ||
|
||
def filter_queryset(self, queryset): | ||
return super().filter_queryset(OAuth2Application.access_qs(self.request.user, queryset=queryset)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.