passerby 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passerby-0.9.0/LICENSE +201 -0
- passerby-0.9.0/PKG-INFO +31 -0
- passerby-0.9.0/pyproject.toml +149 -0
- passerby-0.9.0/src/passerby/.DS_Store +0 -0
- passerby-0.9.0/src/passerby/__init__.py +0 -0
- passerby-0.9.0/src/passerby/accounts/__init__.py +1 -0
- passerby-0.9.0/src/passerby/accounts/models.py +246 -0
- passerby-0.9.0/src/passerby/accounts/oidc.py +259 -0
- passerby-0.9.0/src/passerby/accounts/roles.py +96 -0
- passerby-0.9.0/src/passerby/accounts/sessions.py +68 -0
- passerby-0.9.0/src/passerby/accounts/users.py +95 -0
- passerby-0.9.0/src/passerby/alerts/__init__.py +2 -0
- passerby-0.9.0/src/passerby/alerts/models.py +69 -0
- passerby-0.9.0/src/passerby/alerts/reports.py +240 -0
- passerby-0.9.0/src/passerby/alerts/send.py +304 -0
- passerby-0.9.0/src/passerby/cli.py +511 -0
- passerby-0.9.0/src/passerby/config.py +171 -0
- passerby-0.9.0/src/passerby/db.py +117 -0
- passerby-0.9.0/src/passerby/demo/__init__.py +3 -0
- passerby-0.9.0/src/passerby/demo/sites.py +411 -0
- passerby-0.9.0/src/passerby/demo/traffic.py +565 -0
- passerby-0.9.0/src/passerby/filtering/__init__.py +1 -0
- passerby-0.9.0/src/passerby/filtering/data/crawler_user_agents.txt +37 -0
- passerby-0.9.0/src/passerby/filtering/data/hosting_asns.txt +65 -0
- passerby-0.9.0/src/passerby/filtering/data/referrer_spam.txt +2360 -0
- passerby-0.9.0/src/passerby/filtering/models.py +42 -0
- passerby-0.9.0/src/passerby/filtering/rules.py +205 -0
- passerby-0.9.0/src/passerby/housekeeping/__init__.py +1 -0
- passerby-0.9.0/src/passerby/housekeeping/health.py +368 -0
- passerby-0.9.0/src/passerby/housekeeping/reapply.py +114 -0
- passerby-0.9.0/src/passerby/housekeeping/retention.py +90 -0
- passerby-0.9.0/src/passerby/imports/__init__.py +1 -0
- passerby-0.9.0/src/passerby/imports/base.py +373 -0
- passerby-0.9.0/src/passerby/imports/csvfile.py +136 -0
- passerby-0.9.0/src/passerby/imports/matomo.py +254 -0
- passerby-0.9.0/src/passerby/imports/umami.py +180 -0
- passerby-0.9.0/src/passerby/layout.toml +13 -0
- passerby-0.9.0/src/passerby/liveness/__init__.py +1 -0
- passerby-0.9.0/src/passerby/liveness/checks.py +189 -0
- passerby-0.9.0/src/passerby/liveness/domains.py +81 -0
- passerby-0.9.0/src/passerby/liveness/models.py +43 -0
- passerby-0.9.0/src/passerby/liveness/status.py +154 -0
- passerby-0.9.0/src/passerby/mail.py +40 -0
- passerby-0.9.0/src/passerby/migrations/env.py +91 -0
- passerby-0.9.0/src/passerby/migrations/script.py.mako +27 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_0becea1ce756_project_icon.py +43 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_23c2f6f76d71_event_excluded_flag.py +47 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_53c53abf5f6d_user_timezone.py +37 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_7ad858a7d3b3_baseline.py +375 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_ee008225e276_project_retention.py +33 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261111_eeb3643f2c09_event_referrer_host.py +65 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_0889b3c5c142_project_stars.py +69 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_1a1ae69ded81_hosting_networks.py +51 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_1b5be2c5a6e0_project_viewers.py +69 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_4e7a1c2b9d30_lowercase_emails.py +43 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_6b2898bf913b_dismissed_problems.py +56 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_78725731e933_user_sessions_valid_after.py +34 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_8d3f5a1e6c27_superusers_are_staff.py +28 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_97bbd8425a29_share_links.py +59 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261112_dbb0e00c7f0e_instance_blocked_countries_and_spam_.py +62 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261113_3ffa02de0f80_store_entries_for_shared_rate_limits.py +56 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261113_b7e2c4d91a05_keep_only_utm_parameters.py +73 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261114_882422b477b9_entry_and_exit_pages_on_visits.py +73 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261114_b4fb13573a5c_goals.py +68 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261114_d3b8e4fd9083_archived_sites.py +40 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_1b50500b1915_consent_exempt_projects.py +40 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_5891c4e9db51_webhook_alerts.py +92 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_5b9870b14026_opt_out_seen_on_sites.py +42 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_6264cf0316ee_annotations.py +67 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_b400707f57d8_liveness_checks.py +133 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261116_e1a183071097_email_alerts_and_reports.py +126 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261117_5301de8306c2_page_measures_and_visit_facts.py +72 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261117_5972834e4337_funnels.py +61 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261117_6e8ff6a86c82_segments.py +61 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261118_1d5c0e7a9b42_embeds.py +28 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261118_2d363b6d81df_roles_on_neozen.py +144 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261118_ae826b8acf38_accounts_on_neozen.py +142 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261120_5c1e0a7d9b42_index_excluded_visits.py +33 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261124_7c3d9e21f0ab_project_labels.py +59 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261124_c41d8f0a6b27_organizations.py +335 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261126_a8b07f3e7527_liveness_check_latest.py +29 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261129_3f6a2d8c1b94_site_per_project.py +31 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261203_5b1e7c0d9a42_webhook_secret.py +49 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261203_8d24f6a1c0e3_report_recipients.py +68 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261203_a1f0d93c6b57_api_token_writes.py +33 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261203_c7a35e9b2d18_share_link_password.py +33 -0
- passerby-0.9.0/src/passerby/migrations/versions/20261203_e4b9c2f17a60_public_pages.py +41 -0
- passerby-0.9.0/src/passerby/net.py +112 -0
- passerby-0.9.0/src/passerby/organizations/__init__.py +1 -0
- passerby-0.9.0/src/passerby/organizations/access.py +187 -0
- passerby-0.9.0/src/passerby/organizations/members.py +326 -0
- passerby-0.9.0/src/passerby/projects/__init__.py +1 -0
- passerby-0.9.0/src/passerby/projects/icons.py +343 -0
- passerby-0.9.0/src/passerby/projects/models.py +264 -0
- passerby-0.9.0/src/passerby/py.typed +0 -0
- passerby-0.9.0/src/passerby/reporting/__init__.py +1 -0
- passerby-0.9.0/src/passerby/reporting/attention.py +329 -0
- passerby-0.9.0/src/passerby/reporting/filters.py +113 -0
- passerby-0.9.0/src/passerby/reporting/models.py +90 -0
- passerby-0.9.0/src/passerby/reporting/periods.py +278 -0
- passerby-0.9.0/src/passerby/reporting/stats.py +1709 -0
- passerby-0.9.0/src/passerby/sharing/__init__.py +1 -0
- passerby-0.9.0/src/passerby/sharing/models.py +42 -0
- passerby-0.9.0/src/passerby/text.py +50 -0
- passerby-0.9.0/src/passerby/tracking/__init__.py +1 -0
- passerby-0.9.0/src/passerby/tracking/geoip.py +173 -0
- passerby-0.9.0/src/passerby/tracking/ingest.py +453 -0
- passerby-0.9.0/src/passerby/tracking/models.py +190 -0
- passerby-0.9.0/src/passerby/web/__init__.py +1 -0
- passerby-0.9.0/src/passerby/web/auth/__init__.py +18 -0
- passerby-0.9.0/src/passerby/web/auth/api_auth.py +80 -0
- passerby-0.9.0/src/passerby/web/auth/guards.py +103 -0
- passerby-0.9.0/src/passerby/web/auth/identity.py +75 -0
- passerby-0.9.0/src/passerby/web/auth/middleware.py +39 -0
- passerby-0.9.0/src/passerby/web/auth/session.py +60 -0
- passerby-0.9.0/src/passerby/web/di.py +270 -0
- passerby-0.9.0/src/passerby/web/exports.py +46 -0
- passerby-0.9.0/src/passerby/web/forms.py +311 -0
- passerby-0.9.0/src/passerby/web/main.py +326 -0
- passerby-0.9.0/src/passerby/web/pages.py +482 -0
- passerby-0.9.0/src/passerby/web/repositories.py +47 -0
- passerby-0.9.0/src/passerby/web/routes/__init__.py +72 -0
- passerby-0.9.0/src/passerby/web/routes/account.py +270 -0
- passerby-0.9.0/src/passerby/web/routes/admin.py +334 -0
- passerby-0.9.0/src/passerby/web/routes/annotations.py +92 -0
- passerby-0.9.0/src/passerby/web/routes/api.py +332 -0
- passerby-0.9.0/src/passerby/web/routes/attention.py +105 -0
- passerby-0.9.0/src/passerby/web/routes/auth.py +183 -0
- passerby-0.9.0/src/passerby/web/routes/dashboard.py +224 -0
- passerby-0.9.0/src/passerby/web/routes/dto.py +195 -0
- passerby-0.9.0/src/passerby/web/routes/filtering.py +204 -0
- passerby-0.9.0/src/passerby/web/routes/goals.py +245 -0
- passerby-0.9.0/src/passerby/web/routes/home.py +62 -0
- passerby-0.9.0/src/passerby/web/routes/mcp.py +225 -0
- passerby-0.9.0/src/passerby/web/routes/members.py +301 -0
- passerby-0.9.0/src/passerby/web/routes/projects.py +896 -0
- passerby-0.9.0/src/passerby/web/routes/public.py +236 -0
- passerby-0.9.0/src/passerby/web/routes/reports.py +209 -0
- passerby-0.9.0/src/passerby/web/routes/share.py +361 -0
- passerby-0.9.0/src/passerby/web/routes/sharing.py +325 -0
- passerby-0.9.0/src/passerby/web/routes/tracker.py +220 -0
- passerby-0.9.0/src/passerby/web/routes/visits.py +168 -0
- passerby-0.9.0/src/passerby/web/security.py +141 -0
- passerby-0.9.0/src/passerby/web/service.py +40 -0
- passerby-0.9.0/src/passerby/web/static/ads/ads.css +3622 -0
- passerby-0.9.0/src/passerby/web/static/ads/restore.js +31 -0
- passerby-0.9.0/src/passerby/web/static/ads/shell.js +248 -0
- passerby-0.9.0/src/passerby/web/static/ads/situ.css +108 -0
- passerby-0.9.0/src/passerby/web/static/app.js +497 -0
- passerby-0.9.0/src/passerby/web/static/favicon.png +0 -0
- passerby-0.9.0/src/passerby/web/static/fonts/OFL-barlow.txt +93 -0
- passerby-0.9.0/src/passerby/web/static/fonts/OFL-figtree.txt +93 -0
- passerby-0.9.0/src/passerby/web/static/fonts/barlow-condensed-500.woff2 +0 -0
- passerby-0.9.0/src/passerby/web/static/fonts/barlow-condensed-600.woff2 +0 -0
- passerby-0.9.0/src/passerby/web/static/fonts/figtree.woff2 +0 -0
- passerby-0.9.0/src/passerby/web/static/icons.json +84 -0
- passerby-0.9.0/src/passerby/web/static/passerby.svg +8 -0
- passerby-0.9.0/src/passerby/web/static/t.js +367 -0
- passerby-0.9.0/src/passerby/web/static/t.min.js +2 -0
- passerby-0.9.0/src/passerby/web/static/theme.css +464 -0
- passerby-0.9.0/src/passerby/web/static/world.svg +1 -0
- passerby-0.9.0/src/passerby/web/static_files.py +50 -0
- passerby-0.9.0/src/passerby/web/stores.py +115 -0
- passerby-0.9.0/src/passerby/web/templates/_macros.html +137 -0
- passerby-0.9.0/src/passerby/web/templates/account.html +120 -0
- passerby-0.9.0/src/passerby/web/templates/admin/health.html +26 -0
- passerby-0.9.0/src/passerby/web/templates/admin/rules.html +107 -0
- passerby-0.9.0/src/passerby/web/templates/admin/users.html +89 -0
- passerby-0.9.0/src/passerby/web/templates/ads/form.html +98 -0
- passerby-0.9.0/src/passerby/web/templates/ads/nav.html +52 -0
- passerby-0.9.0/src/passerby/web/templates/ads/shell.html +132 -0
- passerby-0.9.0/src/passerby/web/templates/attention.html +56 -0
- passerby-0.9.0/src/passerby/web/templates/auth/login.html +26 -0
- passerby-0.9.0/src/passerby/web/templates/base.html +89 -0
- passerby-0.9.0/src/passerby/web/templates/dashboard/index.html +165 -0
- passerby-0.9.0/src/passerby/web/templates/demo.html +16 -0
- passerby-0.9.0/src/passerby/web/templates/error.html +14 -0
- passerby-0.9.0/src/passerby/web/templates/home.html +11 -0
- passerby-0.9.0/src/passerby/web/templates/invitation.html +25 -0
- passerby-0.9.0/src/passerby/web/templates/members.html +120 -0
- passerby-0.9.0/src/passerby/web/templates/projects/_details.html +88 -0
- passerby-0.9.0/src/passerby/web/templates/projects/_flow.html +39 -0
- passerby-0.9.0/src/passerby/web/templates/projects/_privacy_notice.html +20 -0
- passerby-0.9.0/src/passerby/web/templates/projects/_report.html +445 -0
- passerby-0.9.0/src/passerby/web/templates/projects/create.html +28 -0
- passerby-0.9.0/src/passerby/web/templates/projects/details.html +11 -0
- passerby-0.9.0/src/passerby/web/templates/projects/filtering.html +183 -0
- passerby-0.9.0/src/passerby/web/templates/projects/flow.html +10 -0
- passerby-0.9.0/src/passerby/web/templates/projects/live.html +52 -0
- passerby-0.9.0/src/passerby/web/templates/projects/report.html +27 -0
- passerby-0.9.0/src/passerby/web/templates/projects/search.html +27 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/_fields.html +104 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/_page.html +23 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/alerts.html +34 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/general.html +88 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/monitoring.html +77 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/privacy.html +29 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/sharing.html +123 -0
- passerby-0.9.0/src/passerby/web/templates/projects/settings/tracking.html +76 -0
- passerby-0.9.0/src/passerby/web/templates/projects/unclaimed.html +43 -0
- passerby-0.9.0/src/passerby/web/templates/projects/visits.html +61 -0
- passerby-0.9.0/src/passerby/web/templates/public.html +25 -0
- passerby-0.9.0/src/passerby/web/templates/public_status.html +59 -0
- passerby-0.9.0/src/passerby/web/templates/report_stop.html +17 -0
- passerby-0.9.0/src/passerby/web/templates/share/base.html +36 -0
- passerby-0.9.0/src/passerby/web/templates/share/details.html +6 -0
- passerby-0.9.0/src/passerby/web/templates/share/flow.html +6 -0
- passerby-0.9.0/src/passerby/web/templates/share/locked.html +20 -0
- passerby-0.9.0/src/passerby/web/templates/share/report.html +6 -0
- passerby-0.9.0/src/passerby/web/transactions.py +52 -0
- passerby-0.9.0/src/passerby/web/ui.py +701 -0
- passerby-0.9.0/src/passerby/worker.py +209 -0
- passerby-0.9.0/tests/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/accounts/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/accounts/test_password_hashing.py +43 -0
- passerby-0.9.0/tests/a_unit/alerts/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/alerts/test_messages.py +62 -0
- passerby-0.9.0/tests/a_unit/alerts/test_reports.py +84 -0
- passerby-0.9.0/tests/a_unit/alerts/test_webhooks.py +75 -0
- passerby-0.9.0/tests/a_unit/conftest.py +24 -0
- passerby-0.9.0/tests/a_unit/filtering/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/filtering/test_rules.py +262 -0
- passerby-0.9.0/tests/a_unit/housekeeping/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/housekeeping/test_health.py +86 -0
- passerby-0.9.0/tests/a_unit/imports/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/imports/test_matomo_parsing.py +105 -0
- passerby-0.9.0/tests/a_unit/imports/test_umami_parsing.py +110 -0
- passerby-0.9.0/tests/a_unit/liveness/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/liveness/test_domains.py +54 -0
- passerby-0.9.0/tests/a_unit/liveness/test_uptime.py +26 -0
- passerby-0.9.0/tests/a_unit/projects/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/projects/test_icons.py +290 -0
- passerby-0.9.0/tests/a_unit/reporting/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/reporting/test_attention.py +159 -0
- passerby-0.9.0/tests/a_unit/reporting/test_event_properties.py +32 -0
- passerby-0.9.0/tests/a_unit/reporting/test_stats.py +282 -0
- passerby-0.9.0/tests/a_unit/test_entrypoints.py +41 -0
- passerby-0.9.0/tests/a_unit/test_layering.py +58 -0
- passerby-0.9.0/tests/a_unit/test_models.py +270 -0
- passerby-0.9.0/tests/a_unit/test_net.py +71 -0
- passerby-0.9.0/tests/a_unit/test_test_environment.py +35 -0
- passerby-0.9.0/tests/a_unit/tracking/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/tracking/test_geoip_updates.py +127 -0
- passerby-0.9.0/tests/a_unit/web/__init__.py +0 -0
- passerby-0.9.0/tests/a_unit/web/test_components.py +389 -0
- passerby-0.9.0/tests/a_unit/web/test_config_and_geoip.py +108 -0
- passerby-0.9.0/tests/a_unit/web/test_dashboard.py +89 -0
- passerby-0.9.0/tests/a_unit/web/test_exports.py +28 -0
- passerby-0.9.0/tests/a_unit/web/test_goals.py +87 -0
- passerby-0.9.0/tests/a_unit/web/test_guards.py +88 -0
- passerby-0.9.0/tests/a_unit/web/test_labels.py +32 -0
- passerby-0.9.0/tests/a_unit/web/test_routes.py +172 -0
- passerby-0.9.0/tests/a_unit/web/test_ui.py +389 -0
- passerby-0.9.0/tests/a_unit/web/test_world_map.py +20 -0
- passerby-0.9.0/tests/b_integration/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/alerts/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/alerts/test_mail.py +324 -0
- passerby-0.9.0/tests/b_integration/alerts/test_send.py +125 -0
- passerby-0.9.0/tests/b_integration/conftest.py +207 -0
- passerby-0.9.0/tests/b_integration/housekeeping/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/housekeeping/test_health.py +46 -0
- passerby-0.9.0/tests/b_integration/housekeeping/test_reapply.py +143 -0
- passerby-0.9.0/tests/b_integration/housekeeping/test_retention.py +152 -0
- passerby-0.9.0/tests/b_integration/imports/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/imports/test_csvfile.py +94 -0
- passerby-0.9.0/tests/b_integration/imports/test_matomo.py +199 -0
- passerby-0.9.0/tests/b_integration/imports/test_umami.py +277 -0
- passerby-0.9.0/tests/b_integration/liveness/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/liveness/test_checks.py +311 -0
- passerby-0.9.0/tests/b_integration/liveness/test_domains.py +87 -0
- passerby-0.9.0/tests/b_integration/organizations/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/organizations/test_members.py +57 -0
- passerby-0.9.0/tests/b_integration/reporting/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/reporting/test_stats_service.py +1057 -0
- passerby-0.9.0/tests/b_integration/test_cli.py +268 -0
- passerby-0.9.0/tests/b_integration/test_demo.py +139 -0
- passerby-0.9.0/tests/b_integration/test_migrations.py +219 -0
- passerby-0.9.0/tests/b_integration/tracking/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/tracking/test_ingest.py +549 -0
- passerby-0.9.0/tests/b_integration/web/__init__.py +0 -0
- passerby-0.9.0/tests/b_integration/web/test_app.py +81 -0
- passerby-0.9.0/tests/b_integration/web/test_stores.py +77 -0
- passerby-0.9.0/tests/b_integration/web/test_transactions.py +120 -0
- passerby-0.9.0/tests/c_e2e/__init__.py +0 -0
- passerby-0.9.0/tests/c_e2e/conftest.py +315 -0
- passerby-0.9.0/tests/c_e2e/web/__init__.py +0 -0
- passerby-0.9.0/tests/c_e2e/web/test_account_routes.py +146 -0
- passerby-0.9.0/tests/c_e2e/web/test_admin_routes.py +310 -0
- passerby-0.9.0/tests/c_e2e/web/test_annotation_routes.py +119 -0
- passerby-0.9.0/tests/c_e2e/web/test_api_routes.py +473 -0
- passerby-0.9.0/tests/c_e2e/web/test_attention_routes.py +94 -0
- passerby-0.9.0/tests/c_e2e/web/test_auth_routes.py +136 -0
- passerby-0.9.0/tests/c_e2e/web/test_dashboard_routes.py +177 -0
- passerby-0.9.0/tests/c_e2e/web/test_document_checks.py +73 -0
- passerby-0.9.0/tests/c_e2e/web/test_export_routes.py +112 -0
- passerby-0.9.0/tests/c_e2e/web/test_health_route.py +70 -0
- passerby-0.9.0/tests/c_e2e/web/test_home_routes.py +39 -0
- passerby-0.9.0/tests/c_e2e/web/test_label_routes.py +218 -0
- passerby-0.9.0/tests/c_e2e/web/test_live_routes.py +56 -0
- passerby-0.9.0/tests/c_e2e/web/test_liveness_routes.py +94 -0
- passerby-0.9.0/tests/c_e2e/web/test_login_flow.py +332 -0
- passerby-0.9.0/tests/c_e2e/web/test_mail_routes.py +169 -0
- passerby-0.9.0/tests/c_e2e/web/test_mcp_routes.py +80 -0
- passerby-0.9.0/tests/c_e2e/web/test_oidc_sign_in.py +497 -0
- passerby-0.9.0/tests/c_e2e/web/test_organizations.py +680 -0
- passerby-0.9.0/tests/c_e2e/web/test_projects_routes.py +1610 -0
- passerby-0.9.0/tests/c_e2e/web/test_public_routes.py +128 -0
- passerby-0.9.0/tests/c_e2e/web/test_rate_limits.py +58 -0
- passerby-0.9.0/tests/c_e2e/web/test_security.py +116 -0
- passerby-0.9.0/tests/c_e2e/web/test_segment_routes.py +65 -0
- passerby-0.9.0/tests/c_e2e/web/test_share_routes.py +273 -0
- passerby-0.9.0/tests/c_e2e/web/test_tracker_routes.py +241 -0
- passerby-0.9.0/tests/c_e2e/web/test_viewer_routes.py +161 -0
- passerby-0.9.0/tests/conftest.py +46 -0
- passerby-0.9.0/tests/docker/Dockerfile +29 -0
- passerby-0.9.0/tests/docker/Dockerfile.dockerignore +13 -0
- passerby-0.9.0/tests/docker/README.md +20 -0
- passerby-0.9.0/tests/docker/compose.host-network.yaml +12 -0
- passerby-0.9.0/tests/docker/compose.yaml +29 -0
- passerby-0.9.0/tests/identity_provider.py +124 -0
- passerby-0.9.0/tests/images.py +17 -0
- passerby-0.9.0/tests/organizations.py +82 -0
- passerby-0.9.0/tests/schema.py +33 -0
passerby-0.9.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
passerby-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: passerby
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Privacy-friendly, cookie-free web analytics powered by Litestar.
|
|
5
|
+
Author-Email: "S. Fermigier" <sf@abilian.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: <4.0,>=3.12.4
|
|
8
|
+
Requires-Dist: litestar[standard]>=2.21.0
|
|
9
|
+
Requires-Dist: dishka>=1.0.0
|
|
10
|
+
Requires-Dist: pydantic>=2.12.5
|
|
11
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
12
|
+
Requires-Dist: uvicorn>=0.40.0
|
|
13
|
+
Requires-Dist: myxo[postgresql]>=0.3
|
|
14
|
+
Requires-Dist: neozen[oauth-client]>=0.13
|
|
15
|
+
Requires-Dist: sqlalchemy<2.1,>=2.0.23
|
|
16
|
+
Requires-Dist: advanced-alchemy<2.0,>=1.8
|
|
17
|
+
Requires-Dist: asyncpg>=0.31.0
|
|
18
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
19
|
+
Requires-Dist: alembic>=1.13
|
|
20
|
+
Requires-Dist: geoip2<6.0.0,>=5.2.0
|
|
21
|
+
Requires-Dist: pycountry>=25.0.0
|
|
22
|
+
Requires-Dist: user-agents<3.0.0,>=2.2.0
|
|
23
|
+
Requires-Dist: python-ipware<4,>=3
|
|
24
|
+
Requires-Dist: python-dotenv<2.0.0,>=1.0.1
|
|
25
|
+
Requires-Dist: sentry-sdk<3,>=2
|
|
26
|
+
Requires-Dist: pagebar[sqlalchemy]>=0.2.0
|
|
27
|
+
Requires-Dist: beartype<1.0,>=0.18
|
|
28
|
+
Requires-Dist: pyyaml<7,>=6
|
|
29
|
+
Requires-Dist: toolz<2.0.0,>=1.1.0
|
|
30
|
+
Requires-Dist: pillow>=11
|
|
31
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "passerby"
|
|
3
|
+
version = "0.9.0"
|
|
4
|
+
description = "Privacy-friendly, cookie-free web analytics powered by Litestar."
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "S. Fermigier", email = "sf@abilian.com" },
|
|
7
|
+
]
|
|
8
|
+
requires-python = "<4.0,>=3.12.4"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"litestar[standard]>=2.21.0",
|
|
11
|
+
"dishka>=1.0.0",
|
|
12
|
+
"pydantic>=2.12.5",
|
|
13
|
+
"pydantic-settings>=2.0.0",
|
|
14
|
+
"uvicorn>=0.40.0",
|
|
15
|
+
"myxo[postgresql]>=0.3",
|
|
16
|
+
"neozen[oauth-client]>=0.13",
|
|
17
|
+
"sqlalchemy>=2.0.23,<2.1",
|
|
18
|
+
"advanced-alchemy>=1.8,<2.0",
|
|
19
|
+
"asyncpg>=0.31.0",
|
|
20
|
+
"aiosqlite>=0.20.0",
|
|
21
|
+
"alembic>=1.13",
|
|
22
|
+
"geoip2<6.0.0,>=5.2.0",
|
|
23
|
+
"pycountry>=25.0.0",
|
|
24
|
+
"user-agents<3.0.0,>=2.2.0",
|
|
25
|
+
"python-ipware<4,>=3",
|
|
26
|
+
"python-dotenv<2.0.0,>=1.0.1",
|
|
27
|
+
"sentry-sdk<3,>=2",
|
|
28
|
+
"pagebar[sqlalchemy]>=0.2.0",
|
|
29
|
+
"beartype<1.0,>=0.18",
|
|
30
|
+
"pyyaml<7,>=6",
|
|
31
|
+
"toolz<2.0.0,>=1.1.0",
|
|
32
|
+
"pillow>=11",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.license]
|
|
36
|
+
text = "Apache-2.0"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
passerby = "passerby.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.entry-points."myxo.services"]
|
|
42
|
+
web = "passerby.web.service:Web"
|
|
43
|
+
jobs = "passerby.worker:Worker"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"abilian-devtools<1.0.0,>=0.10.0",
|
|
48
|
+
"devtools<1.0.0,>=0.12.2",
|
|
49
|
+
"snoop<1.0.0,>=0.4.3",
|
|
50
|
+
"pytest>=9.0.2",
|
|
51
|
+
"pytest-cov>=7.0.0",
|
|
52
|
+
"pytest-archon<1.0.0,>=0.0.6",
|
|
53
|
+
"nox>=2026.2.9",
|
|
54
|
+
"faker<41,>=40",
|
|
55
|
+
"psycopg2-binary<3,>=2.9.9",
|
|
56
|
+
"ruff>=0.15.1",
|
|
57
|
+
"mypy>=1.19.1",
|
|
58
|
+
"ty>=0.0.17",
|
|
59
|
+
"pyrefly>=0.52.0",
|
|
60
|
+
"zuban>=0.10.2",
|
|
61
|
+
"pre-commit>=4.5.1",
|
|
62
|
+
"httpx>=0.28.1",
|
|
63
|
+
"abilian-ds==0.4.0",
|
|
64
|
+
"zensical>=0.1.1",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.pdm.build]
|
|
68
|
+
includes = [
|
|
69
|
+
"src/passerby",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[[tool.mypy.overrides]]
|
|
73
|
+
module = [
|
|
74
|
+
"user_agents",
|
|
75
|
+
"user_agents.*",
|
|
76
|
+
]
|
|
77
|
+
ignore_missing_imports = true
|
|
78
|
+
|
|
79
|
+
[tool.pytest.ini_options]
|
|
80
|
+
addopts = "--tb=short"
|
|
81
|
+
settings_class = "passerby.config:Settings"
|
|
82
|
+
testpaths = [
|
|
83
|
+
"tests",
|
|
84
|
+
"src",
|
|
85
|
+
]
|
|
86
|
+
markers = [
|
|
87
|
+
"unit: Unit tests (fast, isolated, no I/O)",
|
|
88
|
+
"integration: Integration tests (component interactions, database)",
|
|
89
|
+
"e2e: End-to-end tests (full HTTP request/response cycle)",
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
[tool.tepyd]
|
|
93
|
+
src_root = "src/passerby"
|
|
94
|
+
src_package = "passerby"
|
|
95
|
+
units = [
|
|
96
|
+
"*",
|
|
97
|
+
"*.py",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[tool.tepyd.exclude]
|
|
101
|
+
utils = "a one-line utcnow() helper; exercised by every model default"
|
|
102
|
+
|
|
103
|
+
[[tool.tepyd.tiers]]
|
|
104
|
+
name = "a_unit"
|
|
105
|
+
root = "tests/a_unit"
|
|
106
|
+
label = "unit"
|
|
107
|
+
target_share = 0.6
|
|
108
|
+
|
|
109
|
+
[[tool.tepyd.tiers]]
|
|
110
|
+
name = "b_integration"
|
|
111
|
+
root = "tests/b_integration"
|
|
112
|
+
label = "integration"
|
|
113
|
+
|
|
114
|
+
[[tool.tepyd.tiers]]
|
|
115
|
+
name = "c_e2e"
|
|
116
|
+
root = "tests/c_e2e"
|
|
117
|
+
label = "e2e"
|
|
118
|
+
expects = [
|
|
119
|
+
"web",
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[tool.abilian-ds]
|
|
123
|
+
theme = "src/passerby/web/static/ads"
|
|
124
|
+
components = "src/passerby/web/templates/ads"
|
|
125
|
+
templates = [
|
|
126
|
+
"src/passerby/web/templates",
|
|
127
|
+
"mockups/templates",
|
|
128
|
+
]
|
|
129
|
+
stylesheet = [
|
|
130
|
+
"src/passerby/web/static/ads/ads.css",
|
|
131
|
+
"src/passerby/web/static/theme.css",
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
[tool.pyrefly]
|
|
135
|
+
preset = "default"
|
|
136
|
+
project-includes = [
|
|
137
|
+
"**/*.py*",
|
|
138
|
+
"**/*.ipynb",
|
|
139
|
+
]
|
|
140
|
+
search-path = [
|
|
141
|
+
"src",
|
|
142
|
+
".",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
[build-system]
|
|
146
|
+
requires = [
|
|
147
|
+
"pdm-backend",
|
|
148
|
+
]
|
|
149
|
+
build-backend = "pdm.backend"
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Who signs in: users, their passwords and API tokens."""
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"""Accounts: who signs in, as NeoZen keeps them (`Subject`: the email, the
|
|
2
|
+
password's hash, the active flag, and the sessions), and what analytics
|
|
3
|
+
knows of them (`User`: the username, the timezone). This module is where the
|
|
4
|
+
two meet: the rest of the app reads a `User`, and of NeoZen's, what
|
|
5
|
+
`passerby.organizations` makes of it."""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
import re
|
|
11
|
+
import secrets
|
|
12
|
+
from datetime import UTC, datetime, timedelta
|
|
13
|
+
from uuid import uuid4
|
|
14
|
+
|
|
15
|
+
from advanced_alchemy.base import UUIDAuditBase
|
|
16
|
+
from neozen.core.authz.models import ScopeType
|
|
17
|
+
from neozen.core.crypto import generate_token
|
|
18
|
+
from neozen.storage.sqlalchemy.models import RoleAssignment, Subject
|
|
19
|
+
from pwdlib import PasswordHash
|
|
20
|
+
from pwdlib.exceptions import UnknownHashError
|
|
21
|
+
from sqlalchemy import ForeignKey, Select, String, and_, false, select
|
|
22
|
+
from sqlalchemy.orm import Mapped, foreign, mapped_column, relationship
|
|
23
|
+
|
|
24
|
+
from passerby.accounts.roles import ROLE_IDS, Role
|
|
25
|
+
from passerby.db import utcnow
|
|
26
|
+
|
|
27
|
+
# Argon2id. Hashes from before 2026-09-14 (PBKDF2) that no sign-in upgraded
|
|
28
|
+
# since don't verify: an administrator resets those passwords.
|
|
29
|
+
PASSWORDS = PasswordHash.recommended()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def hash_api_token(token: str) -> str:
|
|
33
|
+
"""Hash an API token using SHA256."""
|
|
34
|
+
return hashlib.sha256(token.encode()).hexdigest()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def as_utc(moment: datetime) -> datetime:
|
|
38
|
+
"""A time from NeoZen's tables: SQLite gives it back without its UTC."""
|
|
39
|
+
return moment if moment.tzinfo else moment.replace(tzinfo=UTC)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def normalize_email(email: str) -> str:
|
|
43
|
+
"""An email as stored, and as looked up: trimmed, in lower case."""
|
|
44
|
+
return email.strip().lower()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
MAX_EMAIL = 254
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def parse_email(text: str) -> str:
|
|
51
|
+
"""An email as stored; ValueError for one that isn't."""
|
|
52
|
+
email = normalize_email(text)
|
|
53
|
+
if len(email) > MAX_EMAIL or not re.fullmatch(r"[^@\s]+@[^@\s]+\.[^@\s]+", email):
|
|
54
|
+
msg = "Invalid email address"
|
|
55
|
+
raise ValueError(msg)
|
|
56
|
+
return email
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class User(UUIDAuditBase):
|
|
60
|
+
# Who signs in: the email, the password and the active flag are the
|
|
61
|
+
# subject's, and nowhere else. Loaded with the user, always.
|
|
62
|
+
subject_id: Mapped[str] = mapped_column(
|
|
63
|
+
ForeignKey(Subject.id, ondelete="CASCADE"), unique=True
|
|
64
|
+
)
|
|
65
|
+
subject: Mapped[Subject] = relationship(Subject, lazy="joined", innerjoin=True)
|
|
66
|
+
|
|
67
|
+
username: Mapped[str] = mapped_column(String(150), unique=True)
|
|
68
|
+
|
|
69
|
+
# API token stored as SHA256 hash (plaintext never stored)
|
|
70
|
+
api_token_hash: Mapped[str | None] = mapped_column(String(64), default=None)
|
|
71
|
+
api_token_expires_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
72
|
+
# Whether the token may write (import history, add notes), or only read.
|
|
73
|
+
api_token_writes: Mapped[bool] = mapped_column(
|
|
74
|
+
default=False, server_default=false()
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# The subject's roles on the instance, NeoZen's assignments: loaded with
|
|
78
|
+
# the user, as every page's menu asks. Those in organizations and on
|
|
79
|
+
# projects are passerby.organizations'.
|
|
80
|
+
role_assignments: Mapped[list[RoleAssignment]] = relationship(
|
|
81
|
+
RoleAssignment,
|
|
82
|
+
primaryjoin=lambda: and_(
|
|
83
|
+
User.subject_id == foreign(RoleAssignment.subject_id),
|
|
84
|
+
RoleAssignment.scope_type == ScopeType.GLOBAL,
|
|
85
|
+
),
|
|
86
|
+
lazy="selectin",
|
|
87
|
+
cascade="all, delete-orphan",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# IANA name of the timezone the user's browser reports. Calendar views
|
|
91
|
+
# (days, "yesterday", "this month") are in this timezone.
|
|
92
|
+
timezone: Mapped[str] = mapped_column(
|
|
93
|
+
String(64), default="UTC", server_default="UTC"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def new(
|
|
98
|
+
cls,
|
|
99
|
+
email: str,
|
|
100
|
+
username: str,
|
|
101
|
+
password: str | None = None,
|
|
102
|
+
*,
|
|
103
|
+
roles: tuple[Role, ...] = (),
|
|
104
|
+
**fields: object,
|
|
105
|
+
) -> User:
|
|
106
|
+
"""A new account, with its subject and roles: not added to any
|
|
107
|
+
session. Without a password, no password signs it in. Raises
|
|
108
|
+
ValueError for an email that isn't one."""
|
|
109
|
+
email = parse_email(email)
|
|
110
|
+
user_id = uuid4()
|
|
111
|
+
# The same id on both sides: one less thing to tell apart in the
|
|
112
|
+
# database. Nothing relies on it: the link is `subject_id`.
|
|
113
|
+
user = cls(
|
|
114
|
+
id=user_id,
|
|
115
|
+
username=username,
|
|
116
|
+
subject=Subject(id=str(user_id), email=email, is_active=True),
|
|
117
|
+
**fields,
|
|
118
|
+
)
|
|
119
|
+
if password is not None:
|
|
120
|
+
user.set_password(password)
|
|
121
|
+
for role in roles:
|
|
122
|
+
user.grant(role)
|
|
123
|
+
return user
|
|
124
|
+
|
|
125
|
+
def _assignment(self, role: Role) -> RoleAssignment | None:
|
|
126
|
+
"""NeoZen keeps one per role, expired or not."""
|
|
127
|
+
return next(
|
|
128
|
+
(
|
|
129
|
+
a
|
|
130
|
+
for a in self.role_assignments
|
|
131
|
+
if a.role_id == ROLE_IDS[role] and a.scope_type == ScopeType.GLOBAL
|
|
132
|
+
),
|
|
133
|
+
None,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
def has_role(self, role: Role) -> bool:
|
|
137
|
+
"""Whether the account holds the role on the instance, unexpired."""
|
|
138
|
+
held = self._assignment(role)
|
|
139
|
+
return held is not None and (
|
|
140
|
+
held.expires_at is None or as_utc(held.expires_at) > utcnow()
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def is_superuser(self) -> bool:
|
|
145
|
+
"""An administrator: manages accounts and the instance's rules."""
|
|
146
|
+
return self.has_role(Role.ADMINISTRATOR)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def is_staff(self) -> bool:
|
|
150
|
+
"""Sees the staff pages; administrators do too."""
|
|
151
|
+
return self.is_superuser or self.has_role(Role.STAFF)
|
|
152
|
+
|
|
153
|
+
def grant(self, role: Role) -> None:
|
|
154
|
+
"""Give the account a role on the instance; an expired one again."""
|
|
155
|
+
if self.has_role(role):
|
|
156
|
+
return
|
|
157
|
+
held = self._assignment(role)
|
|
158
|
+
if held is not None:
|
|
159
|
+
held.granted_at, held.expires_at = utcnow(), None
|
|
160
|
+
return
|
|
161
|
+
# As NeoZen's RoleService.assign_role makes them.
|
|
162
|
+
self.role_assignments.append(
|
|
163
|
+
RoleAssignment(
|
|
164
|
+
id=generate_token(prefix="role_"),
|
|
165
|
+
role_id=ROLE_IDS[role],
|
|
166
|
+
scope_type=ScopeType.GLOBAL,
|
|
167
|
+
granted_at=utcnow(),
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
def revoke(self, role: Role) -> None:
|
|
172
|
+
"""Take a role on the instance back from the account."""
|
|
173
|
+
held = self._assignment(role)
|
|
174
|
+
if held is not None:
|
|
175
|
+
self.role_assignments.remove(held)
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def email(self) -> str:
|
|
179
|
+
return self.subject.email
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def is_active(self) -> bool:
|
|
183
|
+
"""Whether the account may sign in, and its sessions count."""
|
|
184
|
+
return self.subject.is_active
|
|
185
|
+
|
|
186
|
+
@is_active.setter
|
|
187
|
+
def is_active(self, active: bool) -> None:
|
|
188
|
+
self.subject.is_active = active
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def has_password(self) -> bool:
|
|
192
|
+
"""Whether a password can sign the account in: one made through the
|
|
193
|
+
identity provider has none until it is given one."""
|
|
194
|
+
return self.subject.hashed_password is not None
|
|
195
|
+
|
|
196
|
+
def set_password(self, password: str) -> None:
|
|
197
|
+
"""Set the user's password (hashed). Ending the account's other
|
|
198
|
+
sessions is the caller's: see `passerby.accounts.sessions`."""
|
|
199
|
+
self.subject.hashed_password = PASSWORDS.hash(password)
|
|
200
|
+
self.subject.password_changed_at = utcnow()
|
|
201
|
+
|
|
202
|
+
def check_password(self, password: str) -> bool:
|
|
203
|
+
"""Whether this is the user's password. A hash in a format no
|
|
204
|
+
longer read (PBKDF2) matches nothing."""
|
|
205
|
+
hashed = self.subject.hashed_password
|
|
206
|
+
if hashed is None:
|
|
207
|
+
return False
|
|
208
|
+
try:
|
|
209
|
+
return PASSWORDS.verify(password, hashed)
|
|
210
|
+
except UnknownHashError:
|
|
211
|
+
return False
|
|
212
|
+
|
|
213
|
+
def generate_api_token(
|
|
214
|
+
self, expires_in_days: int = 365, *, writes: bool = False
|
|
215
|
+
) -> str:
|
|
216
|
+
"""Generate a new API token, that only reads unless it `writes`.
|
|
217
|
+
|
|
218
|
+
The plaintext token is returned once and should be shown to the user.
|
|
219
|
+
Only the hash is stored in the database.
|
|
220
|
+
"""
|
|
221
|
+
token = secrets.token_urlsafe(32)
|
|
222
|
+
self.api_token_hash = hash_api_token(token)
|
|
223
|
+
self.api_token_expires_at = utcnow() + timedelta(days=expires_in_days)
|
|
224
|
+
self.api_token_writes = writes
|
|
225
|
+
return token
|
|
226
|
+
|
|
227
|
+
def revoke_api_token(self) -> None:
|
|
228
|
+
"""Revoke the current API token."""
|
|
229
|
+
self.api_token_hash = None
|
|
230
|
+
self.api_token_expires_at = None
|
|
231
|
+
self.api_token_writes = False
|
|
232
|
+
|
|
233
|
+
def __repr__(self) -> str:
|
|
234
|
+
return f"<User {self.username}>"
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def user_with_email(email: str) -> Select[tuple[User]]:
|
|
238
|
+
"""The account with this email, to look up (emails are unique)."""
|
|
239
|
+
return (
|
|
240
|
+
select(User).join(User.subject).where(Subject.email == normalize_email(email))
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def users_by_email() -> Select[tuple[User]]:
|
|
245
|
+
"""Every account, in the order of their emails."""
|
|
246
|
+
return select(User).join(User.subject).order_by(Subject.email)
|