Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sentry/auth/providers/saml2/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def dispatch(self, request: HttpRequest, organization_slug: str) -> HttpResponse
return pipeline.current_step()


@control_silo_view
class SAML2ACSView(AuthView):
@method_decorator(csrf_exempt)
def dispatch(self, request: HttpRequest, pipeline: AuthHelper) -> HttpResponseBase:
Expand All @@ -152,6 +153,7 @@ def dispatch(self, request: HttpRequest, pipeline: AuthHelper) -> HttpResponseBa
return pipeline.next_step()


@control_silo_view
class SAML2SLSView(BaseView):
@method_decorator(csrf_exempt)
def dispatch(self, request: HttpRequest, organization_slug: str) -> HttpResponseRedirect:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from sentry.integrations.types import IntegrationProviderSlug
from sentry.web.frontend.base import control_silo_view

from .integration_extension_configuration import IntegrationExtensionConfigurationView


@control_silo_view
class DiscordExtensionConfigurationView(IntegrationExtensionConfigurationView):
provider = IntegrationProviderSlug.DISCORD.value
external_provider_key = IntegrationProviderSlug.DISCORD.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from sentry.web.frontend.base import control_silo_view

from .integration_extension_configuration import IntegrationExtensionConfigurationView


@control_silo_view
class VercelExtensionConfigurationView(IntegrationExtensionConfigurationView):
provider = "vercel"
external_provider_key = "vercel"
1 change: 1 addition & 0 deletions src/sentry/web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
}


@all_silo_view
class ClientConfigView(BaseView):
def get(self, request: Request) -> HttpResponse:
return HttpResponse(json.dumps(get_client_config(request)), content_type="application/json")
Expand Down
14 changes: 14 additions & 0 deletions src/sentry/web/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FOREVER_CACHE = "max-age=315360000"

# See
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#requiring_revalidation
# This means that clients *CAN* cache the resource, but they must revalidate
# before using it This means we will have a small HTTP request overhead to
# verify that the local resource is not outdated
#
# Note that the above docs state that "no-cache" is the same as "max-age=0,
# must-revalidate", but some CDNs will not treat them as the same
NO_CACHE = "max-age=0, must-revalidate"

# no-store means that the response should not be stored in *ANY* cache
NEVER_CACHE = "max-age=0, no-cache, no-store, must-revalidate"
2 changes: 1 addition & 1 deletion src/sentry/web/frontend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from sentry.utils.audit import create_audit_entry
from sentry.utils.auth import construct_link_with_query, is_valid_redirect
from sentry.utils.http import absolute_uri, is_using_customer_domain, origin_from_request
from sentry.web.frontend.generic import FOREVER_CACHE
from sentry.web.constants import FOREVER_CACHE
from sentry.web.helpers import render_to_response
from sudo.views import redirect_to_sudo

Expand Down
18 changes: 4 additions & 14 deletions src/sentry/web/frontend/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@
from django.http import Http404, HttpResponseNotFound
from django.views import static

FOREVER_CACHE = "max-age=315360000"

# See
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#requiring_revalidation
# This means that clients *CAN* cache the resource, but they must revalidate
# before using it This means we will have a small HTTP request overhead to
# verify that the local resource is not outdated
#
# Note that the above docs state that "no-cache" is the same as "max-age=0,
# must-revalidate", but some CDNs will not treat them as the same
NO_CACHE = "max-age=0, must-revalidate"

# no-store means that the response should not be stored in *ANY* cache
NEVER_CACHE = "max-age=0, no-cache, no-store, must-revalidate"
from sentry.web.constants import FOREVER_CACHE, NEVER_CACHE, NO_CACHE
from sentry.web.frontend.base import all_silo_view


def dev_favicon(request, extension):
Expand All @@ -45,6 +33,7 @@ def resolve(path):
return os.path.split(absolute_path)


@all_silo_view
def frontend_app_static_media(request, **kwargs):
"""
Serve static files that should not have any versioned paths/filenames.
Expand All @@ -64,6 +53,7 @@ def frontend_app_static_media(request, **kwargs):
return response


@all_silo_view
def static_media(request, **kwargs):
"""
Serve static files below a given point in the directory structure.
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/web/frontend/pipeline_advancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
from sentry.integrations.types import IntegrationProviderSlug
from sentry.organizations.absolute_url import generate_organization_url
from sentry.utils.http import absolute_uri, create_redirect_url
from sentry.web.frontend.base import BaseView
from sentry.web.frontend.base import BaseView, all_silo_view

# The request doesn't contain the pipeline type (pipeline information is stored
# in redis keyed by the pipeline name), so we try to construct multiple pipelines
# and use whichever one works.
PIPELINE_CLASSES = (IntegrationPipeline, IdentityPipeline)


@all_silo_view
class PipelineAdvancerView(BaseView):
"""Gets the current pipeline from the request and executes the current step."""

Expand Down
4 changes: 4 additions & 0 deletions src/social_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from django.utils.http import url_has_allowed_host_and_scheme
from django.views.decorators.csrf import csrf_exempt

from sentry.web.frontend.base import control_silo_view
from social_auth.decorators import dsa_view
from social_auth.exceptions import AuthException
from social_auth.utils import backend_setting, clean_partial_pipeline, setting
Expand All @@ -23,6 +24,7 @@
PIPELINE_KEY = setting("SOCIAL_AUTH_PARTIAL_PIPELINE_KEY", "partial_pipeline")


@control_silo_view
@dsa_view(setting("SOCIAL_AUTH_COMPLETE_URL_NAME", "socialauth_associate_complete_auth_sso"))
def auth(request, backend):
"""Authenticate using social backend"""
Expand Down Expand Up @@ -53,6 +55,7 @@ def auth(request, backend):
return HttpResponse(backend.auth_html(), content_type="text/html;charset=UTF-8")


@control_silo_view
@csrf_exempt
@login_required
@dsa_view()
Expand Down Expand Up @@ -90,6 +93,7 @@ def complete(request, backend, *args, **kwargs):
return HttpResponseRedirect(url)


@control_silo_view
def auth_complete(request, backend, user, *args, **kwargs):
"""Complete auth process. Return authenticated user or None."""
if request.session.get(PIPELINE_KEY):
Expand Down
5 changes: 5 additions & 0 deletions static/app/data/controlsiloUrlPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const patterns: RegExp[] = [
new RegExp('^500/'),
new RegExp('^404/'),
new RegExp('^_warmup/$'),
new RegExp('^api/client-config/?$'),
new RegExp('^api/0/organizations/[^/]+/api-keys/$'),
new RegExp('^api/0/organizations/[^/]+/api-keys/[^/]+/$'),
new RegExp('^api/0/organizations/[^/]+/audit-logs/$'),
Expand Down Expand Up @@ -165,6 +166,7 @@ const patterns: RegExp[] = [
new RegExp('^oauth/token/$'),
new RegExp('^oauth/userinfo/$'),
new RegExp('^saml/acs/[^/]+/$'),
new RegExp('^saml/sls/[^/]+/$'),
new RegExp('^auth/login/$'),
new RegExp('^auth/login/[^/]+/$'),
new RegExp('^auth/channel/[^/]+/[^/]+/$'),
Expand All @@ -188,6 +190,7 @@ const patterns: RegExp[] = [
new RegExp('^avatar/[^/]+/$'),
new RegExp('^sentry-app-avatar/[^/]+/$'),
new RegExp('^doc-integration-avatar/[^/]+/$'),
new RegExp('^extensions/[^/]+/setup/$'),
new RegExp('^extensions/jira/ui-hook/$'),
new RegExp('^extensions/jira/descriptor/$'),
new RegExp('^extensions/jira/installed/$'),
Expand All @@ -209,13 +212,15 @@ const patterns: RegExp[] = [
new RegExp('^extensions/bitbucket/installed/$'),
new RegExp('^extensions/bitbucket/uninstalled/$'),
new RegExp('^extensions/bitbucket/search/[^/]+/[^/]+/$'),
new RegExp('^extensions/vercel/configure/$'),
new RegExp('^extensions/vercel/delete/$'),
new RegExp('^extensions/vercel/webhook/$'),
new RegExp('^extensions/msteams/webhook/$'),
new RegExp('^extensions/msteams/configure/$'),
new RegExp('^extensions/msteams/link-identity/[^/]+/$'),
new RegExp('^extensions/msteams/unlink-identity/[^/]+/$'),
new RegExp('^extensions/discord/interactions/$'),
new RegExp('^extensions/discord/configure/$'),
new RegExp('^extensions/discord/link-identity/[^/]+/$'),
new RegExp('^extensions/discord/unlink-identity/[^/]+/$'),
new RegExp('^share/(?:group|issue)/[^/]+/$'),
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/sentry_apps/web/test_sentryapp_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sentry.sentry_apps.models.sentry_app_avatar import SentryAppAvatar
from sentry.testutils.cases import APITestCase
from sentry.testutils.silo import control_silo_test
from sentry.web.frontend.generic import FOREVER_CACHE
from sentry.web.constants import FOREVER_CACHE


@control_silo_test
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/users/web/test_user_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sentry.testutils.cases import TestCase
from sentry.testutils.silo import control_silo_test
from sentry.users.models.user_avatar import UserAvatar
from sentry.web.frontend.generic import FOREVER_CACHE
from sentry.web.constants import FOREVER_CACHE


@control_silo_test
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/web/frontend/generic/test_static_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sentry.testutils.cases import TestCase
from sentry.testutils.helpers.response import close_streaming_response
from sentry.utils.assets import get_frontend_app_asset_url
from sentry.web.frontend.generic import FOREVER_CACHE, NEVER_CACHE, NO_CACHE
from sentry.web.constants import FOREVER_CACHE, NEVER_CACHE, NO_CACHE


class StaticMediaTest(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/web/frontend/test_doc_integration_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sentry.testutils.cases import APITestCase
from sentry.testutils.silo import control_silo_test
from sentry.web.frontend.generic import FOREVER_CACHE
from sentry.web.constants import FOREVER_CACHE


@control_silo_test
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/web/frontend/test_organization_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sentry.models.avatars.organization_avatar import OrganizationAvatar
from sentry.models.files.file import File
from sentry.testutils.cases import TestCase
from sentry.web.frontend.generic import FOREVER_CACHE
from sentry.web.constants import FOREVER_CACHE


class OrganizationAvatarTest(TestCase):
Expand Down
Loading