sentry
sentry copied to clipboard
feat(hybrid-cloud): Set active org based on subdomain
Branched from https://github.com/getsentry/sentry/pull/37037
This pull request adds the CustomerDomainMiddleware middleware that sets the active organization based on request.subdomain. In addition, region domains are ignored (e.g. us.sentry.io).
For example, if the user is accessing acme.sentry.io, then acme will be the active organization, regardless of what the previous (if any) active organization was.
Redirects are also handled. For example if http://acme.sentry.io/organizations/sentry/issues/ was accessed, then a 302 Redirect response will be generated with http://acme.sentry.io/organizations/acme/issues/.
The activation of the CustomerDomainMiddleware middleware will be in a follow up pull request.
@AniketDas-Tekky Is RequestFactory() not sufficient? Can you give me an example of what test you're looking for?
@dashed https://github.com/getsentry/sentry/blob/master/tests/sentry/ratelimits/utils/test_enforce_rate_limit.py#L37
@AniketDas-Tekky I've added some tests that emulates the request/response on the Django framework with and without the CustomerDomainMiddleware middleware.