Skip to content

Commit

Permalink
Make the app registration form accessible
Browse files Browse the repository at this point in the history
App registration form should be open to logged in users, to help
enable self service of app registration. Updating connections
remains superuser only.
  • Loading branch information
michaeljcollinsuk committed Jan 15, 2024
1 parent 69570b2 commit a7766e6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion controlpanel/api/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def is_app_admin(user, obj):


add_perm("api.list_app", is_authenticated)
add_perm("api.create_app", is_authenticated & is_superuser)
add_perm("api.create_app", is_authenticated)
add_perm("api.retrieve_app", is_authenticated & is_app_admin)
add_perm("api.update_app", is_authenticated & is_superuser)
add_perm("api.destroy_app", is_authenticated & is_superuser)
Expand Down Expand Up @@ -187,6 +187,8 @@ def is_self(user, other):
add_perm("api.update_ip_allowlists", is_authenticated & is_superuser)
add_perm("api.destroy_ip_allowlists", is_authenticated & is_superuser)

add_perm("api.create_connections", is_authenticated & is_superuser)


@predicate
def is_owner(user, obj):
Expand Down
2 changes: 1 addition & 1 deletion controlpanel/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class AppAuthSettingsSerializer(serializers.BaseSerializer):
"edit_link": "update-app-ip-allowlists"
},
cluster.App.AUTH0_CONNECTIONS: {
"permission_flag": "api.create_app",
"permission_flag": "api.create_connections",
"edit_link": "update-auth0-connections"
}
}
Expand Down
2 changes: 1 addition & 1 deletion controlpanel/frontend/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class UpdateAppAuth0Connections(

form_class = UpdateAppAuth0ConnectionsForm
model = App
permission_required = "api.create_app"
permission_required = "api.create_connections"
template_name = "webapp-auth0-connections-update.html"
success_url = "manage-app"

Expand Down
4 changes: 2 additions & 2 deletions tests/api/permissions/test_app_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def test_authenticated_user_has_basic_perms(client, users):
(app_detail, "app_user", status.HTTP_403_FORBIDDEN),
(app_detail, "normal_user", status.HTTP_404_NOT_FOUND),
(app_delete, "normal_user", status.HTTP_403_FORBIDDEN),
(app_create, "normal_user", status.HTTP_403_FORBIDDEN),
(app_create, "normal_user", status.HTTP_201_CREATED),
(app_update, "normal_user", status.HTTP_403_FORBIDDEN),
(app_list, "app_admin", status.HTTP_200_OK),
(app_detail, "app_admin", status.HTTP_200_OK),
(app_delete, "app_admin", status.HTTP_403_FORBIDDEN),
(app_create, "app_admin", status.HTTP_403_FORBIDDEN),
(app_create, "app_admin", status.HTTP_201_CREATED),
(app_update, "app_admin", status.HTTP_403_FORBIDDEN),
],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/views/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ def update_ip_allowlists(client, app, *args):
(update_auth0_connections, "app_admin", status.HTTP_403_FORBIDDEN),
(update_auth0_connections, "normal_user", status.HTTP_403_FORBIDDEN),
(create, "superuser", status.HTTP_200_OK),
(create, "app_admin", status.HTTP_403_FORBIDDEN),
(create, "normal_user", status.HTTP_403_FORBIDDEN),
(create, "app_admin", status.HTTP_200_OK),
(create, "normal_user", status.HTTP_200_OK),
(delete, "superuser", status.HTTP_302_FOUND),
(delete, "app_admin", status.HTTP_403_FORBIDDEN),
(delete, "normal_user", status.HTTP_403_FORBIDDEN),
Expand Down

0 comments on commit a7766e6

Please sign in to comment.