Browse Source

fix(hybridcloud) Add missing function view annotations (#63812)

Add silo annotation to view functions. When we updated tests for these
views we didn't yet have `control_silo_function` and now we do.
Mark Story 1 year ago
parent
commit
7fb0edf048

+ 7 - 0
src/sentry/web/frontend/accounts.py

@@ -19,6 +19,7 @@ from sentry.security.utils import capture_security_activity
 from sentry.services.hybrid_cloud.lost_password_hash import lost_password_hash_service
 from sentry.services.hybrid_cloud.organization import organization_service
 from sentry.services.hybrid_cloud.user.service import user_service
+from sentry.services.hybrid_cloud.util import control_silo_function
 from sentry.signals import email_verified, terms_accepted
 from sentry.utils import auth
 from sentry.web.decorators import login_required, set_referrer_policy
@@ -42,11 +43,13 @@ def get_template(mode, name):
 
 
 @login_required
+@control_silo_function
 def login_redirect(request):
     login_url = auth.get_login_redirect(request)
     return HttpResponseRedirect(login_url)
 
 
+@control_silo_function
 def expired(request, user):
     hash = lost_password_hash_service.get_or_create(user_id=user.id).hash
     LostPasswordHash.send_recover_password_email(user, hash, request.META["REMOTE_ADDR"])
@@ -55,6 +58,7 @@ def expired(request, user):
     return render_to_response(get_template("recover", "expired"), context, request)
 
 
+@control_silo_function
 def recover(request):
     from sentry import ratelimits as ratelimiter
 
@@ -107,6 +111,7 @@ def recover(request):
 
 
 @set_referrer_policy("strict-origin-when-cross-origin")
+@control_silo_function
 def recover_confirm(request, user_id, hash, mode="recover"):
     try:
         password_hash = LostPasswordHash.objects.get(user=user_id, hash=hash)
@@ -188,6 +193,7 @@ relocate_confirm = update_wrapper(relocate_confirm, recover)
 
 @login_required
 @require_http_methods(["POST"])
+@control_silo_function
 def start_confirm_email(request):
     from sentry import ratelimits as ratelimiter
 
@@ -235,6 +241,7 @@ def start_confirm_email(request):
 
 
 @set_referrer_policy("strict-origin-when-cross-origin")
+@control_silo_function
 def confirm_email(request, user_id, hash):
     msg = _("Thanks for confirming your email")
     level = messages.SUCCESS

+ 2 - 0
src/sentry/web/frontend/sudo.py

@@ -6,9 +6,11 @@ from django.http.request import HttpRequest
 
 from sentry.models.authenticator import Authenticator
 from sentry.utils import json
+from sentry.web.frontend.base import control_silo_view
 from sudo.views import SudoView as BaseSudoView
 
 
+@control_silo_view
 class SudoView(BaseSudoView):
     template_name = "sentry/account/sudo.html"
 

+ 4 - 1
static/app/data/controlsiloUrlPatterns.ts

@@ -13,6 +13,7 @@ const patterns: RegExp[] = [
   new RegExp('^api/0/audit-logs/$'),
   new RegExp('^api/0/_admin/options/$'),
   new RegExp('^api/0/billingadmins/$'),
+  new RegExp('^api/0/superuseradmins/$'),
   new RegExp('^api/0/beacons/$'),
   new RegExp('^api/0/beacons/[^/]+/$'),
   new RegExp('^api/0/beacons/[^/]+/checkins/$'),
@@ -29,7 +30,7 @@ const patterns: RegExp[] = [
   new RegExp('^api/0/policies/[^/]+/revisions/$'),
   new RegExp('^api/0/policies/[^/]+/revisions/[^/]+/$'),
   new RegExp('^api/0/promocodes/$'),
-  new RegExp('^api/0/promocodes-external/[^/]+/$'),
+  new RegExp('^api/0/promocodes-external/[^/]+$'),
   new RegExp('^api/0/promocodes/[^/]+/$'),
   new RegExp('^api/0/promocodes/[^/]+/claimants/$'),
   new RegExp('^api/0/gdpr_request/$'),
@@ -91,6 +92,7 @@ const patterns: RegExp[] = [
   new RegExp('^api/0/sentry-apps/[^/]+/avatar/$'),
   new RegExp('^api/0/sentry-apps/[^/]+/api-tokens/$'),
   new RegExp('^api/0/sentry-apps/[^/]+/api-tokens/[^/]+/$'),
+  new RegExp('^api/0/sentry-apps/[^/]+/api-tokens/[^/]+/$'),
   new RegExp('^api/0/sentry-apps/[^/]+/stats/$'),
   new RegExp('^api/0/sentry-apps/[^/]+/publish-request/$'),
   new RegExp('^api/0/sentry-app-installations/[^/]+/$'),
@@ -145,6 +147,7 @@ const patterns: RegExp[] = [
   new RegExp('^auth/reactivate/$'),
   new RegExp('^auth/register/$'),
   new RegExp('^auth/close/$'),
+  new RegExp('^account/sudo/$'),
   new RegExp('^account/user-confirm/[^/]+/$'),
   new RegExp('^account/settings/identities/associate/[^/]+/[^/]+/[^/]+/$'),
   new RegExp('^account/settings/wizard/[^/]+/$'),