Пример #1
0
 def __call__(self, request: HttpRequest) -> HttpResponse:
     if not hasattr(request, "tenant"):
         tenant = get_tenant_for_request(request)
         setattr(request, "tenant", tenant)
         set_tag("authentik.tenant_uuid", tenant.tenant_uuid.hex)
         set_tag("authentik.tenant_domain", tenant.domain)
     return self.get_response(request)
Пример #2
0
 def __call__(self, request: HttpRequest) -> HttpResponse:
     if not hasattr(request, "request_id"):
         request_id = uuid4().hex
         setattr(request, "request_id", request_id)
         LOCAL.authentik = {
             "request_id": request_id,
             "host": request.get_host(),
         }
         set_tag("authentik.request_id", request_id)
     response = self.get_response(request)
     response[RESPONSE_HEADER_ID] = request.request_id
     setattr(response, "ak_context", {})
     response.ak_context.update(LOCAL.authentik)
     response.ak_context[KEY_USER] = request.user.username
     for key in list(LOCAL.authentik.keys()):
         del LOCAL.authentik[key]
     return response
Пример #3
0
 def setup(self, request: HttpRequest, flow_slug: str):
     super().setup(request, flow_slug=flow_slug)
     self.flow = get_object_or_404(Flow.objects.select_related(),
                                   slug=flow_slug)
     self._logger = get_logger().bind(flow_slug=flow_slug)
     set_tag("authentik.flow", self.flow.slug)
Пример #4
0
if _ERROR_REPORTING:
    # pylint: disable=abstract-class-instantiated
    sentry_init(
        dsn="https://[email protected]/8",
        integrations=[
            DjangoIntegration(transaction_style="function_name"),
            CeleryIntegration(),
            RedisIntegration(),
        ],
        before_send=before_send,
        release=f"authentik@{__version__}",
        traces_sample_rate=0.6,
        environment=CONFIG.y("error_reporting.environment", "customer"),
        send_default_pii=CONFIG.y_bool("error_reporting.send_pii", False),
    )
    set_tag("authentik:build_hash", os.environ.get(ENV_GIT_HASH_KEY, ""))
    set_tag(
        "authentik:env", "kubernetes" if "KUBERNETES_PORT" in os.environ else "compose"
    )
    set_tag("authentik:component", "backend")
    j_print(
        "Error reporting is enabled",
        env=CONFIG.y("error_reporting.environment", "customer"),
    )


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = "/static/"
MEDIA_URL = "/media/"
Пример #5
0
    sentry_init(
        dsn=SENTRY_DSN,
        integrations=[
            DjangoIntegration(transaction_style="function_name"),
            CeleryIntegration(),
            RedisIntegration(),
            Boto3Integration(),
            ThreadingIntegration(propagate_hub=True),
        ],
        before_send=before_send,
        release=f"authentik@{__version__}",
        traces_sample_rate=float(CONFIG.y("error_reporting.sample_rate", 0.5)),
        environment=CONFIG.y("error_reporting.environment", "customer"),
        send_default_pii=CONFIG.y_bool("error_reporting.send_pii", False),
    )
    set_tag("authentik.build_hash", get_build_hash("tagged"))
    set_tag("authentik.env", env)
    set_tag("authentik.component", "backend")
    set_tag("authentik.uuid",
            sha512(str(SECRET_KEY).encode("ascii")).hexdigest()[:16])
    j_print(
        "Error reporting is enabled",
        env=CONFIG.y("error_reporting.environment", "customer"),
    )
if not CONFIG.y_bool("disable_startup_analytics", False):
    should_send = env not in ["dev", "ci"]
    if should_send:
        try:
            get_http_session().post(
                "https://goauthentik.io/api/event",
                json={