From 8949464294690515f105de7a51767ecde34d9f79 Mon Sep 17 00:00:00 2001 From: Jens L Date: Wed, 31 Jan 2024 15:24:45 +0100 Subject: [PATCH] root: reformat with latest black version and fix tests (#8376) * format files Signed-off-by: Jens Langhammer * fix pyright Signed-off-by: Jens Langhammer * revert #8367 Signed-off-by: Jens Langhammer * sigh Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- authentik/__init__.py | 1 + authentik/admin/api/meta.py | 1 + authentik/admin/api/metrics.py | 1 + authentik/admin/api/system.py | 1 + authentik/admin/api/version.py | 1 + authentik/admin/api/workers.py | 1 + authentik/admin/apps.py | 1 + authentik/admin/settings.py | 1 + authentik/admin/signals.py | 1 + authentik/admin/tasks.py | 1 + authentik/admin/tests/test_api.py | 1 + authentik/admin/tests/test_tasks.py | 1 + authentik/admin/urls.py | 1 + authentik/api/authentication.py | 1 + authentik/api/authorization.py | 1 + authentik/api/decorators.py | 1 + authentik/api/pagination.py | 1 + authentik/api/schema.py | 1 + authentik/api/tests/test_auth.py | 1 + authentik/api/tests/test_config.py | 1 + authentik/api/tests/test_decorators.py | 1 + authentik/api/tests/test_schema.py | 1 + authentik/api/tests/test_viewsets.py | 1 + authentik/api/urls.py | 1 + authentik/api/v3/config.py | 1 + authentik/api/v3/urls.py | 1 + authentik/api/views.py | 1 + authentik/blueprints/api.py | 1 + .../management/commands/apply_blueprint.py | 1 + .../management/commands/export_blueprint.py | 1 + .../commands/make_blueprint_schema.py | 1 + authentik/blueprints/models.py | 1 + authentik/blueprints/settings.py | 1 + authentik/blueprints/tests/__init__.py | 1 + authentik/blueprints/tests/test_models.py | 1 + authentik/blueprints/tests/test_oci.py | 1 + authentik/blueprints/tests/test_packaged.py | 1 + .../tests/test_serializer_models.py | 1 + authentik/blueprints/tests/test_v1.py | 1 + authentik/blueprints/tests/test_v1_api.py | 1 + .../tests/test_v1_conditional_fields.py | 1 + .../blueprints/tests/test_v1_conditions.py | 1 + authentik/blueprints/tests/test_v1_state.py | 1 + authentik/blueprints/tests/test_v1_tasks.py | 1 + authentik/blueprints/urls.py | 1 + authentik/blueprints/v1/common.py | 1 + authentik/blueprints/v1/exporter.py | 1 + authentik/blueprints/v1/importer.py | 1 + .../blueprints/v1/meta/apply_blueprint.py | 1 + authentik/blueprints/v1/meta/registry.py | 1 + authentik/blueprints/v1/oci.py | 1 + authentik/blueprints/v1/tasks.py | 1 + authentik/brands/api.py | 1 + authentik/brands/apps.py | 1 + authentik/brands/middleware.py | 1 + authentik/brands/models.py | 1 + authentik/brands/tests.py | 1 + authentik/brands/urls.py | 1 + authentik/brands/utils.py | 1 + authentik/core/api/applications.py | 1 + authentik/core/api/authenticated_sessions.py | 1 + authentik/core/api/devices.py | 1 + authentik/core/api/groups.py | 1 + authentik/core/api/propertymappings.py | 1 + authentik/core/api/providers.py | 1 + authentik/core/api/sources.py | 1 + authentik/core/api/tokens.py | 1 + .../core/api/transactional_applications.py | 1 + authentik/core/api/used_by.py | 1 + authentik/core/api/users.py | 1 + authentik/core/api/utils.py | 1 + authentik/core/apps.py | 1 + authentik/core/channels.py | 1 + authentik/core/exceptions.py | 1 + authentik/core/expression/evaluator.py | 1 + .../management/commands/bootstrap_tasks.py | 1 + .../management/commands/build_source_docs.py | 1 + .../core/management/commands/dev_server.py | 1 + .../management/commands/repair_permissions.py | 1 + authentik/core/management/commands/shell.py | 1 + authentik/core/management/commands/worker.py | 1 + authentik/core/middleware.py | 1 + authentik/core/models.py | 1 + authentik/core/signals.py | 1 + authentik/core/sources/flow_manager.py | 1 + authentik/core/sources/stage.py | 1 + authentik/core/tasks.py | 1 + authentik/core/tests/test_api_utils.py | 1 + authentik/core/tests/test_applications_api.py | 1 + .../core/tests/test_applications_views.py | 1 + .../tests/test_authenticated_sessions_api.py | 1 + authentik/core/tests/test_groups.py | 1 + authentik/core/tests/test_groups_api.py | 1 + authentik/core/tests/test_impersonation.py | 1 + authentik/core/tests/test_models.py | 1 + authentik/core/tests/test_property_mapping.py | 1 + .../core/tests/test_property_mapping_api.py | 1 + authentik/core/tests/test_providers_api.py | 1 + .../core/tests/test_source_flow_manager.py | 1 + authentik/core/tests/test_tasks.py | 1 + authentik/core/tests/test_token_api.py | 1 + authentik/core/tests/test_token_auth.py | 1 + .../test_transactional_applications_api.py | 1 + authentik/core/tests/test_users_avatars.py | 1 + authentik/core/tests/utils.py | 1 + authentik/core/types.py | 1 + authentik/core/urls.py | 1 + authentik/core/views/apps.py | 1 + authentik/core/views/debug.py | 1 + authentik/core/views/interface.py | 1 + authentik/core/views/session.py | 1 + authentik/crypto/api.py | 13 +++---- authentik/crypto/apps.py | 1 + authentik/crypto/builder.py | 1 + .../management/commands/import_certificate.py | 1 + authentik/crypto/models.py | 1 + authentik/crypto/settings.py | 1 + authentik/crypto/tasks.py | 1 + authentik/crypto/tests.py | 1 + authentik/crypto/urls.py | 1 + authentik/enterprise/api.py | 1 + authentik/enterprise/apps.py | 1 + authentik/enterprise/audit/apps.py | 1 + authentik/enterprise/audit/middleware.py | 1 + authentik/enterprise/models.py | 1 + authentik/enterprise/policy.py | 1 + .../enterprise/providers/rac/api/endpoints.py | 1 + .../providers/rac/api/property_mappings.py | 1 + .../enterprise/providers/rac/api/providers.py | 1 + authentik/enterprise/providers/rac/apps.py | 1 + .../providers/rac/consumer_client.py | 1 + .../providers/rac/consumer_outpost.py | 1 + .../providers/rac/controllers/docker.py | 1 + .../providers/rac/controllers/kubernetes.py | 1 + authentik/enterprise/providers/rac/models.py | 1 + authentik/enterprise/providers/rac/signals.py | 1 + .../providers/rac/tests/test_models.py | 1 + .../providers/rac/tests/test_views.py | 1 + authentik/enterprise/providers/rac/urls.py | 1 + authentik/enterprise/providers/rac/views.py | 1 + authentik/enterprise/settings.py | 1 + authentik/enterprise/signals.py | 1 + authentik/enterprise/tasks.py | 1 + authentik/enterprise/tests/test_license.py | 1 + authentik/events/api/events.py | 1 + authentik/events/api/notification_mappings.py | 1 + authentik/events/api/notification_rules.py | 1 + .../events/api/notification_transports.py | 1 + authentik/events/api/notifications.py | 1 + authentik/events/api/tasks.py | 1 + authentik/events/apps.py | 1 + authentik/events/context_processors/asn.py | 1 + authentik/events/context_processors/base.py | 1 + authentik/events/context_processors/geoip.py | 1 + authentik/events/context_processors/mmdb.py | 1 + authentik/events/middleware.py | 1 + authentik/events/models.py | 1 + authentik/events/settings.py | 1 + authentik/events/signals.py | 1 + authentik/events/system_tasks.py | 1 + authentik/events/tasks.py | 1 + authentik/events/tests/test_api.py | 1 + authentik/events/tests/test_enrich_asn.py | 1 + authentik/events/tests/test_enrich_geoip.py | 1 + authentik/events/tests/test_event.py | 1 + authentik/events/tests/test_tasks.py | 1 + authentik/events/tests/test_transports.py | 1 + authentik/events/urls.py | 1 + authentik/events/utils.py | 1 + authentik/flows/api/bindings.py | 1 + authentik/flows/api/flows.py | 2 ++ authentik/flows/api/flows_diagram.py | 1 + authentik/flows/api/stages.py | 1 + authentik/flows/apps.py | 1 + authentik/flows/challenge.py | 1 + authentik/flows/exceptions.py | 1 + .../flows/management/commands/benchmark.py | 1 + authentik/flows/markers.py | 1 + authentik/flows/models.py | 1 + authentik/flows/planner.py | 1 + authentik/flows/signals.py | 1 + authentik/flows/stage.py | 1 + authentik/flows/tests/__init__.py | 1 + authentik/flows/tests/test_api.py | 1 + authentik/flows/tests/test_challenges.py | 1 + authentik/flows/tests/test_executor.py | 1 + authentik/flows/tests/test_planner.py | 1 + authentik/flows/tests/test_stage_model.py | 1 + authentik/flows/tests/test_stage_views.py | 1 + authentik/flows/tests/test_views_helper.py | 1 + authentik/flows/urls.py | 1 + authentik/flows/views/executor.py | 35 +++++++++++-------- authentik/flows/views/inspector.py | 1 + authentik/lib/avatars.py | 1 + authentik/lib/config.py | 1 + authentik/lib/expression/evaluator.py | 1 + authentik/lib/generators.py | 1 + authentik/lib/logging.py | 1 + authentik/lib/merge.py | 1 + authentik/lib/migrations.py | 1 + authentik/lib/models.py | 1 + authentik/lib/sentry.py | 1 + authentik/lib/tests/test_config.py | 1 + authentik/lib/tests/test_evaluator.py | 1 + authentik/lib/tests/test_http.py | 1 + authentik/lib/tests/test_sentry.py | 1 + authentik/lib/tests/test_serializer_model.py | 1 + authentik/lib/tests/test_utils_time.py | 1 + authentik/lib/tests/utils.py | 1 + authentik/lib/utils/errors.py | 1 + authentik/lib/utils/file.py | 1 + authentik/lib/utils/http.py | 1 + authentik/lib/utils/reflection.py | 1 + authentik/lib/utils/time.py | 1 + authentik/lib/utils/urls.py | 1 + authentik/lib/validators.py | 1 + authentik/lib/views.py | 1 + authentik/lib/xml.py | 1 + authentik/outposts/api/outposts.py | 1 + authentik/outposts/api/service_connections.py | 1 + authentik/outposts/apps.py | 1 + authentik/outposts/consumer.py | 1 + authentik/outposts/controllers/base.py | 1 + authentik/outposts/controllers/docker.py | 1 + authentik/outposts/controllers/k8s/base.py | 1 + .../outposts/controllers/k8s/deployment.py | 1 + authentik/outposts/controllers/k8s/secret.py | 1 + authentik/outposts/controllers/k8s/service.py | 1 + .../controllers/k8s/service_monitor.py | 1 + .../outposts/controllers/k8s/triggers.py | 1 + authentik/outposts/controllers/k8s/utils.py | 1 + authentik/outposts/controllers/kubernetes.py | 1 + authentik/outposts/docker_ssh.py | 1 + authentik/outposts/docker_tls.py | 1 + authentik/outposts/models.py | 1 + authentik/outposts/settings.py | 1 + authentik/outposts/signals.py | 1 + authentik/outposts/tasks.py | 1 + authentik/outposts/tests/test_api.py | 1 + authentik/outposts/tests/test_commands.py | 1 + .../outposts/tests/test_controller_docker.py | 1 + authentik/outposts/tests/test_sa.py | 1 + authentik/outposts/tests/test_ws.py | 1 + authentik/outposts/urls.py | 1 + authentik/policies/api/bindings.py | 1 + authentik/policies/api/exec.py | 1 + authentik/policies/api/policies.py | 1 + authentik/policies/apps.py | 1 + authentik/policies/denied.py | 1 + authentik/policies/dummy/api.py | 1 + authentik/policies/dummy/models.py | 1 + authentik/policies/dummy/tests.py | 1 + authentik/policies/dummy/urls.py | 1 + authentik/policies/engine.py | 1 + authentik/policies/event_matcher/api.py | 1 + authentik/policies/event_matcher/models.py | 1 + authentik/policies/event_matcher/tests.py | 1 + authentik/policies/event_matcher/urls.py | 1 + authentik/policies/exceptions.py | 1 + authentik/policies/expiry/api.py | 1 + authentik/policies/expiry/models.py | 1 + authentik/policies/expiry/urls.py | 1 + authentik/policies/expression/api.py | 1 + authentik/policies/expression/evaluator.py | 1 + authentik/policies/expression/models.py | 1 + authentik/policies/expression/tests.py | 1 + authentik/policies/expression/urls.py | 1 + authentik/policies/models.py | 1 + authentik/policies/password/api.py | 1 + authentik/policies/password/models.py | 1 + .../policies/password/tests/test_flows.py | 1 + .../policies/password/tests/test_hibp.py | 1 + .../policies/password/tests/test_policy.py | 1 + .../policies/password/tests/test_zxcvbn.py | 1 + authentik/policies/password/urls.py | 1 + authentik/policies/process.py | 1 + authentik/policies/reputation/api.py | 1 + authentik/policies/reputation/apps.py | 1 + authentik/policies/reputation/models.py | 1 + authentik/policies/reputation/settings.py | 1 + authentik/policies/reputation/signals.py | 1 + authentik/policies/reputation/tasks.py | 1 + authentik/policies/reputation/tests.py | 1 + authentik/policies/reputation/urls.py | 1 + authentik/policies/signals.py | 1 + authentik/policies/tests/test_bindings_api.py | 1 + authentik/policies/tests/test_engine.py | 1 + authentik/policies/tests/test_policies_api.py | 1 + authentik/policies/tests/test_process.py | 1 + authentik/policies/types.py | 1 + authentik/policies/urls.py | 1 + authentik/policies/utils.py | 1 + authentik/policies/views.py | 1 + authentik/providers/ldap/api.py | 1 + authentik/providers/ldap/apps.py | 1 + .../providers/ldap/controllers/docker.py | 1 + .../providers/ldap/controllers/kubernetes.py | 1 + authentik/providers/ldap/models.py | 1 + authentik/providers/ldap/tests/test_api.py | 1 + authentik/providers/ldap/urls.py | 1 + authentik/providers/oauth2/api/providers.py | 1 + authentik/providers/oauth2/api/scopes.py | 1 + authentik/providers/oauth2/api/tokens.py | 1 + authentik/providers/oauth2/apps.py | 1 + authentik/providers/oauth2/errors.py | 1 + authentik/providers/oauth2/id_token.py | 1 + authentik/providers/oauth2/models.py | 1 + authentik/providers/oauth2/tests/test_api.py | 1 + .../providers/oauth2/tests/test_authorize.py | 1 + .../oauth2/tests/test_device_backchannel.py | 1 + .../oauth2/tests/test_device_init.py | 1 + .../providers/oauth2/tests/test_introspect.py | 1 + authentik/providers/oauth2/tests/test_jwks.py | 1 + .../providers/oauth2/tests/test_revoke.py | 1 + .../providers/oauth2/tests/test_token.py | 1 + .../providers/oauth2/tests/test_token_cc.py | 1 + .../oauth2/tests/test_token_cc_jwt_source.py | 1 + .../oauth2/tests/test_token_device.py | 1 + .../providers/oauth2/tests/test_token_pkce.py | 1 + .../providers/oauth2/tests/test_userinfo.py | 1 + authentik/providers/oauth2/tests/utils.py | 1 + authentik/providers/oauth2/urls.py | 1 + authentik/providers/oauth2/urls_root.py | 1 + authentik/providers/oauth2/utils.py | 7 ++-- authentik/providers/oauth2/views/authorize.py | 1 + .../oauth2/views/device_backchannel.py | 1 + .../providers/oauth2/views/device_finish.py | 1 + .../providers/oauth2/views/device_init.py | 1 + .../providers/oauth2/views/introspection.py | 1 + authentik/providers/oauth2/views/jwks.py | 1 + authentik/providers/oauth2/views/provider.py | 1 + authentik/providers/oauth2/views/token.py | 1 + .../providers/oauth2/views/token_revoke.py | 1 + authentik/providers/oauth2/views/userinfo.py | 1 + authentik/providers/proxy/api.py | 1 + authentik/providers/proxy/apps.py | 1 + .../providers/proxy/controllers/docker.py | 19 +++++----- .../proxy/controllers/k8s/ingress.py | 1 + .../proxy/controllers/k8s/traefik.py | 1 + .../proxy/controllers/k8s/traefik_2.py | 1 + .../proxy/controllers/k8s/traefik_3.py | 1 + .../providers/proxy/controllers/kubernetes.py | 7 ++-- authentik/providers/proxy/models.py | 1 + authentik/providers/proxy/signals.py | 1 + authentik/providers/proxy/tasks.py | 1 + authentik/providers/proxy/tests.py | 1 + authentik/providers/proxy/urls.py | 1 + authentik/providers/radius/api.py | 1 + authentik/providers/radius/apps.py | 1 + .../providers/radius/controllers/docker.py | 1 + .../radius/controllers/kubernetes.py | 1 + authentik/providers/radius/models.py | 1 + authentik/providers/radius/urls.py | 1 + .../providers/saml/api/property_mapping.py | 1 + authentik/providers/saml/api/providers.py | 7 ++-- authentik/providers/saml/exceptions.py | 1 + authentik/providers/saml/models.py | 1 + .../providers/saml/processors/assertion.py | 1 + .../saml/processors/authn_request_parser.py | 1 + .../saml/processors/logout_request_parser.py | 1 + .../providers/saml/processors/metadata.py | 1 + .../saml/processors/metadata_parser.py | 1 + authentik/providers/saml/tests/test_api.py | 1 + .../saml/tests/test_auth_n_request.py | 1 + .../saml/tests/test_logout_request.py | 1 + .../providers/saml/tests/test_metadata.py | 1 + authentik/providers/saml/tests/test_schema.py | 1 + authentik/providers/saml/urls.py | 1 + authentik/providers/saml/utils/__init__.py | 1 + authentik/providers/saml/utils/encoding.py | 1 + authentik/providers/saml/utils/time.py | 1 + authentik/providers/saml/views/flows.py | 1 + authentik/providers/saml/views/metadata.py | 1 + authentik/providers/saml/views/slo.py | 1 + authentik/providers/saml/views/sso.py | 1 + .../providers/scim/api/property_mapping.py | 1 + authentik/providers/scim/api/providers.py | 1 + authentik/providers/scim/apps.py | 1 + authentik/providers/scim/clients/__init__.py | 1 + authentik/providers/scim/clients/base.py | 1 + .../providers/scim/clients/exceptions.py | 1 + authentik/providers/scim/clients/group.py | 1 + authentik/providers/scim/clients/schema.py | 1 + authentik/providers/scim/clients/user.py | 1 + .../scim/management/commands/scim_sync.py | 1 + authentik/providers/scim/models.py | 1 + authentik/providers/scim/settings.py | 1 + authentik/providers/scim/signals.py | 1 + authentik/providers/scim/tasks.py | 1 + authentik/providers/scim/tests/test_client.py | 1 + authentik/providers/scim/tests/test_group.py | 1 + .../providers/scim/tests/test_membership.py | 1 + authentik/providers/scim/tests/test_user.py | 1 + authentik/providers/scim/urls.py | 1 + authentik/rbac/api/rbac.py | 1 + authentik/rbac/api/rbac_assigned_by_roles.py | 1 + authentik/rbac/api/rbac_assigned_by_users.py | 1 + authentik/rbac/api/rbac_roles.py | 1 + authentik/rbac/api/rbac_users.py | 1 + authentik/rbac/api/roles.py | 1 + authentik/rbac/apps.py | 1 + authentik/rbac/filters.py | 1 + authentik/rbac/models.py | 1 + authentik/rbac/permissions.py | 1 + authentik/rbac/signals.py | 1 + .../rbac/tests/test_api_assigned_by_roles.py | 1 + .../rbac/tests/test_api_assigned_by_users.py | 1 + authentik/rbac/tests/test_api_filters.py | 1 + authentik/rbac/tests/test_roles.py | 1 + authentik/rbac/urls.py | 1 + authentik/recovery/apps.py | 1 + authentik/recovery/lib.py | 1 + .../management/commands/create_admin_group.py | 1 + .../commands/create_recovery_key.py | 1 + authentik/recovery/tests.py | 1 + authentik/recovery/views.py | 1 + authentik/root/asgi.py | 1 + authentik/root/asgi_middleware.py | 1 + authentik/root/celery.py | 1 + authentik/root/db/base.py | 1 + authentik/root/install_id.py | 1 + authentik/root/messages/consumer.py | 1 + authentik/root/messages/storage.py | 1 + authentik/root/middleware.py | 1 + authentik/root/monitoring.py | 1 + authentik/root/sessions/pickle.py | 1 + authentik/root/settings.py | 7 ++-- authentik/root/storages.py | 1 + authentik/root/test_runner.py | 1 + authentik/root/tests.py | 1 + authentik/root/urls.py | 1 + authentik/root/websocket.py | 1 + authentik/sources/ldap/api.py | 1 + authentik/sources/ldap/apps.py | 1 + authentik/sources/ldap/auth.py | 1 + .../commands/ldap_check_connection.py | 1 + .../ldap/management/commands/ldap_sync.py | 1 + authentik/sources/ldap/models.py | 1 + authentik/sources/ldap/password.py | 1 + authentik/sources/ldap/settings.py | 1 + authentik/sources/ldap/signals.py | 1 + authentik/sources/ldap/sync/base.py | 1 + authentik/sources/ldap/sync/groups.py | 1 + authentik/sources/ldap/sync/membership.py | 1 + authentik/sources/ldap/sync/users.py | 1 + authentik/sources/ldap/sync/vendor/freeipa.py | 1 + authentik/sources/ldap/sync/vendor/ms_ad.py | 1 + authentik/sources/ldap/tasks.py | 1 + authentik/sources/ldap/tests/test_api.py | 1 + authentik/sources/ldap/tests/test_auth.py | 1 + authentik/sources/ldap/tests/test_password.py | 1 + authentik/sources/ldap/tests/test_sync.py | 1 + authentik/sources/ldap/urls.py | 1 + authentik/sources/oauth/api/source.py | 1 + .../sources/oauth/api/source_connection.py | 1 + authentik/sources/oauth/apps.py | 1 + authentik/sources/oauth/clients/base.py | 1 + authentik/sources/oauth/clients/oauth1.py | 1 + authentik/sources/oauth/clients/oauth2.py | 1 + authentik/sources/oauth/exceptions.py | 1 + authentik/sources/oauth/models.py | 1 + authentik/sources/oauth/settings.py | 1 + authentik/sources/oauth/tasks.py | 1 + authentik/sources/oauth/tests/test_tasks.py | 1 + .../sources/oauth/tests/test_type_azure_ad.py | 1 + .../sources/oauth/tests/test_type_discord.py | 1 + .../sources/oauth/tests/test_type_github.py | 1 + .../sources/oauth/tests/test_type_google.py | 1 + .../sources/oauth/tests/test_type_mailcow.py | 1 + .../sources/oauth/tests/test_type_openid.py | 1 + .../sources/oauth/tests/test_type_patreon.py | 1 + .../sources/oauth/tests/test_type_twitch.py | 1 + .../sources/oauth/tests/test_type_twitter.py | 1 + authentik/sources/oauth/tests/test_views.py | 1 + authentik/sources/oauth/types/apple.py | 1 + authentik/sources/oauth/types/azure_ad.py | 1 + authentik/sources/oauth/types/discord.py | 1 + authentik/sources/oauth/types/facebook.py | 1 + authentik/sources/oauth/types/github.py | 1 + authentik/sources/oauth/types/google.py | 1 + authentik/sources/oauth/types/mailcow.py | 1 + authentik/sources/oauth/types/oidc.py | 1 + authentik/sources/oauth/types/okta.py | 1 + authentik/sources/oauth/types/patreon.py | 1 + authentik/sources/oauth/types/reddit.py | 1 + authentik/sources/oauth/types/registry.py | 1 + authentik/sources/oauth/types/twitch.py | 1 + authentik/sources/oauth/types/twitter.py | 1 + authentik/sources/oauth/views/base.py | 1 + authentik/sources/oauth/views/callback.py | 1 + authentik/sources/oauth/views/dispatcher.py | 1 + authentik/sources/oauth/views/redirect.py | 1 + authentik/sources/plex/api/source.py | 1 + .../sources/plex/api/source_connection.py | 1 + authentik/sources/plex/apps.py | 1 + authentik/sources/plex/models.py | 1 + authentik/sources/plex/plex.py | 1 + authentik/sources/plex/settings.py | 1 + authentik/sources/plex/tasks.py | 1 + authentik/sources/plex/tests.py | 1 + authentik/sources/plex/urls.py | 1 + authentik/sources/saml/api/source.py | 1 + .../sources/saml/api/source_connection.py | 1 + authentik/sources/saml/apps.py | 1 + authentik/sources/saml/exceptions.py | 1 + authentik/sources/saml/models.py | 1 + .../sources/saml/processors/constants.py | 1 + authentik/sources/saml/processors/metadata.py | 7 ++-- authentik/sources/saml/processors/request.py | 1 + authentik/sources/saml/processors/response.py | 1 + authentik/sources/saml/signals.py | 1 + authentik/sources/saml/tests/test_metadata.py | 1 + authentik/sources/saml/tests/test_response.py | 1 + authentik/sources/saml/urls.py | 1 + authentik/sources/saml/views.py | 1 + authentik/stages/authenticator/__init__.py | 1 + authentik/stages/authenticator/apps.py | 1 + authentik/stages/authenticator/models.py | 1 + authentik/stages/authenticator/oath.py | 1 + authentik/stages/authenticator/tests.py | 1 + authentik/stages/authenticator/util.py | 1 + authentik/stages/authenticator_duo/api.py | 1 + authentik/stages/authenticator_duo/models.py | 1 + authentik/stages/authenticator_duo/stage.py | 1 + authentik/stages/authenticator_duo/tasks.py | 1 + authentik/stages/authenticator_duo/tests.py | 1 + authentik/stages/authenticator_duo/urls.py | 1 + authentik/stages/authenticator_sms/api.py | 1 + authentik/stages/authenticator_sms/apps.py | 1 + authentik/stages/authenticator_sms/models.py | 1 + authentik/stages/authenticator_sms/stage.py | 1 + authentik/stages/authenticator_sms/tests.py | 1 + authentik/stages/authenticator_sms/urls.py | 1 + authentik/stages/authenticator_static/api.py | 1 + authentik/stages/authenticator_static/apps.py | 1 + .../stages/authenticator_static/models.py | 1 + .../stages/authenticator_static/signals.py | 1 + .../stages/authenticator_static/stage.py | 1 + .../stages/authenticator_static/tests.py | 1 + authentik/stages/authenticator_static/urls.py | 1 + authentik/stages/authenticator_totp/api.py | 1 + authentik/stages/authenticator_totp/apps.py | 1 + authentik/stages/authenticator_totp/models.py | 1 + authentik/stages/authenticator_totp/stage.py | 1 + authentik/stages/authenticator_totp/tests.py | 1 + authentik/stages/authenticator_totp/urls.py | 1 + .../stages/authenticator_validate/api.py | 1 + .../stages/authenticator_validate/apps.py | 1 + .../authenticator_validate/challenge.py | 1 + .../stages/authenticator_validate/stage.py | 1 + .../authenticator_validate/tests/test_duo.py | 1 + .../authenticator_validate/tests/test_sms.py | 1 + .../tests/test_stage.py | 1 + .../authenticator_validate/tests/test_totp.py | 1 + .../tests/test_webauthn.py | 1 + .../stages/authenticator_validate/urls.py | 1 + .../stages/authenticator_webauthn/api.py | 1 + .../stages/authenticator_webauthn/apps.py | 1 + .../stages/authenticator_webauthn/models.py | 1 + .../stages/authenticator_webauthn/stage.py | 1 + .../stages/authenticator_webauthn/tests.py | 1 + .../stages/authenticator_webauthn/urls.py | 1 + authentik/stages/captcha/api.py | 1 + authentik/stages/captcha/apps.py | 1 + authentik/stages/captcha/tests.py | 1 + authentik/stages/captcha/urls.py | 1 + authentik/stages/consent/api.py | 1 + authentik/stages/consent/apps.py | 1 + authentik/stages/consent/stage.py | 1 + authentik/stages/consent/tests.py | 1 + authentik/stages/consent/urls.py | 1 + authentik/stages/deny/api.py | 1 + authentik/stages/deny/apps.py | 1 + authentik/stages/deny/models.py | 1 + authentik/stages/deny/stage.py | 1 + authentik/stages/deny/tests.py | 1 + authentik/stages/deny/urls.py | 1 + authentik/stages/dummy/api.py | 1 + authentik/stages/dummy/models.py | 1 + authentik/stages/dummy/stage.py | 1 + authentik/stages/dummy/tests.py | 1 + authentik/stages/dummy/urls.py | 1 + authentik/stages/email/api.py | 1 + authentik/stages/email/apps.py | 1 + .../email/management/commands/test_email.py | 1 + authentik/stages/email/models.py | 1 + authentik/stages/email/stage.py | 1 + authentik/stages/email/tasks.py | 1 + .../templatetags/authentik_stages_email.py | 1 + authentik/stages/email/tests/test_api.py | 1 + authentik/stages/email/tests/test_sending.py | 1 + authentik/stages/email/tests/test_stage.py | 1 + .../stages/email/tests/test_templates.py | 1 + authentik/stages/email/urls.py | 1 + authentik/stages/email/utils.py | 1 + authentik/stages/identification/api.py | 1 + authentik/stages/identification/apps.py | 1 + authentik/stages/identification/signals.py | 1 + authentik/stages/identification/stage.py | 7 ++-- authentik/stages/identification/tests.py | 1 + authentik/stages/identification/urls.py | 1 + authentik/stages/invitation/api.py | 1 + authentik/stages/invitation/apps.py | 1 + authentik/stages/invitation/models.py | 1 + authentik/stages/invitation/signals.py | 1 + authentik/stages/invitation/stage.py | 1 + authentik/stages/invitation/tests.py | 1 + authentik/stages/invitation/urls.py | 1 + authentik/stages/password/__init__.py | 1 + authentik/stages/password/api.py | 1 + authentik/stages/password/apps.py | 1 + authentik/stages/password/models.py | 1 + authentik/stages/password/stage.py | 1 + authentik/stages/password/tests.py | 1 + authentik/stages/password/urls.py | 1 + authentik/stages/prompt/api.py | 1 + authentik/stages/prompt/apps.py | 1 + authentik/stages/prompt/models.py | 1 + authentik/stages/prompt/signals.py | 1 + authentik/stages/prompt/stage.py | 1 + authentik/stages/prompt/tests.py | 1 + authentik/stages/prompt/urls.py | 1 + authentik/stages/user_delete/api.py | 1 + authentik/stages/user_delete/apps.py | 1 + authentik/stages/user_delete/stage.py | 1 + authentik/stages/user_delete/tests.py | 1 + authentik/stages/user_delete/urls.py | 1 + authentik/stages/user_login/api.py | 1 + authentik/stages/user_login/apps.py | 1 + authentik/stages/user_login/middleware.py | 1 + authentik/stages/user_login/stage.py | 1 + authentik/stages/user_login/tests.py | 1 + authentik/stages/user_login/urls.py | 1 + authentik/stages/user_logout/api.py | 1 + authentik/stages/user_logout/apps.py | 1 + authentik/stages/user_logout/stage.py | 1 + authentik/stages/user_logout/tests.py | 1 + authentik/stages/user_logout/urls.py | 1 + authentik/stages/user_write/api.py | 1 + authentik/stages/user_write/apps.py | 1 + authentik/stages/user_write/signals.py | 1 + authentik/stages/user_write/stage.py | 1 + authentik/stages/user_write/tests.py | 1 + authentik/stages/user_write/urls.py | 1 + authentik/tenants/api/domains.py | 1 + authentik/tenants/api/settings.py | 1 + authentik/tenants/api/tenants.py | 1 + authentik/tenants/apps.py | 1 + authentik/tenants/checks.py | 1 + authentik/tenants/management/__init__.py | 1 + authentik/tenants/models.py | 1 + authentik/tenants/scheduler.py | 1 + authentik/tenants/tests/test_api.py | 1 + authentik/tenants/tests/test_domain.py | 1 + .../tenants/tests/test_event_retention.py | 1 + authentik/tenants/tests/test_recovery.py | 1 + authentik/tenants/urls.py | 1 + authentik/tenants/utils.py | 4 +-- lifecycle/ak.py | 1 + lifecycle/gunicorn.conf.py | 1 + lifecycle/worker.py | 1 + scripts/generate_config.py | 1 + scripts/npm_version.py | 1 + tests/e2e/test_flows_authenticators.py | 1 + tests/e2e/test_flows_enroll.py | 1 + tests/e2e/test_flows_login.py | 1 + tests/e2e/test_flows_recovery.py | 1 + tests/e2e/test_flows_stage_setup.py | 1 + tests/e2e/test_provider_ldap.py | 1 + tests/e2e/test_provider_oauth2_github.py | 1 + tests/e2e/test_provider_oauth2_grafana.py | 1 + tests/e2e/test_provider_oidc.py | 1 + tests/e2e/test_provider_oidc_implicit.py | 1 + tests/e2e/test_provider_proxy.py | 1 + tests/e2e/test_provider_radius.py | 1 + tests/e2e/test_provider_saml.py | 1 + tests/e2e/test_source_ldap_samba.py | 1 + tests/e2e/test_source_oauth_oauth1.py | 1 + tests/e2e/test_source_oauth_oauth2.py | 1 + tests/e2e/test_source_saml.py | 1 + tests/e2e/utils.py | 1 + tests/integration/test_outpost_docker.py | 1 + tests/integration/test_outpost_kubernetes.py | 1 + tests/integration/test_proxy_docker.py | 1 + tests/integration/test_proxy_kubernetes.py | 1 + web/package-lock.json | 8 ++--- web/package.json | 2 +- 687 files changed, 744 insertions(+), 55 deletions(-) diff --git a/authentik/__init__.py b/authentik/__init__.py index 05ba8ec88a..85e51066b7 100644 --- a/authentik/__init__.py +++ b/authentik/__init__.py @@ -1,4 +1,5 @@ """authentik root module""" + from os import environ from typing import Optional diff --git a/authentik/admin/api/meta.py b/authentik/admin/api/meta.py index 52640b8c50..bdece26f5c 100644 --- a/authentik/admin/api/meta.py +++ b/authentik/admin/api/meta.py @@ -1,4 +1,5 @@ """Meta API""" + from drf_spectacular.utils import extend_schema from rest_framework.fields import CharField from rest_framework.permissions import IsAuthenticated diff --git a/authentik/admin/api/metrics.py b/authentik/admin/api/metrics.py index af32662b17..6929767ecf 100644 --- a/authentik/admin/api/metrics.py +++ b/authentik/admin/api/metrics.py @@ -1,4 +1,5 @@ """authentik administration metrics""" + from datetime import timedelta from django.db.models.functions import ExtractHour diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index 16637067a2..442771c218 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -1,4 +1,5 @@ """authentik administration overview""" + import platform from datetime import datetime from sys import version as python_version diff --git a/authentik/admin/api/version.py b/authentik/admin/api/version.py index e0cc2c5b48..855a5016d7 100644 --- a/authentik/admin/api/version.py +++ b/authentik/admin/api/version.py @@ -1,4 +1,5 @@ """authentik administration overview""" + from django.core.cache import cache from drf_spectacular.utils import extend_schema from packaging.version import parse diff --git a/authentik/admin/api/workers.py b/authentik/admin/api/workers.py index 3b5da05948..86578a50eb 100644 --- a/authentik/admin/api/workers.py +++ b/authentik/admin/api/workers.py @@ -1,4 +1,5 @@ """authentik administration overview""" + from django.conf import settings from drf_spectacular.utils import extend_schema, inline_serializer from rest_framework.fields import IntegerField diff --git a/authentik/admin/apps.py b/authentik/admin/apps.py index 6cc7ba8655..91d087365b 100644 --- a/authentik/admin/apps.py +++ b/authentik/admin/apps.py @@ -1,4 +1,5 @@ """authentik admin app config""" + from prometheus_client import Gauge, Info from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/admin/settings.py b/authentik/admin/settings.py index 37b9d8bda1..7c5b561ff0 100644 --- a/authentik/admin/settings.py +++ b/authentik/admin/settings.py @@ -1,4 +1,5 @@ """authentik admin settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/admin/signals.py b/authentik/admin/signals.py index aa081724b5..6bd906972c 100644 --- a/authentik/admin/signals.py +++ b/authentik/admin/signals.py @@ -1,4 +1,5 @@ """admin signals""" + from django.dispatch import receiver from authentik.admin.apps import GAUGE_WORKERS diff --git a/authentik/admin/tasks.py b/authentik/admin/tasks.py index 6a75f51c91..f5aeff028b 100644 --- a/authentik/admin/tasks.py +++ b/authentik/admin/tasks.py @@ -1,4 +1,5 @@ """authentik admin tasks""" + import re from django.core.cache import cache diff --git a/authentik/admin/tests/test_api.py b/authentik/admin/tests/test_api.py index f7bd03ff5c..8d7d5eb44a 100644 --- a/authentik/admin/tests/test_api.py +++ b/authentik/admin/tests/test_api.py @@ -1,4 +1,5 @@ """test admin api""" + from json import loads from django.test import TestCase diff --git a/authentik/admin/tests/test_tasks.py b/authentik/admin/tests/test_tasks.py index b6720623e5..0ea3457f61 100644 --- a/authentik/admin/tests/test_tasks.py +++ b/authentik/admin/tests/test_tasks.py @@ -1,4 +1,5 @@ """test admin tasks""" + from django.core.cache import cache from django.test import TestCase from requests_mock import Mocker diff --git a/authentik/admin/urls.py b/authentik/admin/urls.py index 6ef21e93e9..2be8af5756 100644 --- a/authentik/admin/urls.py +++ b/authentik/admin/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from django.urls import path from authentik.admin.api.meta import AppsViewSet, ModelViewSet diff --git a/authentik/api/authentication.py b/authentik/api/authentication.py index 8aa402384f..04edc73580 100644 --- a/authentik/api/authentication.py +++ b/authentik/api/authentication.py @@ -1,4 +1,5 @@ """API Authentication""" + from hmac import compare_digest from typing import Any, Optional diff --git a/authentik/api/authorization.py b/authentik/api/authorization.py index e3ae48e5c6..a79cb1803f 100644 --- a/authentik/api/authorization.py +++ b/authentik/api/authorization.py @@ -1,4 +1,5 @@ """API Authorization""" + from django.conf import settings from django.db.models import Model from django.db.models.query import QuerySet diff --git a/authentik/api/decorators.py b/authentik/api/decorators.py index 0cd737c76d..3d5f343a94 100644 --- a/authentik/api/decorators.py +++ b/authentik/api/decorators.py @@ -1,4 +1,5 @@ """API Decorators""" + from functools import wraps from typing import Callable, Optional diff --git a/authentik/api/pagination.py b/authentik/api/pagination.py index 402dbac9b7..a49a6811b0 100644 --- a/authentik/api/pagination.py +++ b/authentik/api/pagination.py @@ -1,4 +1,5 @@ """Pagination which includes total pages and current page""" + from rest_framework import pagination from rest_framework.response import Response diff --git a/authentik/api/schema.py b/authentik/api/schema.py index e70caaf3e1..0f5f36b92d 100644 --- a/authentik/api/schema.py +++ b/authentik/api/schema.py @@ -1,4 +1,5 @@ """Error Response schema, from https://github.com/axnsan12/drf-yasg/issues/224""" + from django.utils.translation import gettext_lazy as _ from drf_spectacular.generators import SchemaGenerator from drf_spectacular.plumbing import ( diff --git a/authentik/api/tests/test_auth.py b/authentik/api/tests/test_auth.py index c09bca5a32..7978236a40 100644 --- a/authentik/api/tests/test_auth.py +++ b/authentik/api/tests/test_auth.py @@ -1,4 +1,5 @@ """Test API Authentication""" + import json from base64 import b64encode diff --git a/authentik/api/tests/test_config.py b/authentik/api/tests/test_config.py index 6f6f60f319..afee3fa177 100644 --- a/authentik/api/tests/test_config.py +++ b/authentik/api/tests/test_config.py @@ -1,4 +1,5 @@ """Test config API""" + from json import loads from django.urls import reverse diff --git a/authentik/api/tests/test_decorators.py b/authentik/api/tests/test_decorators.py index 2370683564..6ae200bfb2 100644 --- a/authentik/api/tests/test_decorators.py +++ b/authentik/api/tests/test_decorators.py @@ -1,4 +1,5 @@ """test decorators api""" + from django.urls import reverse from guardian.shortcuts import assign_perm from rest_framework.test import APITestCase diff --git a/authentik/api/tests/test_schema.py b/authentik/api/tests/test_schema.py index d86597d964..e33a31f9df 100644 --- a/authentik/api/tests/test_schema.py +++ b/authentik/api/tests/test_schema.py @@ -1,4 +1,5 @@ """Schema generation tests""" + from django.urls import reverse from rest_framework.test import APITestCase from yaml import safe_load diff --git a/authentik/api/tests/test_viewsets.py b/authentik/api/tests/test_viewsets.py index ac3d7da62d..08cc457c49 100644 --- a/authentik/api/tests/test_viewsets.py +++ b/authentik/api/tests/test_viewsets.py @@ -1,4 +1,5 @@ """authentik API Modelviewset tests""" + from typing import Callable from django.test import TestCase diff --git a/authentik/api/urls.py b/authentik/api/urls.py index 461fe5b94a..43b8827719 100644 --- a/authentik/api/urls.py +++ b/authentik/api/urls.py @@ -1,4 +1,5 @@ """authentik api urls""" + from django.urls import include, path from authentik.api.v3.urls import urlpatterns as v3_urls diff --git a/authentik/api/v3/config.py b/authentik/api/v3/config.py index 49493234bc..fd1f80cff4 100644 --- a/authentik/api/v3/config.py +++ b/authentik/api/v3/config.py @@ -1,4 +1,5 @@ """core Configs API""" + from pathlib import Path from django.conf import settings diff --git a/authentik/api/v3/urls.py b/authentik/api/v3/urls.py index a7e610efac..e56b8510bd 100644 --- a/authentik/api/v3/urls.py +++ b/authentik/api/v3/urls.py @@ -1,4 +1,5 @@ """api v3 urls""" + from importlib import import_module from django.urls import path diff --git a/authentik/api/views.py b/authentik/api/views.py index 36193ed170..1e3f9eb242 100644 --- a/authentik/api/views.py +++ b/authentik/api/views.py @@ -1,4 +1,5 @@ """General API Views""" + from typing import Any from django.urls import reverse diff --git a/authentik/blueprints/api.py b/authentik/blueprints/api.py index 7abf488dae..4b2f2664dc 100644 --- a/authentik/blueprints/api.py +++ b/authentik/blueprints/api.py @@ -1,4 +1,5 @@ """Serializer mixin for managed models""" + from django.utils.translation import gettext_lazy as _ from drf_spectacular.utils import extend_schema, inline_serializer from rest_framework.decorators import action diff --git a/authentik/blueprints/management/commands/apply_blueprint.py b/authentik/blueprints/management/commands/apply_blueprint.py index adc76c207c..698ff4b5c0 100644 --- a/authentik/blueprints/management/commands/apply_blueprint.py +++ b/authentik/blueprints/management/commands/apply_blueprint.py @@ -1,4 +1,5 @@ """Apply blueprint from commandline""" + from sys import exit as sys_exit from django.core.management.base import BaseCommand, no_translations diff --git a/authentik/blueprints/management/commands/export_blueprint.py b/authentik/blueprints/management/commands/export_blueprint.py index a7a0ccdf83..c8371595e2 100644 --- a/authentik/blueprints/management/commands/export_blueprint.py +++ b/authentik/blueprints/management/commands/export_blueprint.py @@ -1,4 +1,5 @@ """Export blueprint of current authentik install""" + from django.core.management.base import no_translations from structlog.stdlib import get_logger diff --git a/authentik/blueprints/management/commands/make_blueprint_schema.py b/authentik/blueprints/management/commands/make_blueprint_schema.py index f75b6ab0bc..f109f22bad 100644 --- a/authentik/blueprints/management/commands/make_blueprint_schema.py +++ b/authentik/blueprints/management/commands/make_blueprint_schema.py @@ -1,4 +1,5 @@ """Generate JSON Schema for blueprints""" + from json import dumps from typing import Any diff --git a/authentik/blueprints/models.py b/authentik/blueprints/models.py index 2551beacc2..f1679866ee 100644 --- a/authentik/blueprints/models.py +++ b/authentik/blueprints/models.py @@ -1,4 +1,5 @@ """blueprint models""" + from pathlib import Path from uuid import uuid4 diff --git a/authentik/blueprints/settings.py b/authentik/blueprints/settings.py index c9ce11057c..da0029d678 100644 --- a/authentik/blueprints/settings.py +++ b/authentik/blueprints/settings.py @@ -1,4 +1,5 @@ """blueprint Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/blueprints/tests/__init__.py b/authentik/blueprints/tests/__init__.py index e407db13a8..ab8e780310 100644 --- a/authentik/blueprints/tests/__init__.py +++ b/authentik/blueprints/tests/__init__.py @@ -1,4 +1,5 @@ """Blueprint helpers""" + from functools import wraps from typing import Callable diff --git a/authentik/blueprints/tests/test_models.py b/authentik/blueprints/tests/test_models.py index 2c04b64ef0..a2ceac828b 100644 --- a/authentik/blueprints/tests/test_models.py +++ b/authentik/blueprints/tests/test_models.py @@ -1,4 +1,5 @@ """authentik managed models tests""" + from django.test import TestCase from authentik.blueprints.models import BlueprintInstance, BlueprintRetrievalFailed diff --git a/authentik/blueprints/tests/test_oci.py b/authentik/blueprints/tests/test_oci.py index 963e3797ff..71b0d34807 100644 --- a/authentik/blueprints/tests/test_oci.py +++ b/authentik/blueprints/tests/test_oci.py @@ -1,4 +1,5 @@ """Test blueprints OCI""" + from django.test import TransactionTestCase from requests_mock import Mocker diff --git a/authentik/blueprints/tests/test_packaged.py b/authentik/blueprints/tests/test_packaged.py index e94c750172..9e1111c321 100644 --- a/authentik/blueprints/tests/test_packaged.py +++ b/authentik/blueprints/tests/test_packaged.py @@ -1,4 +1,5 @@ """test packaged blueprints""" + from pathlib import Path from typing import Callable diff --git a/authentik/blueprints/tests/test_serializer_models.py b/authentik/blueprints/tests/test_serializer_models.py index 78dc553483..8bff9994ed 100644 --- a/authentik/blueprints/tests/test_serializer_models.py +++ b/authentik/blueprints/tests/test_serializer_models.py @@ -1,4 +1,5 @@ """authentik managed models tests""" + from typing import Callable, Type from django.apps import apps diff --git a/authentik/blueprints/tests/test_v1.py b/authentik/blueprints/tests/test_v1.py index f7f53f780d..5f85e69477 100644 --- a/authentik/blueprints/tests/test_v1.py +++ b/authentik/blueprints/tests/test_v1.py @@ -1,4 +1,5 @@ """Test blueprints v1""" + from os import environ from django.test import TransactionTestCase diff --git a/authentik/blueprints/tests/test_v1_api.py b/authentik/blueprints/tests/test_v1_api.py index 6ee4bd7f6a..681260d690 100644 --- a/authentik/blueprints/tests/test_v1_api.py +++ b/authentik/blueprints/tests/test_v1_api.py @@ -1,4 +1,5 @@ """Test blueprints v1 api""" + from json import loads from tempfile import NamedTemporaryFile, mkdtemp diff --git a/authentik/blueprints/tests/test_v1_conditional_fields.py b/authentik/blueprints/tests/test_v1_conditional_fields.py index 4b7cb45915..d260e9599b 100644 --- a/authentik/blueprints/tests/test_v1_conditional_fields.py +++ b/authentik/blueprints/tests/test_v1_conditional_fields.py @@ -1,4 +1,5 @@ """Test blueprints v1""" + from django.test import TransactionTestCase from authentik.blueprints.v1.importer import Importer diff --git a/authentik/blueprints/tests/test_v1_conditions.py b/authentik/blueprints/tests/test_v1_conditions.py index dd633a22a6..8dd79563e1 100644 --- a/authentik/blueprints/tests/test_v1_conditions.py +++ b/authentik/blueprints/tests/test_v1_conditions.py @@ -1,4 +1,5 @@ """Test blueprints v1""" + from django.test import TransactionTestCase from authentik.blueprints.v1.importer import Importer diff --git a/authentik/blueprints/tests/test_v1_state.py b/authentik/blueprints/tests/test_v1_state.py index ad12c239c8..96a2d0f602 100644 --- a/authentik/blueprints/tests/test_v1_state.py +++ b/authentik/blueprints/tests/test_v1_state.py @@ -1,4 +1,5 @@ """Test blueprints v1""" + from django.test import TransactionTestCase from authentik.blueprints.v1.importer import Importer diff --git a/authentik/blueprints/tests/test_v1_tasks.py b/authentik/blueprints/tests/test_v1_tasks.py index 913431d66b..fefdb62e25 100644 --- a/authentik/blueprints/tests/test_v1_tasks.py +++ b/authentik/blueprints/tests/test_v1_tasks.py @@ -1,4 +1,5 @@ """Test blueprints v1 tasks""" + from hashlib import sha512 from tempfile import NamedTemporaryFile, mkdtemp diff --git a/authentik/blueprints/urls.py b/authentik/blueprints/urls.py index 7f18c0094c..bea95598ea 100644 --- a/authentik/blueprints/urls.py +++ b/authentik/blueprints/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.blueprints.api import BlueprintInstanceViewSet api_urlpatterns = [ diff --git a/authentik/blueprints/v1/common.py b/authentik/blueprints/v1/common.py index 997fecc6f8..2199b3ebec 100644 --- a/authentik/blueprints/v1/common.py +++ b/authentik/blueprints/v1/common.py @@ -1,4 +1,5 @@ """transfer common classes""" + from collections import OrderedDict from copy import copy from dataclasses import asdict, dataclass, field, is_dataclass diff --git a/authentik/blueprints/v1/exporter.py b/authentik/blueprints/v1/exporter.py index 6d0858d498..fbe94c3b42 100644 --- a/authentik/blueprints/v1/exporter.py +++ b/authentik/blueprints/v1/exporter.py @@ -1,4 +1,5 @@ """Blueprint exporter""" + from typing import Iterable from uuid import UUID diff --git a/authentik/blueprints/v1/importer.py b/authentik/blueprints/v1/importer.py index 6a648d06a4..1e935c4d6b 100644 --- a/authentik/blueprints/v1/importer.py +++ b/authentik/blueprints/v1/importer.py @@ -1,4 +1,5 @@ """Blueprint importer""" + from contextlib import contextmanager from copy import deepcopy from typing import Any, Optional diff --git a/authentik/blueprints/v1/meta/apply_blueprint.py b/authentik/blueprints/v1/meta/apply_blueprint.py index 0a8d84e661..f3c5aa4704 100644 --- a/authentik/blueprints/v1/meta/apply_blueprint.py +++ b/authentik/blueprints/v1/meta/apply_blueprint.py @@ -1,4 +1,5 @@ """Apply Blueprint meta model""" + from typing import TYPE_CHECKING from rest_framework.exceptions import ValidationError diff --git a/authentik/blueprints/v1/meta/registry.py b/authentik/blueprints/v1/meta/registry.py index 70e409f9c4..588f03e806 100644 --- a/authentik/blueprints/v1/meta/registry.py +++ b/authentik/blueprints/v1/meta/registry.py @@ -1,4 +1,5 @@ """Base models""" + from django.apps import apps from django.db.models import Model from rest_framework.serializers import Serializer diff --git a/authentik/blueprints/v1/oci.py b/authentik/blueprints/v1/oci.py index d02f3fa2f0..6a22c4037f 100644 --- a/authentik/blueprints/v1/oci.py +++ b/authentik/blueprints/v1/oci.py @@ -1,4 +1,5 @@ """OCI Client""" + from typing import Any from urllib.parse import ParseResult, urlparse diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index cf3e1ca1a5..c6b78a4e83 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -1,4 +1,5 @@ """v1 blueprints tasks""" + from dataclasses import asdict, dataclass, field from hashlib import sha512 from pathlib import Path diff --git a/authentik/brands/api.py b/authentik/brands/api.py index eab725a4b3..a856cee485 100644 --- a/authentik/brands/api.py +++ b/authentik/brands/api.py @@ -1,4 +1,5 @@ """Serializer for brands models""" + from typing import Any from django.db import models diff --git a/authentik/brands/apps.py b/authentik/brands/apps.py index a116f7c4bc..43c20acc75 100644 --- a/authentik/brands/apps.py +++ b/authentik/brands/apps.py @@ -1,4 +1,5 @@ """authentik brands app""" + from django.apps import AppConfig diff --git a/authentik/brands/middleware.py b/authentik/brands/middleware.py index 744b700c9e..3bf0ea9f52 100644 --- a/authentik/brands/middleware.py +++ b/authentik/brands/middleware.py @@ -1,4 +1,5 @@ """Inject brand into current request""" + from typing import Callable from django.http.request import HttpRequest diff --git a/authentik/brands/models.py b/authentik/brands/models.py index 268aa5c26a..8d3cdc121b 100644 --- a/authentik/brands/models.py +++ b/authentik/brands/models.py @@ -1,4 +1,5 @@ """brand models""" + from uuid import uuid4 from django.db import models diff --git a/authentik/brands/tests.py b/authentik/brands/tests.py index 71f18ca4e9..712818fda1 100644 --- a/authentik/brands/tests.py +++ b/authentik/brands/tests.py @@ -1,4 +1,5 @@ """Test brands""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/brands/urls.py b/authentik/brands/urls.py index b71406d1c9..85b0ea2432 100644 --- a/authentik/brands/urls.py +++ b/authentik/brands/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.brands.api import BrandViewSet api_urlpatterns = [ diff --git a/authentik/brands/utils.py b/authentik/brands/utils.py index c77abc6dff..6e1db26a53 100644 --- a/authentik/brands/utils.py +++ b/authentik/brands/utils.py @@ -1,4 +1,5 @@ """Brand utilities""" + from typing import Any from django.db.models import F, Q diff --git a/authentik/core/api/applications.py b/authentik/core/api/applications.py index ee9ba8e3a3..bb8532e368 100644 --- a/authentik/core/api/applications.py +++ b/authentik/core/api/applications.py @@ -1,4 +1,5 @@ """Application API Views""" + from copy import copy from datetime import timedelta from typing import Optional diff --git a/authentik/core/api/authenticated_sessions.py b/authentik/core/api/authenticated_sessions.py index 2d77937be0..c9d29aabed 100644 --- a/authentik/core/api/authenticated_sessions.py +++ b/authentik/core/api/authenticated_sessions.py @@ -1,4 +1,5 @@ """AuthenticatedSessions API Viewset""" + from typing import Optional, TypedDict from django_filters.rest_framework import DjangoFilterBackend diff --git a/authentik/core/api/devices.py b/authentik/core/api/devices.py index 7773615332..528d1775f7 100644 --- a/authentik/core/api/devices.py +++ b/authentik/core/api/devices.py @@ -1,4 +1,5 @@ """Authenticator Devices API Views""" + from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema from rest_framework.fields import BooleanField, CharField, IntegerField, SerializerMethodField diff --git a/authentik/core/api/groups.py b/authentik/core/api/groups.py index 04670844d5..a184275616 100644 --- a/authentik/core/api/groups.py +++ b/authentik/core/api/groups.py @@ -1,4 +1,5 @@ """Groups API Viewset""" + from json import loads from typing import Optional diff --git a/authentik/core/api/propertymappings.py b/authentik/core/api/propertymappings.py index 1e7436be93..8382e0ac02 100644 --- a/authentik/core/api/propertymappings.py +++ b/authentik/core/api/propertymappings.py @@ -1,4 +1,5 @@ """PropertyMapping API Views""" + from json import dumps from drf_spectacular.types import OpenApiTypes diff --git a/authentik/core/api/providers.py b/authentik/core/api/providers.py index 6c0f4db061..b1716e8f2b 100644 --- a/authentik/core/api/providers.py +++ b/authentik/core/api/providers.py @@ -1,4 +1,5 @@ """Provider API Views""" + from django.db.models import QuerySet from django.db.models.query import Q from django.utils.translation import gettext_lazy as _ diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index eff2c9211d..0179b3804f 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -1,4 +1,5 @@ """Source API Views""" + from typing import Iterable from django_filters.rest_framework import DjangoFilterBackend diff --git a/authentik/core/api/tokens.py b/authentik/core/api/tokens.py index e3c2d46bf0..6ccd8aae80 100644 --- a/authentik/core/api/tokens.py +++ b/authentik/core/api/tokens.py @@ -1,4 +1,5 @@ """Tokens API Viewset""" + from typing import Any from django_filters.rest_framework import DjangoFilterBackend diff --git a/authentik/core/api/transactional_applications.py b/authentik/core/api/transactional_applications.py index 19b6ea4656..e320fae07e 100644 --- a/authentik/core/api/transactional_applications.py +++ b/authentik/core/api/transactional_applications.py @@ -1,4 +1,5 @@ """transactional application and provider creation""" + from django.apps import apps from drf_spectacular.utils import PolymorphicProxySerializer, extend_schema, extend_schema_field from rest_framework.exceptions import ValidationError diff --git a/authentik/core/api/used_by.py b/authentik/core/api/used_by.py index 3f7d4fc8a5..2aa2b07968 100644 --- a/authentik/core/api/used_by.py +++ b/authentik/core/api/used_by.py @@ -1,4 +1,5 @@ """used_by mixin""" + from enum import Enum from inspect import getmembers diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index abe7a73d70..6be7782d3f 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -1,4 +1,5 @@ """User API Views""" + from datetime import timedelta from json import loads from typing import Any, Optional diff --git a/authentik/core/api/utils.py b/authentik/core/api/utils.py index c79fec22e1..9cc3d3fc5d 100644 --- a/authentik/core/api/utils.py +++ b/authentik/core/api/utils.py @@ -1,4 +1,5 @@ """API Utilities""" + from typing import Any from django.db.models import Model diff --git a/authentik/core/apps.py b/authentik/core/apps.py index f158cd4a8f..b0b8595b6a 100644 --- a/authentik/core/apps.py +++ b/authentik/core/apps.py @@ -1,4 +1,5 @@ """authentik core app config""" + from django.conf import settings from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/core/channels.py b/authentik/core/channels.py index 722e9e03f7..3678be005b 100644 --- a/authentik/core/channels.py +++ b/authentik/core/channels.py @@ -1,4 +1,5 @@ """Channels base classes""" + from channels.db import database_sync_to_async from channels.exceptions import DenyConnection from rest_framework.exceptions import AuthenticationFailed diff --git a/authentik/core/exceptions.py b/authentik/core/exceptions.py index 7b157fc269..17679f45c3 100644 --- a/authentik/core/exceptions.py +++ b/authentik/core/exceptions.py @@ -1,4 +1,5 @@ """authentik core exceptions""" + from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/core/expression/evaluator.py b/authentik/core/expression/evaluator.py index 480caea21b..77aa890c1b 100644 --- a/authentik/core/expression/evaluator.py +++ b/authentik/core/expression/evaluator.py @@ -1,4 +1,5 @@ """Property Mapping Evaluator""" + from typing import Any, Optional from django.db.models import Model diff --git a/authentik/core/management/commands/bootstrap_tasks.py b/authentik/core/management/commands/bootstrap_tasks.py index 89258eaf4c..1038796b9a 100644 --- a/authentik/core/management/commands/bootstrap_tasks.py +++ b/authentik/core/management/commands/bootstrap_tasks.py @@ -1,4 +1,5 @@ """Run bootstrap tasks""" + from django.core.management.base import BaseCommand from django_tenants.utils import get_public_schema_name diff --git a/authentik/core/management/commands/build_source_docs.py b/authentik/core/management/commands/build_source_docs.py index 1c69d5a5f5..d7174f8bc7 100644 --- a/authentik/core/management/commands/build_source_docs.py +++ b/authentik/core/management/commands/build_source_docs.py @@ -1,4 +1,5 @@ """Build source docs""" + from pathlib import Path from django.core.management.base import BaseCommand diff --git a/authentik/core/management/commands/dev_server.py b/authentik/core/management/commands/dev_server.py index ea53167cdb..81981deff7 100644 --- a/authentik/core/management/commands/dev_server.py +++ b/authentik/core/management/commands/dev_server.py @@ -1,4 +1,5 @@ """custom runserver command""" + from daphne.management.commands.runserver import Command as RunServer diff --git a/authentik/core/management/commands/repair_permissions.py b/authentik/core/management/commands/repair_permissions.py index 25200b2ad0..3dfa9b8d7d 100644 --- a/authentik/core/management/commands/repair_permissions.py +++ b/authentik/core/management/commands/repair_permissions.py @@ -1,4 +1,5 @@ """Repair missing permissions""" + from django.apps import apps from django.contrib.auth.management import create_permissions from django.core.management.base import BaseCommand, no_translations diff --git a/authentik/core/management/commands/shell.py b/authentik/core/management/commands/shell.py index dcaf70e9c6..a04545f5cd 100644 --- a/authentik/core/management/commands/shell.py +++ b/authentik/core/management/commands/shell.py @@ -1,4 +1,5 @@ """authentik shell command""" + import code import platform import sys diff --git a/authentik/core/management/commands/worker.py b/authentik/core/management/commands/worker.py index f85c36cc9e..06d32839b2 100644 --- a/authentik/core/management/commands/worker.py +++ b/authentik/core/management/commands/worker.py @@ -1,4 +1,5 @@ """Run worker""" + from sys import exit as sysexit from tempfile import tempdir diff --git a/authentik/core/middleware.py b/authentik/core/middleware.py index 2cda0b0c39..4b710ef12a 100644 --- a/authentik/core/middleware.py +++ b/authentik/core/middleware.py @@ -1,4 +1,5 @@ """authentik admin Middleware to impersonate users""" + from contextvars import ContextVar from typing import Callable, Optional from uuid import uuid4 diff --git a/authentik/core/models.py b/authentik/core/models.py index 6f9e98cd40..d35015d0d3 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -1,4 +1,5 @@ """authentik core models""" + from datetime import timedelta from hashlib import sha256 from typing import Any, Optional, Self diff --git a/authentik/core/signals.py b/authentik/core/signals.py index 31340fce91..75695a135c 100644 --- a/authentik/core/signals.py +++ b/authentik/core/signals.py @@ -1,4 +1,5 @@ """authentik core signals""" + from django.contrib.auth.signals import user_logged_in, user_logged_out from django.contrib.sessions.backends.cache import KEY_PREFIX from django.core.cache import cache diff --git a/authentik/core/sources/flow_manager.py b/authentik/core/sources/flow_manager.py index 0fb038d909..b90add829b 100644 --- a/authentik/core/sources/flow_manager.py +++ b/authentik/core/sources/flow_manager.py @@ -1,4 +1,5 @@ """Source decision helper""" + from enum import Enum from typing import Any, Optional diff --git a/authentik/core/sources/stage.py b/authentik/core/sources/stage.py index 385db38922..12703906ca 100644 --- a/authentik/core/sources/stage.py +++ b/authentik/core/sources/stage.py @@ -1,4 +1,5 @@ """Source flow manager stages""" + from django.http import HttpRequest, HttpResponse from authentik.core.models import User, UserSourceConnection diff --git a/authentik/core/tasks.py b/authentik/core/tasks.py index c3cd5df374..4d66aaa4f8 100644 --- a/authentik/core/tasks.py +++ b/authentik/core/tasks.py @@ -1,4 +1,5 @@ """authentik core tasks""" + from datetime import datetime, timedelta from django.contrib.sessions.backends.cache import KEY_PREFIX diff --git a/authentik/core/tests/test_api_utils.py b/authentik/core/tests/test_api_utils.py index 00736de28c..25a317ebd1 100644 --- a/authentik/core/tests/test_api_utils.py +++ b/authentik/core/tests/test_api_utils.py @@ -1,4 +1,5 @@ """Test API Utils""" + from rest_framework.exceptions import ValidationError from rest_framework.test import APITestCase diff --git a/authentik/core/tests/test_applications_api.py b/authentik/core/tests/test_applications_api.py index 2bed87237e..6e970b2079 100644 --- a/authentik/core/tests/test_applications_api.py +++ b/authentik/core/tests/test_applications_api.py @@ -1,4 +1,5 @@ """Test Applications API""" + from json import loads from django.core.files.base import ContentFile diff --git a/authentik/core/tests/test_applications_views.py b/authentik/core/tests/test_applications_views.py index d71e8406ba..248a595428 100644 --- a/authentik/core/tests/test_applications_views.py +++ b/authentik/core/tests/test_applications_views.py @@ -1,4 +1,5 @@ """Test Applications API""" + from unittest.mock import MagicMock, patch from django.urls import reverse diff --git a/authentik/core/tests/test_authenticated_sessions_api.py b/authentik/core/tests/test_authenticated_sessions_api.py index 51430346bc..a079dd5f84 100644 --- a/authentik/core/tests/test_authenticated_sessions_api.py +++ b/authentik/core/tests/test_authenticated_sessions_api.py @@ -1,4 +1,5 @@ """Test AuthenticatedSessions API""" + from json import loads from django.urls.base import reverse diff --git a/authentik/core/tests/test_groups.py b/authentik/core/tests/test_groups.py index 65a0cc3e60..fa60e6d8ba 100644 --- a/authentik/core/tests/test_groups.py +++ b/authentik/core/tests/test_groups.py @@ -1,4 +1,5 @@ """group tests""" + from django.test.testcases import TestCase from authentik.core.models import Group, User diff --git a/authentik/core/tests/test_groups_api.py b/authentik/core/tests/test_groups_api.py index cff643f5a7..df9cc03ebc 100644 --- a/authentik/core/tests/test_groups_api.py +++ b/authentik/core/tests/test_groups_api.py @@ -1,4 +1,5 @@ """Test Groups API""" + from django.urls.base import reverse from rest_framework.test import APITestCase diff --git a/authentik/core/tests/test_impersonation.py b/authentik/core/tests/test_impersonation.py index 4411fbfe7a..ad3fba32be 100644 --- a/authentik/core/tests/test_impersonation.py +++ b/authentik/core/tests/test_impersonation.py @@ -1,4 +1,5 @@ """impersonation tests""" + from json import loads from django.urls import reverse diff --git a/authentik/core/tests/test_models.py b/authentik/core/tests/test_models.py index a08dbb5af6..1c187daea5 100644 --- a/authentik/core/tests/test_models.py +++ b/authentik/core/tests/test_models.py @@ -1,4 +1,5 @@ """authentik core models tests""" + from time import sleep from typing import Callable diff --git a/authentik/core/tests/test_property_mapping.py b/authentik/core/tests/test_property_mapping.py index ff73b7d228..9fc502af3f 100644 --- a/authentik/core/tests/test_property_mapping.py +++ b/authentik/core/tests/test_property_mapping.py @@ -1,4 +1,5 @@ """authentik core property mapping tests""" + from django.test import RequestFactory, TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/core/tests/test_property_mapping_api.py b/authentik/core/tests/test_property_mapping_api.py index 29e608c056..a7a3581369 100644 --- a/authentik/core/tests/test_property_mapping_api.py +++ b/authentik/core/tests/test_property_mapping_api.py @@ -1,4 +1,5 @@ """Test property mappings API""" + from json import dumps from django.urls import reverse diff --git a/authentik/core/tests/test_providers_api.py b/authentik/core/tests/test_providers_api.py index 0b09686b9a..eac36132ec 100644 --- a/authentik/core/tests/test_providers_api.py +++ b/authentik/core/tests/test_providers_api.py @@ -1,4 +1,5 @@ """Test providers API""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/core/tests/test_source_flow_manager.py b/authentik/core/tests/test_source_flow_manager.py index a16201a6f1..264cdc9d70 100644 --- a/authentik/core/tests/test_source_flow_manager.py +++ b/authentik/core/tests/test_source_flow_manager.py @@ -1,4 +1,5 @@ """Test Source flow_manager""" + from django.contrib.auth.models import AnonymousUser from django.test import TestCase from guardian.utils import get_anonymous_user diff --git a/authentik/core/tests/test_tasks.py b/authentik/core/tests/test_tasks.py index 2212dbccc2..261b19ae6a 100644 --- a/authentik/core/tests/test_tasks.py +++ b/authentik/core/tests/test_tasks.py @@ -1,4 +1,5 @@ """Test tasks""" + from time import mktime from django.utils.timezone import now diff --git a/authentik/core/tests/test_token_api.py b/authentik/core/tests/test_token_api.py index 3584e01a78..26e6740604 100644 --- a/authentik/core/tests/test_token_api.py +++ b/authentik/core/tests/test_token_api.py @@ -1,4 +1,5 @@ """Test token API""" + from json import loads from django.urls.base import reverse diff --git a/authentik/core/tests/test_token_auth.py b/authentik/core/tests/test_token_auth.py index 399e81d135..87e3df3818 100644 --- a/authentik/core/tests/test_token_auth.py +++ b/authentik/core/tests/test_token_auth.py @@ -1,4 +1,5 @@ """Test token auth""" + from django.test import TestCase from authentik.core.auth import TokenBackend diff --git a/authentik/core/tests/test_transactional_applications_api.py b/authentik/core/tests/test_transactional_applications_api.py index cd042bdb65..3d18e8cd9b 100644 --- a/authentik/core/tests/test_transactional_applications_api.py +++ b/authentik/core/tests/test_transactional_applications_api.py @@ -1,4 +1,5 @@ """Test Transactional API""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/core/tests/test_users_avatars.py b/authentik/core/tests/test_users_avatars.py index 01f703c616..dc31e9f614 100644 --- a/authentik/core/tests/test_users_avatars.py +++ b/authentik/core/tests/test_users_avatars.py @@ -1,4 +1,5 @@ """Test Users Avatars""" + from json import loads from django.urls.base import reverse diff --git a/authentik/core/tests/utils.py b/authentik/core/tests/utils.py index 6373d31d74..c46c6ad792 100644 --- a/authentik/core/tests/utils.py +++ b/authentik/core/tests/utils.py @@ -1,4 +1,5 @@ """Test Utils""" + from typing import Optional from django.utils.text import slugify diff --git a/authentik/core/types.py b/authentik/core/types.py index 036b17c783..af8d32eb56 100644 --- a/authentik/core/types.py +++ b/authentik/core/types.py @@ -1,4 +1,5 @@ """authentik core dataclasses""" + from dataclasses import dataclass from typing import Optional diff --git a/authentik/core/urls.py b/authentik/core/urls.py index 0914d4e88c..3f3949d0c3 100644 --- a/authentik/core/urls.py +++ b/authentik/core/urls.py @@ -1,4 +1,5 @@ """authentik URL Configuration""" + from channels.auth import AuthMiddleware from channels.sessions import CookieMiddleware from django.conf import settings diff --git a/authentik/core/views/apps.py b/authentik/core/views/apps.py index e52ba12d62..351507256b 100644 --- a/authentik/core/views/apps.py +++ b/authentik/core/views/apps.py @@ -1,4 +1,5 @@ """app views""" + from django.http import Http404, HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.utils.translation import gettext_lazy as _ diff --git a/authentik/core/views/debug.py b/authentik/core/views/debug.py index 5ec6fd860a..96bb04a101 100644 --- a/authentik/core/views/debug.py +++ b/authentik/core/views/debug.py @@ -1,4 +1,5 @@ """debug view""" + from django.http import HttpRequest, HttpResponse from django.views.generic import View diff --git a/authentik/core/views/interface.py b/authentik/core/views/interface.py index faeb40b821..2a7dbda558 100644 --- a/authentik/core/views/interface.py +++ b/authentik/core/views/interface.py @@ -1,4 +1,5 @@ """Interface views""" + from json import dumps from typing import Any diff --git a/authentik/core/views/session.py b/authentik/core/views/session.py index 11d5ad9409..c0ad9d7714 100644 --- a/authentik/core/views/session.py +++ b/authentik/core/views/session.py @@ -1,4 +1,5 @@ """authentik Session Views""" + from typing import Any from django.shortcuts import get_object_or_404 diff --git a/authentik/crypto/api.py b/authentik/crypto/api.py index af9b1d066d..38c414c821 100644 --- a/authentik/crypto/api.py +++ b/authentik/crypto/api.py @@ -1,4 +1,5 @@ """Crypto API Views""" + from datetime import datetime from typing import Optional @@ -272,9 +273,9 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet): response = HttpResponse( certificate.certificate_data, content_type="application/x-pem-file" ) - response[ - "Content-Disposition" - ] = f'attachment; filename="{certificate.name}_certificate.pem"' + response["Content-Disposition"] = ( + f'attachment; filename="{certificate.name}_certificate.pem"' + ) return response return Response(CertificateDataSerializer({"data": certificate.certificate_data}).data) @@ -300,8 +301,8 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet): if "download" in request.query_params: # Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html response = HttpResponse(certificate.key_data, content_type="application/x-pem-file") - response[ - "Content-Disposition" - ] = f'attachment; filename="{certificate.name}_private_key.pem"' + response["Content-Disposition"] = ( + f'attachment; filename="{certificate.name}_private_key.pem"' + ) return response return Response(CertificateDataSerializer({"data": certificate.key_data}).data) diff --git a/authentik/crypto/apps.py b/authentik/crypto/apps.py index 24d63e92a7..2afb4c579e 100644 --- a/authentik/crypto/apps.py +++ b/authentik/crypto/apps.py @@ -1,4 +1,5 @@ """authentik crypto app config""" + from datetime import datetime from typing import Optional diff --git a/authentik/crypto/builder.py b/authentik/crypto/builder.py index d560901bda..29bd8caadf 100644 --- a/authentik/crypto/builder.py +++ b/authentik/crypto/builder.py @@ -1,4 +1,5 @@ """Create self-signed certificates""" + import datetime import uuid from typing import Optional diff --git a/authentik/crypto/management/commands/import_certificate.py b/authentik/crypto/management/commands/import_certificate.py index 6f84a1ddc1..b8b04e6a10 100644 --- a/authentik/crypto/management/commands/import_certificate.py +++ b/authentik/crypto/management/commands/import_certificate.py @@ -1,4 +1,5 @@ """Import certificate""" + from sys import exit as sys_exit from django.core.management.base import no_translations diff --git a/authentik/crypto/models.py b/authentik/crypto/models.py index d6543fe318..3c8120ea9c 100644 --- a/authentik/crypto/models.py +++ b/authentik/crypto/models.py @@ -1,4 +1,5 @@ """authentik crypto models""" + from binascii import hexlify from hashlib import md5 from typing import Optional diff --git a/authentik/crypto/settings.py b/authentik/crypto/settings.py index 939473a96e..8316e9b84d 100644 --- a/authentik/crypto/settings.py +++ b/authentik/crypto/settings.py @@ -1,4 +1,5 @@ """Crypto task Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/crypto/tasks.py b/authentik/crypto/tasks.py index 066fee8ac8..cef8f61c61 100644 --- a/authentik/crypto/tasks.py +++ b/authentik/crypto/tasks.py @@ -1,4 +1,5 @@ """Crypto tasks""" + from glob import glob from pathlib import Path diff --git a/authentik/crypto/tests.py b/authentik/crypto/tests.py index 3a4f05ea5c..056425e06d 100644 --- a/authentik/crypto/tests.py +++ b/authentik/crypto/tests.py @@ -1,4 +1,5 @@ """Crypto tests""" + import datetime from json import loads from os import makedirs diff --git a/authentik/crypto/urls.py b/authentik/crypto/urls.py index a71a890848..e98009e316 100644 --- a/authentik/crypto/urls.py +++ b/authentik/crypto/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.crypto.api import CertificateKeyPairViewSet api_urlpatterns = [ diff --git a/authentik/enterprise/api.py b/authentik/enterprise/api.py index c13e34b6da..b7a91d7649 100644 --- a/authentik/enterprise/api.py +++ b/authentik/enterprise/api.py @@ -1,4 +1,5 @@ """Enterprise API Views""" + from datetime import datetime, timedelta from django.utils.timezone import now diff --git a/authentik/enterprise/apps.py b/authentik/enterprise/apps.py index 166ab55c88..ae979dac77 100644 --- a/authentik/enterprise/apps.py +++ b/authentik/enterprise/apps.py @@ -1,4 +1,5 @@ """Enterprise app config""" + from django.conf import settings from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/enterprise/audit/apps.py b/authentik/enterprise/audit/apps.py index 04c9f3686d..6779111bc3 100644 --- a/authentik/enterprise/audit/apps.py +++ b/authentik/enterprise/audit/apps.py @@ -1,4 +1,5 @@ """Enterprise app config""" + from django.conf import settings from authentik.enterprise.apps import EnterpriseConfig diff --git a/authentik/enterprise/audit/middleware.py b/authentik/enterprise/audit/middleware.py index 889ce25e58..cca240b96f 100644 --- a/authentik/enterprise/audit/middleware.py +++ b/authentik/enterprise/audit/middleware.py @@ -1,4 +1,5 @@ """Enterprise audit middleware""" + from copy import deepcopy from functools import partial diff --git a/authentik/enterprise/models.py b/authentik/enterprise/models.py index 34cab4f6f7..2c20169fbd 100644 --- a/authentik/enterprise/models.py +++ b/authentik/enterprise/models.py @@ -1,4 +1,5 @@ """Enterprise models""" + from base64 import b64decode from binascii import Error from dataclasses import dataclass, field diff --git a/authentik/enterprise/policy.py b/authentik/enterprise/policy.py index 20bf438a0e..a448c087c5 100644 --- a/authentik/enterprise/policy.py +++ b/authentik/enterprise/policy.py @@ -1,4 +1,5 @@ """Enterprise license policies""" + from typing import Optional from django.utils.translation import gettext_lazy as _ diff --git a/authentik/enterprise/providers/rac/api/endpoints.py b/authentik/enterprise/providers/rac/api/endpoints.py index 1af281ef85..c681350e8e 100644 --- a/authentik/enterprise/providers/rac/api/endpoints.py +++ b/authentik/enterprise/providers/rac/api/endpoints.py @@ -1,4 +1,5 @@ """RAC Provider API Views""" + from typing import Optional from django.core.cache import cache diff --git a/authentik/enterprise/providers/rac/api/property_mappings.py b/authentik/enterprise/providers/rac/api/property_mappings.py index 360ad978a1..95caf21760 100644 --- a/authentik/enterprise/providers/rac/api/property_mappings.py +++ b/authentik/enterprise/providers/rac/api/property_mappings.py @@ -1,4 +1,5 @@ """RAC Provider API Views""" + from django_filters.filters import AllValuesMultipleFilter from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes diff --git a/authentik/enterprise/providers/rac/api/providers.py b/authentik/enterprise/providers/rac/api/providers.py index cda6c2af36..25df75789c 100644 --- a/authentik/enterprise/providers/rac/api/providers.py +++ b/authentik/enterprise/providers/rac/api/providers.py @@ -1,4 +1,5 @@ """RAC Provider API Views""" + from rest_framework.fields import CharField, ListField from rest_framework.viewsets import ModelViewSet diff --git a/authentik/enterprise/providers/rac/apps.py b/authentik/enterprise/providers/rac/apps.py index d5958eb941..d5ad27b6d5 100644 --- a/authentik/enterprise/providers/rac/apps.py +++ b/authentik/enterprise/providers/rac/apps.py @@ -1,4 +1,5 @@ """RAC app config""" + from authentik.enterprise.apps import EnterpriseConfig diff --git a/authentik/enterprise/providers/rac/consumer_client.py b/authentik/enterprise/providers/rac/consumer_client.py index 57fef7d744..5bfc176b95 100644 --- a/authentik/enterprise/providers/rac/consumer_client.py +++ b/authentik/enterprise/providers/rac/consumer_client.py @@ -1,4 +1,5 @@ """RAC Client consumer""" + from asgiref.sync import async_to_sync from channels.db import database_sync_to_async from channels.exceptions import ChannelFull, DenyConnection diff --git a/authentik/enterprise/providers/rac/consumer_outpost.py b/authentik/enterprise/providers/rac/consumer_outpost.py index 8fa42d8598..a1119d85a8 100644 --- a/authentik/enterprise/providers/rac/consumer_outpost.py +++ b/authentik/enterprise/providers/rac/consumer_outpost.py @@ -1,4 +1,5 @@ """RAC consumer""" + from channels.exceptions import ChannelFull from channels.generic.websocket import AsyncWebsocketConsumer diff --git a/authentik/enterprise/providers/rac/controllers/docker.py b/authentik/enterprise/providers/rac/controllers/docker.py index 8dac04d061..56fca7b4a2 100644 --- a/authentik/enterprise/providers/rac/controllers/docker.py +++ b/authentik/enterprise/providers/rac/controllers/docker.py @@ -1,4 +1,5 @@ """RAC Provider Docker Controller""" + from authentik.outposts.controllers.docker import DockerController from authentik.outposts.models import DockerServiceConnection, Outpost diff --git a/authentik/enterprise/providers/rac/controllers/kubernetes.py b/authentik/enterprise/providers/rac/controllers/kubernetes.py index f7768735e7..b6eda83db9 100644 --- a/authentik/enterprise/providers/rac/controllers/kubernetes.py +++ b/authentik/enterprise/providers/rac/controllers/kubernetes.py @@ -1,4 +1,5 @@ """RAC Provider Kubernetes Controller""" + from authentik.outposts.controllers.k8s.service import ServiceReconciler from authentik.outposts.controllers.kubernetes import KubernetesController from authentik.outposts.models import KubernetesServiceConnection, Outpost diff --git a/authentik/enterprise/providers/rac/models.py b/authentik/enterprise/providers/rac/models.py index 927bd23fec..d1645efc5a 100644 --- a/authentik/enterprise/providers/rac/models.py +++ b/authentik/enterprise/providers/rac/models.py @@ -1,4 +1,5 @@ """RAC Models""" + from typing import Optional from uuid import uuid4 diff --git a/authentik/enterprise/providers/rac/signals.py b/authentik/enterprise/providers/rac/signals.py index 21f7276902..20e967ddb3 100644 --- a/authentik/enterprise/providers/rac/signals.py +++ b/authentik/enterprise/providers/rac/signals.py @@ -1,4 +1,5 @@ """RAC Signals""" + from asgiref.sync import async_to_sync from channels.layers import get_channel_layer from django.contrib.auth.signals import user_logged_out diff --git a/authentik/enterprise/providers/rac/tests/test_models.py b/authentik/enterprise/providers/rac/tests/test_models.py index 48218f41ba..5e583d7b6d 100644 --- a/authentik/enterprise/providers/rac/tests/test_models.py +++ b/authentik/enterprise/providers/rac/tests/test_models.py @@ -1,4 +1,5 @@ """Test RAC Models""" + from django.test import TransactionTestCase from authentik.core.models import Application, AuthenticatedSession diff --git a/authentik/enterprise/providers/rac/tests/test_views.py b/authentik/enterprise/providers/rac/tests/test_views.py index e2fb14a11f..380b925a76 100644 --- a/authentik/enterprise/providers/rac/tests/test_views.py +++ b/authentik/enterprise/providers/rac/tests/test_views.py @@ -1,4 +1,5 @@ """RAC Views tests""" + from datetime import timedelta from json import loads from time import mktime diff --git a/authentik/enterprise/providers/rac/urls.py b/authentik/enterprise/providers/rac/urls.py index 383619a3a5..b36eb998d5 100644 --- a/authentik/enterprise/providers/rac/urls.py +++ b/authentik/enterprise/providers/rac/urls.py @@ -1,4 +1,5 @@ """rac urls""" + from channels.auth import AuthMiddleware from channels.sessions import CookieMiddleware from django.urls import path diff --git a/authentik/enterprise/providers/rac/views.py b/authentik/enterprise/providers/rac/views.py index c1dc2c6673..b6de8b89e8 100644 --- a/authentik/enterprise/providers/rac/views.py +++ b/authentik/enterprise/providers/rac/views.py @@ -1,4 +1,5 @@ """RAC Views""" + from typing import Any from django.http import Http404, HttpRequest, HttpResponse diff --git a/authentik/enterprise/settings.py b/authentik/enterprise/settings.py index cc3ed2ae8d..fb91d7f444 100644 --- a/authentik/enterprise/settings.py +++ b/authentik/enterprise/settings.py @@ -1,4 +1,5 @@ """Enterprise additional settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/enterprise/signals.py b/authentik/enterprise/signals.py index 67e7c57455..59ac1c81cf 100644 --- a/authentik/enterprise/signals.py +++ b/authentik/enterprise/signals.py @@ -1,4 +1,5 @@ """Enterprise signals""" + from datetime import datetime from django.db.models.signals import pre_save diff --git a/authentik/enterprise/tasks.py b/authentik/enterprise/tasks.py index 2063cf07ac..2e46bd8b3b 100644 --- a/authentik/enterprise/tasks.py +++ b/authentik/enterprise/tasks.py @@ -1,4 +1,5 @@ """Enterprise tasks""" + from authentik.enterprise.models import LicenseKey from authentik.root.celery import CELERY_APP diff --git a/authentik/enterprise/tests/test_license.py b/authentik/enterprise/tests/test_license.py index dd91af1a6f..a972d961b7 100644 --- a/authentik/enterprise/tests/test_license.py +++ b/authentik/enterprise/tests/test_license.py @@ -1,4 +1,5 @@ """Enterprise license tests""" + from datetime import timedelta from time import mktime from unittest.mock import MagicMock, patch diff --git a/authentik/events/api/events.py b/authentik/events/api/events.py index dbec7a5149..5ddb1a55b7 100644 --- a/authentik/events/api/events.py +++ b/authentik/events/api/events.py @@ -1,4 +1,5 @@ """Events API Views""" + from datetime import timedelta from json import loads diff --git a/authentik/events/api/notification_mappings.py b/authentik/events/api/notification_mappings.py index 6e84332ea4..86a23fa810 100644 --- a/authentik/events/api/notification_mappings.py +++ b/authentik/events/api/notification_mappings.py @@ -1,4 +1,5 @@ """NotificationWebhookMapping API Views""" + from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet diff --git a/authentik/events/api/notification_rules.py b/authentik/events/api/notification_rules.py index 6258f57bda..ada4332bb9 100644 --- a/authentik/events/api/notification_rules.py +++ b/authentik/events/api/notification_rules.py @@ -1,4 +1,5 @@ """NotificationRule API Views""" + from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet diff --git a/authentik/events/api/notification_transports.py b/authentik/events/api/notification_transports.py index 6902c6e178..60294e9acc 100644 --- a/authentik/events/api/notification_transports.py +++ b/authentik/events/api/notification_transports.py @@ -1,4 +1,5 @@ """NotificationTransport API Views""" + from typing import Any from drf_spectacular.types import OpenApiTypes diff --git a/authentik/events/api/notifications.py b/authentik/events/api/notifications.py index 32608ec28d..3df2744ace 100644 --- a/authentik/events/api/notifications.py +++ b/authentik/events/api/notifications.py @@ -1,4 +1,5 @@ """Notification API Views""" + from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiResponse, extend_schema diff --git a/authentik/events/api/tasks.py b/authentik/events/api/tasks.py index c89724059e..a0d303b958 100644 --- a/authentik/events/api/tasks.py +++ b/authentik/events/api/tasks.py @@ -1,4 +1,5 @@ """Tasks API""" + from datetime import datetime, timezone from importlib import import_module diff --git a/authentik/events/apps.py b/authentik/events/apps.py index 0c999fc142..5948d43d2f 100644 --- a/authentik/events/apps.py +++ b/authentik/events/apps.py @@ -1,4 +1,5 @@ """authentik events app""" + from prometheus_client import Gauge, Histogram from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/events/context_processors/asn.py b/authentik/events/context_processors/asn.py index 4478c7fb04..a125b07446 100644 --- a/authentik/events/context_processors/asn.py +++ b/authentik/events/context_processors/asn.py @@ -1,4 +1,5 @@ """ASN Enricher""" + from typing import TYPE_CHECKING, Optional, TypedDict from django.http import HttpRequest diff --git a/authentik/events/context_processors/base.py b/authentik/events/context_processors/base.py index 96a46a65a0..fe94dd6d09 100644 --- a/authentik/events/context_processors/base.py +++ b/authentik/events/context_processors/base.py @@ -1,4 +1,5 @@ """Base event enricher""" + from functools import cache from typing import TYPE_CHECKING, Optional diff --git a/authentik/events/context_processors/geoip.py b/authentik/events/context_processors/geoip.py index 40ea0b0126..0d32ec991c 100644 --- a/authentik/events/context_processors/geoip.py +++ b/authentik/events/context_processors/geoip.py @@ -1,4 +1,5 @@ """events GeoIP Reader""" + from typing import TYPE_CHECKING, Optional, TypedDict from django.http import HttpRequest diff --git a/authentik/events/context_processors/mmdb.py b/authentik/events/context_processors/mmdb.py index 45bd854115..4453e78215 100644 --- a/authentik/events/context_processors/mmdb.py +++ b/authentik/events/context_processors/mmdb.py @@ -1,4 +1,5 @@ """Common logic for reading MMDB files""" + from pathlib import Path from typing import Optional diff --git a/authentik/events/middleware.py b/authentik/events/middleware.py index e0f722ccfe..b39ecb7337 100644 --- a/authentik/events/middleware.py +++ b/authentik/events/middleware.py @@ -1,4 +1,5 @@ """Events middleware""" + from functools import partial from threading import Thread from typing import Any, Callable, Optional diff --git a/authentik/events/models.py b/authentik/events/models.py index fa869b4658..a2e7d71190 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -1,4 +1,5 @@ """authentik events models""" + import time from collections import Counter from datetime import timedelta diff --git a/authentik/events/settings.py b/authentik/events/settings.py index 4e41e3953f..5fc978ef27 100644 --- a/authentik/events/settings.py +++ b/authentik/events/settings.py @@ -1,4 +1,5 @@ """Event Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/events/signals.py b/authentik/events/signals.py index ff1fb91d23..2f29491708 100644 --- a/authentik/events/signals.py +++ b/authentik/events/signals.py @@ -1,4 +1,5 @@ """authentik events signal listener""" + from typing import Any, Optional from django.contrib.auth.signals import user_logged_in, user_logged_out diff --git a/authentik/events/system_tasks.py b/authentik/events/system_tasks.py index 6d36c81161..a4bc60d569 100644 --- a/authentik/events/system_tasks.py +++ b/authentik/events/system_tasks.py @@ -1,4 +1,5 @@ """Monitored tasks""" + from datetime import timedelta from timeit import default_timer from typing import Any, Optional diff --git a/authentik/events/tasks.py b/authentik/events/tasks.py index c896238080..e196712cb9 100644 --- a/authentik/events/tasks.py +++ b/authentik/events/tasks.py @@ -1,4 +1,5 @@ """Event notification tasks""" + from typing import Optional from django.db.models.query_utils import Q diff --git a/authentik/events/tests/test_api.py b/authentik/events/tests/test_api.py index 98df7bc695..51028c8a8f 100644 --- a/authentik/events/tests/test_api.py +++ b/authentik/events/tests/test_api.py @@ -1,4 +1,5 @@ """Event API tests""" + from json import loads from django.urls import reverse diff --git a/authentik/events/tests/test_enrich_asn.py b/authentik/events/tests/test_enrich_asn.py index 2844c45919..185a60632e 100644 --- a/authentik/events/tests/test_enrich_asn.py +++ b/authentik/events/tests/test_enrich_asn.py @@ -1,4 +1,5 @@ """Test ASN Wrapper""" + from django.test import TestCase from authentik.events.context_processors.asn import ASNContextProcessor diff --git a/authentik/events/tests/test_enrich_geoip.py b/authentik/events/tests/test_enrich_geoip.py index 5317901a4f..83a8391558 100644 --- a/authentik/events/tests/test_enrich_geoip.py +++ b/authentik/events/tests/test_enrich_geoip.py @@ -1,4 +1,5 @@ """Test GeoIP Wrapper""" + from django.test import TestCase from authentik.events.context_processors.geoip import GeoIPContextProcessor diff --git a/authentik/events/tests/test_event.py b/authentik/events/tests/test_event.py index f9392014df..78771d472d 100644 --- a/authentik/events/tests/test_event.py +++ b/authentik/events/tests/test_event.py @@ -1,4 +1,5 @@ """event tests""" + from urllib.parse import urlencode from django.contrib.contenttypes.models import ContentType diff --git a/authentik/events/tests/test_tasks.py b/authentik/events/tests/test_tasks.py index 0e3a3cd5d6..353c11b07f 100644 --- a/authentik/events/tests/test_tasks.py +++ b/authentik/events/tests/test_tasks.py @@ -1,4 +1,5 @@ """Test Monitored tasks""" + from json import loads from django.urls import reverse diff --git a/authentik/events/tests/test_transports.py b/authentik/events/tests/test_transports.py index 3633f1ed5c..23ea924376 100644 --- a/authentik/events/tests/test_transports.py +++ b/authentik/events/tests/test_transports.py @@ -1,4 +1,5 @@ """transport tests""" + from unittest.mock import PropertyMock, patch from django.core import mail diff --git a/authentik/events/urls.py b/authentik/events/urls.py index 523435819d..0beea59913 100644 --- a/authentik/events/urls.py +++ b/authentik/events/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.events.api.events import EventViewSet from authentik.events.api.notification_mappings import NotificationWebhookMappingViewSet from authentik.events.api.notification_rules import NotificationRuleViewSet diff --git a/authentik/events/utils.py b/authentik/events/utils.py index c0888375a1..b9071435c4 100644 --- a/authentik/events/utils.py +++ b/authentik/events/utils.py @@ -1,4 +1,5 @@ """event utilities""" + import re from copy import copy from dataclasses import asdict, is_dataclass diff --git a/authentik/flows/api/bindings.py b/authentik/flows/api/bindings.py index 96e2e46629..d3d684dd74 100644 --- a/authentik/flows/api/bindings.py +++ b/authentik/flows/api/bindings.py @@ -1,4 +1,5 @@ """Flow Binding API Views""" + from typing import Any from rest_framework.exceptions import ValidationError diff --git a/authentik/flows/api/flows.py b/authentik/flows/api/flows.py index 0508b2222b..3d22f0ce92 100644 --- a/authentik/flows/api/flows.py +++ b/authentik/flows/api/flows.py @@ -1,4 +1,5 @@ """Flow API Views""" + from django.core.cache import cache from django.http import HttpResponse from django.urls import reverse @@ -113,6 +114,7 @@ class FlowImportResultSerializer(PassiveSerializer): class FlowViewSet(UsedByMixin, ModelViewSet): """Flow Viewset""" + # pylint: disable=no-member queryset = Flow.objects.all().prefetch_related("stages", "policies") serializer_class = FlowSerializer lookup_field = "slug" diff --git a/authentik/flows/api/flows_diagram.py b/authentik/flows/api/flows_diagram.py index ab75fa2355..ba0056c14a 100644 --- a/authentik/flows/api/flows_diagram.py +++ b/authentik/flows/api/flows_diagram.py @@ -1,4 +1,5 @@ """Flows Diagram API""" + from dataclasses import dataclass, field from typing import Optional diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index 6f0d6e4ac5..89fb250232 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -1,4 +1,5 @@ """Flow Stage API Views""" + from django.urls.base import reverse from drf_spectacular.utils import extend_schema from rest_framework import mixins diff --git a/authentik/flows/apps.py b/authentik/flows/apps.py index b901160a86..b0ffff2c70 100644 --- a/authentik/flows/apps.py +++ b/authentik/flows/apps.py @@ -1,4 +1,5 @@ """authentik flows app config""" + from prometheus_client import Gauge, Histogram from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/flows/challenge.py b/authentik/flows/challenge.py index eb968ce791..b04ca18199 100644 --- a/authentik/flows/challenge.py +++ b/authentik/flows/challenge.py @@ -1,4 +1,5 @@ """Challenge helpers""" + from dataclasses import asdict, is_dataclass from enum import Enum from typing import TYPE_CHECKING, Optional, TypedDict diff --git a/authentik/flows/exceptions.py b/authentik/flows/exceptions.py index 7f903633e9..04f8855577 100644 --- a/authentik/flows/exceptions.py +++ b/authentik/flows/exceptions.py @@ -1,4 +1,5 @@ """flow exceptions""" + from typing import Optional from django.utils.translation import gettext_lazy as _ diff --git a/authentik/flows/management/commands/benchmark.py b/authentik/flows/management/commands/benchmark.py index 66e27a9cbe..cab0f105e3 100644 --- a/authentik/flows/management/commands/benchmark.py +++ b/authentik/flows/management/commands/benchmark.py @@ -1,4 +1,5 @@ """authentik benchmark command""" + from csv import DictWriter from multiprocessing import Manager, cpu_count, get_context from sys import stdout diff --git a/authentik/flows/markers.py b/authentik/flows/markers.py index e59333e685..0aeaa66c60 100644 --- a/authentik/flows/markers.py +++ b/authentik/flows/markers.py @@ -1,4 +1,5 @@ """Stage Markers""" + from dataclasses import dataclass from typing import TYPE_CHECKING, Optional diff --git a/authentik/flows/models.py b/authentik/flows/models.py index 7ed7448247..e7efaca816 100644 --- a/authentik/flows/models.py +++ b/authentik/flows/models.py @@ -1,4 +1,5 @@ """Flow models""" + from base64 import b64decode, b64encode from pickle import dumps, loads # nosec from typing import TYPE_CHECKING, Optional diff --git a/authentik/flows/planner.py b/authentik/flows/planner.py index a74c432756..28f34a2655 100644 --- a/authentik/flows/planner.py +++ b/authentik/flows/planner.py @@ -1,4 +1,5 @@ """Flows Planner""" + from dataclasses import dataclass, field from typing import Any, Optional diff --git a/authentik/flows/signals.py b/authentik/flows/signals.py index af645fa7e9..4ceda51520 100644 --- a/authentik/flows/signals.py +++ b/authentik/flows/signals.py @@ -1,4 +1,5 @@ """authentik flow signals""" + from django.core.cache import cache from django.db import connection from django.db.models.signals import post_save, pre_delete diff --git a/authentik/flows/stage.py b/authentik/flows/stage.py index 04e64df921..e96cb33322 100644 --- a/authentik/flows/stage.py +++ b/authentik/flows/stage.py @@ -1,4 +1,5 @@ """authentik stage Base view""" + from typing import TYPE_CHECKING, Optional from django.contrib.auth.models import AnonymousUser diff --git a/authentik/flows/tests/__init__.py b/authentik/flows/tests/__init__.py index bd7d8dc888..2123611845 100644 --- a/authentik/flows/tests/__init__.py +++ b/authentik/flows/tests/__init__.py @@ -1,4 +1,5 @@ """Test helpers""" + from json import loads from typing import Any, Optional diff --git a/authentik/flows/tests/test_api.py b/authentik/flows/tests/test_api.py index 3de7dd3f07..d2133b45aa 100644 --- a/authentik/flows/tests/test_api.py +++ b/authentik/flows/tests/test_api.py @@ -1,4 +1,5 @@ """API flow tests""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/flows/tests/test_challenges.py b/authentik/flows/tests/test_challenges.py index 4651e6ff80..fe1a6c288f 100644 --- a/authentik/flows/tests/test_challenges.py +++ b/authentik/flows/tests/test_challenges.py @@ -1,4 +1,5 @@ """flow views tests""" + from django.test import TestCase from authentik.flows.challenge import AutosubmitChallenge, ChallengeTypes diff --git a/authentik/flows/tests/test_executor.py b/authentik/flows/tests/test_executor.py index dfca805171..c8e67492de 100644 --- a/authentik/flows/tests/test_executor.py +++ b/authentik/flows/tests/test_executor.py @@ -1,4 +1,5 @@ """flow views tests""" + from unittest.mock import MagicMock, PropertyMock, patch from django.http import HttpRequest, HttpResponse diff --git a/authentik/flows/tests/test_planner.py b/authentik/flows/tests/test_planner.py index f95462dc55..f7352a7cf5 100644 --- a/authentik/flows/tests/test_planner.py +++ b/authentik/flows/tests/test_planner.py @@ -1,4 +1,5 @@ """flow planner tests""" + from unittest.mock import MagicMock, Mock, PropertyMock, patch from django.contrib.auth.models import AnonymousUser diff --git a/authentik/flows/tests/test_stage_model.py b/authentik/flows/tests/test_stage_model.py index 2e1edd54b2..0987bf2f44 100644 --- a/authentik/flows/tests/test_stage_model.py +++ b/authentik/flows/tests/test_stage_model.py @@ -1,4 +1,5 @@ """base model tests""" + from typing import Callable from django.test import TestCase diff --git a/authentik/flows/tests/test_stage_views.py b/authentik/flows/tests/test_stage_views.py index b116ddac4c..46364ef298 100644 --- a/authentik/flows/tests/test_stage_views.py +++ b/authentik/flows/tests/test_stage_views.py @@ -1,4 +1,5 @@ """stage view tests""" + from typing import Callable from django.test import RequestFactory, TestCase diff --git a/authentik/flows/tests/test_views_helper.py b/authentik/flows/tests/test_views_helper.py index 1cf68fec2e..d5a64d84ae 100644 --- a/authentik/flows/tests/test_views_helper.py +++ b/authentik/flows/tests/test_views_helper.py @@ -1,4 +1,5 @@ """flow views tests""" + from django.test import TestCase from django.urls import reverse diff --git a/authentik/flows/urls.py b/authentik/flows/urls.py index 4642df07e6..a256437d46 100644 --- a/authentik/flows/urls.py +++ b/authentik/flows/urls.py @@ -1,4 +1,5 @@ """flow urls""" + from django.urls import path from authentik.flows.api.bindings import FlowStageBindingViewSet diff --git a/authentik/flows/views/executor.py b/authentik/flows/views/executor.py index 42c762779a..71ee200402 100644 --- a/authentik/flows/views/executor.py +++ b/authentik/flows/views/executor.py @@ -1,4 +1,5 @@ """authentik multi-stage authentication engine""" + from copy import deepcopy from typing import Optional @@ -274,13 +275,16 @@ class FlowExecutorView(APIView): stage=self.current_stage, ) try: - with Hub.current.start_span( - op="authentik.flow.executor.stage", - description=class_path, - ) as span, HIST_FLOW_EXECUTION_STAGE_TIME.labels( - method=request.method.upper(), - stage_type=class_path, - ).time(): + with ( + Hub.current.start_span( + op="authentik.flow.executor.stage", + description=class_path, + ) as span, + HIST_FLOW_EXECUTION_STAGE_TIME.labels( + method=request.method.upper(), + stage_type=class_path, + ).time(), + ): span.set_data("Method", request.method.upper()) span.set_data("authentik Stage", self.current_stage_view) span.set_data("authentik Flow", self.flow.slug) @@ -322,13 +326,16 @@ class FlowExecutorView(APIView): stage=self.current_stage, ) try: - with Hub.current.start_span( - op="authentik.flow.executor.stage", - description=class_path, - ) as span, HIST_FLOW_EXECUTION_STAGE_TIME.labels( - method=request.method.upper(), - stage_type=class_path, - ).time(): + with ( + Hub.current.start_span( + op="authentik.flow.executor.stage", + description=class_path, + ) as span, + HIST_FLOW_EXECUTION_STAGE_TIME.labels( + method=request.method.upper(), + stage_type=class_path, + ).time(), + ): span.set_data("Method", request.method.upper()) span.set_data("authentik Stage", self.current_stage_view) span.set_data("authentik Flow", self.flow.slug) diff --git a/authentik/flows/views/inspector.py b/authentik/flows/views/inspector.py index 4800ead6d7..8af581f756 100644 --- a/authentik/flows/views/inspector.py +++ b/authentik/flows/views/inspector.py @@ -1,4 +1,5 @@ """Flow Inspector""" + from hashlib import sha256 from typing import Any diff --git a/authentik/lib/avatars.py b/authentik/lib/avatars.py index 8006240e30..593ef6b828 100644 --- a/authentik/lib/avatars.py +++ b/authentik/lib/avatars.py @@ -1,4 +1,5 @@ """Avatar utils""" + from base64 import b64encode from functools import cache as funccache from hashlib import md5 diff --git a/authentik/lib/config.py b/authentik/lib/config.py index 319be44125..8d499e9b94 100644 --- a/authentik/lib/config.py +++ b/authentik/lib/config.py @@ -1,4 +1,5 @@ """authentik core config loader""" + import base64 import json import os diff --git a/authentik/lib/expression/evaluator.py b/authentik/lib/expression/evaluator.py index 3e98843ffc..e4742e096e 100644 --- a/authentik/lib/expression/evaluator.py +++ b/authentik/lib/expression/evaluator.py @@ -1,4 +1,5 @@ """authentik expression policy evaluator""" + import re import socket from ipaddress import ip_address, ip_network diff --git a/authentik/lib/generators.py b/authentik/lib/generators.py index 2716cc93ea..67e0e9a459 100644 --- a/authentik/lib/generators.py +++ b/authentik/lib/generators.py @@ -1,4 +1,5 @@ """ID/Secret Generators""" + import string from random import SystemRandom diff --git a/authentik/lib/logging.py b/authentik/lib/logging.py index b93cd06e5f..7b0a46f246 100644 --- a/authentik/lib/logging.py +++ b/authentik/lib/logging.py @@ -1,4 +1,5 @@ """logging helpers""" + import logging from logging import Logger from os import getpid diff --git a/authentik/lib/merge.py b/authentik/lib/merge.py index 99a6dab665..764188cb52 100644 --- a/authentik/lib/merge.py +++ b/authentik/lib/merge.py @@ -1,4 +1,5 @@ """merge utils""" + from deepmerge import Merger MERGE_LIST_UNIQUE = Merger( diff --git a/authentik/lib/migrations.py b/authentik/lib/migrations.py index 9239430e6f..65dc3a84bb 100644 --- a/authentik/lib/migrations.py +++ b/authentik/lib/migrations.py @@ -1,4 +1,5 @@ """Migration helpers""" + from typing import Iterable from django.apps.registry import Apps diff --git a/authentik/lib/models.py b/authentik/lib/models.py index 19029c57fb..36a1e173b4 100644 --- a/authentik/lib/models.py +++ b/authentik/lib/models.py @@ -1,4 +1,5 @@ """Generic models""" + import re from django.core.validators import URLValidator diff --git a/authentik/lib/sentry.py b/authentik/lib/sentry.py index 6ea34625e2..75198764bd 100644 --- a/authentik/lib/sentry.py +++ b/authentik/lib/sentry.py @@ -1,4 +1,5 @@ """authentik sentry integration""" + from asyncio.exceptions import CancelledError from typing import Any, Optional diff --git a/authentik/lib/tests/test_config.py b/authentik/lib/tests/test_config.py index 3c253663f9..d2ef0a897b 100644 --- a/authentik/lib/tests/test_config.py +++ b/authentik/lib/tests/test_config.py @@ -1,4 +1,5 @@ """Test config loader""" + import base64 from json import dumps from os import chmod, environ, unlink, write diff --git a/authentik/lib/tests/test_evaluator.py b/authentik/lib/tests/test_evaluator.py index bb029304d6..305fea5fec 100644 --- a/authentik/lib/tests/test_evaluator.py +++ b/authentik/lib/tests/test_evaluator.py @@ -1,4 +1,5 @@ """Test Evaluator base functions""" + from django.test import TestCase from authentik.core.tests.utils import create_test_admin_user diff --git a/authentik/lib/tests/test_http.py b/authentik/lib/tests/test_http.py index 92ec5b4259..4fa8ab6196 100644 --- a/authentik/lib/tests/test_http.py +++ b/authentik/lib/tests/test_http.py @@ -1,4 +1,5 @@ """Test HTTP Helpers""" + from django.test import RequestFactory, TestCase from authentik.core.models import Token, TokenIntents, UserTypes diff --git a/authentik/lib/tests/test_sentry.py b/authentik/lib/tests/test_sentry.py index 958ef50414..e54664d7d5 100644 --- a/authentik/lib/tests/test_sentry.py +++ b/authentik/lib/tests/test_sentry.py @@ -1,4 +1,5 @@ """test sentry integration""" + from django.test import TestCase from authentik.lib.sentry import SentryIgnoredException, before_send diff --git a/authentik/lib/tests/test_serializer_model.py b/authentik/lib/tests/test_serializer_model.py index 08907211ea..aea9d73fca 100644 --- a/authentik/lib/tests/test_serializer_model.py +++ b/authentik/lib/tests/test_serializer_model.py @@ -1,4 +1,5 @@ """base model tests""" + from typing import Callable from django.test import TestCase diff --git a/authentik/lib/tests/test_utils_time.py b/authentik/lib/tests/test_utils_time.py index cc16550e15..43d8f34940 100644 --- a/authentik/lib/tests/test_utils_time.py +++ b/authentik/lib/tests/test_utils_time.py @@ -1,4 +1,5 @@ """Test time utils""" + from datetime import timedelta from django.core.exceptions import ValidationError diff --git a/authentik/lib/tests/utils.py b/authentik/lib/tests/utils.py index 6e15fe61b5..1345a747fd 100644 --- a/authentik/lib/tests/utils.py +++ b/authentik/lib/tests/utils.py @@ -1,4 +1,5 @@ """Test utils""" + from inspect import currentframe from pathlib import Path diff --git a/authentik/lib/utils/errors.py b/authentik/lib/utils/errors.py index f1207c3ced..67bfd43f33 100644 --- a/authentik/lib/utils/errors.py +++ b/authentik/lib/utils/errors.py @@ -1,4 +1,5 @@ """error utils""" + from traceback import extract_tb from authentik.lib.utils.reflection import class_to_path diff --git a/authentik/lib/utils/file.py b/authentik/lib/utils/file.py index 2dc1d84299..d5b6056eb1 100644 --- a/authentik/lib/utils/file.py +++ b/authentik/lib/utils/file.py @@ -1,4 +1,5 @@ """file utils""" + from django.db.models import Model from django.http import HttpResponseBadRequest from rest_framework.fields import BooleanField, CharField, FileField diff --git a/authentik/lib/utils/http.py b/authentik/lib/utils/http.py index f8d33db98c..a8eaf084d8 100644 --- a/authentik/lib/utils/http.py +++ b/authentik/lib/utils/http.py @@ -1,4 +1,5 @@ """http helpers""" + from uuid import uuid4 from django.conf import settings diff --git a/authentik/lib/utils/reflection.py b/authentik/lib/utils/reflection.py index c7dda74149..3d13ca89f4 100644 --- a/authentik/lib/utils/reflection.py +++ b/authentik/lib/utils/reflection.py @@ -1,4 +1,5 @@ """authentik lib reflection utilities""" + import os from importlib import import_module from pathlib import Path diff --git a/authentik/lib/utils/time.py b/authentik/lib/utils/time.py index ebca0ca387..4e7338cdb4 100644 --- a/authentik/lib/utils/time.py +++ b/authentik/lib/utils/time.py @@ -1,4 +1,5 @@ """Time utilities""" + import datetime from hashlib import sha256 from random import randrange, seed diff --git a/authentik/lib/utils/urls.py b/authentik/lib/utils/urls.py index da724817f3..b0e1b5493a 100644 --- a/authentik/lib/utils/urls.py +++ b/authentik/lib/utils/urls.py @@ -1,4 +1,5 @@ """URL-related utils""" + from typing import Optional from urllib.parse import urlparse diff --git a/authentik/lib/validators.py b/authentik/lib/validators.py index 7c67da8c1a..668f84c7b7 100644 --- a/authentik/lib/validators.py +++ b/authentik/lib/validators.py @@ -1,4 +1,5 @@ """Serializer validators""" + from typing import Optional from django.utils.translation import gettext_lazy as _ diff --git a/authentik/lib/views.py b/authentik/lib/views.py index f430b149af..51d4d3b6d1 100644 --- a/authentik/lib/views.py +++ b/authentik/lib/views.py @@ -1,4 +1,5 @@ """authentik helper views""" + from django.http import HttpRequest from django.template.response import TemplateResponse from django.utils.translation import gettext_lazy as _ diff --git a/authentik/lib/xml.py b/authentik/lib/xml.py index d5a7b61c37..ec65d3475a 100644 --- a/authentik/lib/xml.py +++ b/authentik/lib/xml.py @@ -1,4 +1,5 @@ """XML Utilities""" + from lxml.etree import XMLParser, fromstring # nosec diff --git a/authentik/outposts/api/outposts.py b/authentik/outposts/api/outposts.py index 182ec4dbfe..cf905ec105 100644 --- a/authentik/outposts/api/outposts.py +++ b/authentik/outposts/api/outposts.py @@ -1,4 +1,5 @@ """Outpost API Views""" + from dacite.core import from_dict from dacite.exceptions import DaciteError from django_filters.filters import ModelMultipleChoiceFilter diff --git a/authentik/outposts/api/service_connections.py b/authentik/outposts/api/service_connections.py index 7c988474a5..21eac69e49 100644 --- a/authentik/outposts/api/service_connections.py +++ b/authentik/outposts/api/service_connections.py @@ -1,4 +1,5 @@ """Outpost API Views""" + from dataclasses import asdict from django.utils.translation import gettext_lazy as _ diff --git a/authentik/outposts/apps.py b/authentik/outposts/apps.py index dbdf26af41..8cf7874c78 100644 --- a/authentik/outposts/apps.py +++ b/authentik/outposts/apps.py @@ -1,4 +1,5 @@ """authentik outposts app config""" + from prometheus_client import Gauge from structlog.stdlib import get_logger diff --git a/authentik/outposts/consumer.py b/authentik/outposts/consumer.py index 03738b88fb..126526a6b8 100644 --- a/authentik/outposts/consumer.py +++ b/authentik/outposts/consumer.py @@ -1,4 +1,5 @@ """Outpost websocket handler""" + from dataclasses import asdict, dataclass, field from datetime import datetime from enum import IntEnum diff --git a/authentik/outposts/controllers/base.py b/authentik/outposts/controllers/base.py index a3c0cb7d62..d0098df8ca 100644 --- a/authentik/outposts/controllers/base.py +++ b/authentik/outposts/controllers/base.py @@ -1,4 +1,5 @@ """Base Controller""" + from dataclasses import dataclass from typing import Optional diff --git a/authentik/outposts/controllers/docker.py b/authentik/outposts/controllers/docker.py index 48918e25e0..6280ee57f2 100644 --- a/authentik/outposts/controllers/docker.py +++ b/authentik/outposts/controllers/docker.py @@ -1,4 +1,5 @@ """Docker controller""" + from time import sleep from typing import Optional from urllib.parse import urlparse diff --git a/authentik/outposts/controllers/k8s/base.py b/authentik/outposts/controllers/k8s/base.py index ca8542a750..7eac71234f 100644 --- a/authentik/outposts/controllers/k8s/base.py +++ b/authentik/outposts/controllers/k8s/base.py @@ -1,4 +1,5 @@ """Base Kubernetes Reconciler""" + from dataclasses import asdict from json import dumps from typing import TYPE_CHECKING, Generic, Optional, TypeVar diff --git a/authentik/outposts/controllers/k8s/deployment.py b/authentik/outposts/controllers/k8s/deployment.py index e06d971395..fe12a4404e 100644 --- a/authentik/outposts/controllers/k8s/deployment.py +++ b/authentik/outposts/controllers/k8s/deployment.py @@ -1,4 +1,5 @@ """Kubernetes Deployment Reconciler""" + from typing import TYPE_CHECKING from django.utils.text import slugify diff --git a/authentik/outposts/controllers/k8s/secret.py b/authentik/outposts/controllers/k8s/secret.py index ddc3643c6e..ca765b6833 100644 --- a/authentik/outposts/controllers/k8s/secret.py +++ b/authentik/outposts/controllers/k8s/secret.py @@ -1,4 +1,5 @@ """Kubernetes Secret Reconciler""" + from base64 import b64encode from typing import TYPE_CHECKING diff --git a/authentik/outposts/controllers/k8s/service.py b/authentik/outposts/controllers/k8s/service.py index 374e942741..5a26f1c04b 100644 --- a/authentik/outposts/controllers/k8s/service.py +++ b/authentik/outposts/controllers/k8s/service.py @@ -1,4 +1,5 @@ """Kubernetes Service Reconciler""" + from typing import TYPE_CHECKING from kubernetes.client import CoreV1Api, V1Service, V1ServicePort, V1ServiceSpec diff --git a/authentik/outposts/controllers/k8s/service_monitor.py b/authentik/outposts/controllers/k8s/service_monitor.py index 8e00f9c50c..8001ae8553 100644 --- a/authentik/outposts/controllers/k8s/service_monitor.py +++ b/authentik/outposts/controllers/k8s/service_monitor.py @@ -1,4 +1,5 @@ """Kubernetes Prometheus ServiceMonitor Reconciler""" + from dataclasses import asdict, dataclass, field from typing import TYPE_CHECKING diff --git a/authentik/outposts/controllers/k8s/triggers.py b/authentik/outposts/controllers/k8s/triggers.py index 284acd3bc5..f9191a1ff0 100644 --- a/authentik/outposts/controllers/k8s/triggers.py +++ b/authentik/outposts/controllers/k8s/triggers.py @@ -1,4 +1,5 @@ """exceptions used by the kubernetes reconciler to trigger updates""" + from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/outposts/controllers/k8s/utils.py b/authentik/outposts/controllers/k8s/utils.py index e9c83f9753..a0395ffd2c 100644 --- a/authentik/outposts/controllers/k8s/utils.py +++ b/authentik/outposts/controllers/k8s/utils.py @@ -1,4 +1,5 @@ """k8s utils""" + from pathlib import Path from typing import Optional diff --git a/authentik/outposts/controllers/kubernetes.py b/authentik/outposts/controllers/kubernetes.py index e3b3580787..bf8eea2127 100644 --- a/authentik/outposts/controllers/kubernetes.py +++ b/authentik/outposts/controllers/kubernetes.py @@ -1,4 +1,5 @@ """Kubernetes deployment controller""" + from io import StringIO from kubernetes.client import VersionApi, VersionInfo diff --git a/authentik/outposts/docker_ssh.py b/authentik/outposts/docker_ssh.py index b146ca6c9d..2736fe258c 100644 --- a/authentik/outposts/docker_ssh.py +++ b/authentik/outposts/docker_ssh.py @@ -1,4 +1,5 @@ """Docker SSH helper""" + import os from pathlib import Path from tempfile import gettempdir diff --git a/authentik/outposts/docker_tls.py b/authentik/outposts/docker_tls.py index 79e9bdaca6..378295541a 100644 --- a/authentik/outposts/docker_tls.py +++ b/authentik/outposts/docker_tls.py @@ -1,4 +1,5 @@ """Create Docker TLSConfig from CertificateKeyPair""" + from os import unlink from pathlib import Path from tempfile import gettempdir diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index 3460d4ada8..d99751c9f0 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -1,4 +1,5 @@ """Outpost models""" + from dataclasses import asdict, dataclass, field from datetime import datetime from typing import Any, Iterable, Optional diff --git a/authentik/outposts/settings.py b/authentik/outposts/settings.py index 6ce2d52c86..c29f9f64ab 100644 --- a/authentik/outposts/settings.py +++ b/authentik/outposts/settings.py @@ -1,4 +1,5 @@ """Outposts Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/outposts/signals.py b/authentik/outposts/signals.py index 0185dfcb3f..73d05a4b9a 100644 --- a/authentik/outposts/signals.py +++ b/authentik/outposts/signals.py @@ -1,4 +1,5 @@ """authentik outpost signals""" + from django.core.cache import cache from django.db.models import Model from django.db.models.signals import m2m_changed, post_save, pre_delete, pre_save diff --git a/authentik/outposts/tasks.py b/authentik/outposts/tasks.py index 3b085bad58..73405f6cff 100644 --- a/authentik/outposts/tasks.py +++ b/authentik/outposts/tasks.py @@ -1,4 +1,5 @@ """outpost tasks""" + from os import R_OK, access from pathlib import Path from socket import gethostname diff --git a/authentik/outposts/tests/test_api.py b/authentik/outposts/tests/test_api.py index 3edaeb78ee..99b2da915b 100644 --- a/authentik/outposts/tests/test_api.py +++ b/authentik/outposts/tests/test_api.py @@ -1,4 +1,5 @@ """Test outpost service connection API""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/outposts/tests/test_commands.py b/authentik/outposts/tests/test_commands.py index 9e70e8b024..d2fa6229ab 100644 --- a/authentik/outposts/tests/test_commands.py +++ b/authentik/outposts/tests/test_commands.py @@ -1,4 +1,5 @@ """management command tests""" + from io import StringIO from django.core.management import call_command diff --git a/authentik/outposts/tests/test_controller_docker.py b/authentik/outposts/tests/test_controller_docker.py index 1fd00d9c92..8bf8d07ea5 100644 --- a/authentik/outposts/tests/test_controller_docker.py +++ b/authentik/outposts/tests/test_controller_docker.py @@ -1,4 +1,5 @@ """Docker controller tests""" + from django.test import TestCase from docker.models.containers import Container diff --git a/authentik/outposts/tests/test_sa.py b/authentik/outposts/tests/test_sa.py index de73071ae5..59238a2cf8 100644 --- a/authentik/outposts/tests/test_sa.py +++ b/authentik/outposts/tests/test_sa.py @@ -1,4 +1,5 @@ """outpost tests""" + from django.apps import apps from django.contrib.auth.management import create_permissions from django.test import TestCase diff --git a/authentik/outposts/tests/test_ws.py b/authentik/outposts/tests/test_ws.py index ec3d543a37..effb91a84a 100644 --- a/authentik/outposts/tests/test_ws.py +++ b/authentik/outposts/tests/test_ws.py @@ -1,4 +1,5 @@ """Websocket tests""" + from dataclasses import asdict from channels.exceptions import DenyConnection diff --git a/authentik/outposts/urls.py b/authentik/outposts/urls.py index 9d28a01ebd..42bb779241 100644 --- a/authentik/outposts/urls.py +++ b/authentik/outposts/urls.py @@ -1,4 +1,5 @@ """Outpost Websocket URLS""" + from django.urls import path from authentik.core.channels import TokenOutpostMiddleware diff --git a/authentik/policies/api/bindings.py b/authentik/policies/api/bindings.py index 59b28d262e..8ca6d17d29 100644 --- a/authentik/policies/api/bindings.py +++ b/authentik/policies/api/bindings.py @@ -1,4 +1,5 @@ """policy binding API Views""" + from typing import OrderedDict from django.core.exceptions import ObjectDoesNotExist diff --git a/authentik/policies/api/exec.py b/authentik/policies/api/exec.py index 56fb42c907..99a911e3e9 100644 --- a/authentik/policies/api/exec.py +++ b/authentik/policies/api/exec.py @@ -1,4 +1,5 @@ """Serializer for policy execution""" + from rest_framework.fields import BooleanField, CharField, DictField, ListField from rest_framework.relations import PrimaryKeyRelatedField diff --git a/authentik/policies/api/policies.py b/authentik/policies/api/policies.py index 11bdab1907..93ec0a667a 100644 --- a/authentik/policies/api/policies.py +++ b/authentik/policies/api/policies.py @@ -1,4 +1,5 @@ """policy API Views""" + from django.core.cache import cache from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiResponse, extend_schema diff --git a/authentik/policies/apps.py b/authentik/policies/apps.py index eca22c5f7f..7d70dc5a0e 100644 --- a/authentik/policies/apps.py +++ b/authentik/policies/apps.py @@ -1,4 +1,5 @@ """authentik policies app config""" + from prometheus_client import Gauge, Histogram from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/policies/denied.py b/authentik/policies/denied.py index 7cb7d0bb88..faf0736d64 100644 --- a/authentik/policies/denied.py +++ b/authentik/policies/denied.py @@ -1,4 +1,5 @@ """policy http response""" + from typing import Any, Optional from django.http.request import HttpRequest diff --git a/authentik/policies/dummy/api.py b/authentik/policies/dummy/api.py index 344089a0df..d19f2346c3 100644 --- a/authentik/policies/dummy/api.py +++ b/authentik/policies/dummy/api.py @@ -1,4 +1,5 @@ """Dummy Policy API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/policies/dummy/models.py b/authentik/policies/dummy/models.py index eb2c60441c..8167f8f935 100644 --- a/authentik/policies/dummy/models.py +++ b/authentik/policies/dummy/models.py @@ -1,4 +1,5 @@ """Dummy policy""" + from random import SystemRandom from time import sleep diff --git a/authentik/policies/dummy/tests.py b/authentik/policies/dummy/tests.py index 364ae54e7f..c510e3d363 100644 --- a/authentik/policies/dummy/tests.py +++ b/authentik/policies/dummy/tests.py @@ -1,4 +1,5 @@ """dummy policy tests""" + from django.test import TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/policies/dummy/urls.py b/authentik/policies/dummy/urls.py index 1ff9867b3a..1d0036bbe5 100644 --- a/authentik/policies/dummy/urls.py +++ b/authentik/policies/dummy/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.dummy.api import DummyPolicyViewSet api_urlpatterns = [("policies/dummy", DummyPolicyViewSet)] diff --git a/authentik/policies/engine.py b/authentik/policies/engine.py index 58295f3219..76610d626d 100644 --- a/authentik/policies/engine.py +++ b/authentik/policies/engine.py @@ -1,4 +1,5 @@ """authentik policy engine""" + from multiprocessing import Pipe, current_process from multiprocessing.connection import Connection from timeit import default_timer diff --git a/authentik/policies/event_matcher/api.py b/authentik/policies/event_matcher/api.py index ea81a8c054..866067322c 100644 --- a/authentik/policies/event_matcher/api.py +++ b/authentik/policies/event_matcher/api.py @@ -1,4 +1,5 @@ """Event Matcher Policy API""" + from django.utils.translation import gettext as _ from rest_framework.exceptions import ValidationError from rest_framework.fields import ChoiceField diff --git a/authentik/policies/event_matcher/models.py b/authentik/policies/event_matcher/models.py index c4e3ca3736..78af38d5cf 100644 --- a/authentik/policies/event_matcher/models.py +++ b/authentik/policies/event_matcher/models.py @@ -1,4 +1,5 @@ """Event Matcher models""" + from itertools import chain from django.apps import apps diff --git a/authentik/policies/event_matcher/tests.py b/authentik/policies/event_matcher/tests.py index d703125e96..003a21d630 100644 --- a/authentik/policies/event_matcher/tests.py +++ b/authentik/policies/event_matcher/tests.py @@ -1,4 +1,5 @@ """event_matcher tests""" + from django.test import TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/policies/event_matcher/urls.py b/authentik/policies/event_matcher/urls.py index a9a2dfd856..793c8c63a8 100644 --- a/authentik/policies/event_matcher/urls.py +++ b/authentik/policies/event_matcher/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.event_matcher.api import EventMatcherPolicyViewSet api_urlpatterns = [("policies/event_matcher", EventMatcherPolicyViewSet)] diff --git a/authentik/policies/exceptions.py b/authentik/policies/exceptions.py index b6848fd411..928510b5a1 100644 --- a/authentik/policies/exceptions.py +++ b/authentik/policies/exceptions.py @@ -1,4 +1,5 @@ """policy exceptions""" + from typing import Optional from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/policies/expiry/api.py b/authentik/policies/expiry/api.py index 2f72cc6e87..9f1d001106 100644 --- a/authentik/policies/expiry/api.py +++ b/authentik/policies/expiry/api.py @@ -1,4 +1,5 @@ """Password Expiry Policy API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/policies/expiry/models.py b/authentik/policies/expiry/models.py index b4f2b58f6d..6df91ef534 100644 --- a/authentik/policies/expiry/models.py +++ b/authentik/policies/expiry/models.py @@ -1,4 +1,5 @@ """authentik password_expiry_policy Models""" + from datetime import timedelta from django.db import models diff --git a/authentik/policies/expiry/urls.py b/authentik/policies/expiry/urls.py index d5945201ba..d2fef36a37 100644 --- a/authentik/policies/expiry/urls.py +++ b/authentik/policies/expiry/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.expiry.api import PasswordExpiryPolicyViewSet api_urlpatterns = [("policies/password_expiry", PasswordExpiryPolicyViewSet)] diff --git a/authentik/policies/expression/api.py b/authentik/policies/expression/api.py index c587f1b151..6e970eb39d 100644 --- a/authentik/policies/expression/api.py +++ b/authentik/policies/expression/api.py @@ -1,4 +1,5 @@ """Expression Policy API""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/policies/expression/evaluator.py b/authentik/policies/expression/evaluator.py index 4cc167f4bc..bba01553cf 100644 --- a/authentik/policies/expression/evaluator.py +++ b/authentik/policies/expression/evaluator.py @@ -1,4 +1,5 @@ """authentik expression policy evaluator""" + from ipaddress import ip_address from typing import TYPE_CHECKING, Optional diff --git a/authentik/policies/expression/models.py b/authentik/policies/expression/models.py index c1b2c2062d..e70f780562 100644 --- a/authentik/policies/expression/models.py +++ b/authentik/policies/expression/models.py @@ -1,4 +1,5 @@ """authentik expression Policy Models""" + from django.db import models from django.utils.translation import gettext as _ from rest_framework.serializers import BaseSerializer diff --git a/authentik/policies/expression/tests.py b/authentik/policies/expression/tests.py index b94df250d5..53fbc76472 100644 --- a/authentik/policies/expression/tests.py +++ b/authentik/policies/expression/tests.py @@ -1,4 +1,5 @@ """evaluator tests""" + from django.test import RequestFactory, TestCase from guardian.shortcuts import get_anonymous_user from rest_framework.serializers import ValidationError diff --git a/authentik/policies/expression/urls.py b/authentik/policies/expression/urls.py index ad554fea9d..86acb4c2b4 100644 --- a/authentik/policies/expression/urls.py +++ b/authentik/policies/expression/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.expression.api import ExpressionPolicyViewSet api_urlpatterns = [("policies/expression", ExpressionPolicyViewSet)] diff --git a/authentik/policies/models.py b/authentik/policies/models.py index b99aeb5497..ba4c72f720 100644 --- a/authentik/policies/models.py +++ b/authentik/policies/models.py @@ -1,4 +1,5 @@ """Policy base models""" + from uuid import uuid4 from django.db import models diff --git a/authentik/policies/password/api.py b/authentik/policies/password/api.py index c42a0fee10..ec5fa10440 100644 --- a/authentik/policies/password/api.py +++ b/authentik/policies/password/api.py @@ -1,4 +1,5 @@ """Password Policy API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/policies/password/models.py b/authentik/policies/password/models.py index 31765bf20b..8dde8ae24e 100644 --- a/authentik/policies/password/models.py +++ b/authentik/policies/password/models.py @@ -1,4 +1,5 @@ """password policy""" + import re from hashlib import sha1 diff --git a/authentik/policies/password/tests/test_flows.py b/authentik/policies/password/tests/test_flows.py index 8f2e7998e7..1dc18fc9c4 100644 --- a/authentik/policies/password/tests/test_flows.py +++ b/authentik/policies/password/tests/test_flows.py @@ -1,4 +1,5 @@ """Password flow tests""" + from django.urls.base import reverse from authentik.core.tests.utils import create_test_admin_user, create_test_flow diff --git a/authentik/policies/password/tests/test_hibp.py b/authentik/policies/password/tests/test_hibp.py index 9ffd3b0d6f..03ad652d93 100644 --- a/authentik/policies/password/tests/test_hibp.py +++ b/authentik/policies/password/tests/test_hibp.py @@ -1,4 +1,5 @@ """Password Policy HIBP tests""" + from django.test import TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/policies/password/tests/test_policy.py b/authentik/policies/password/tests/test_policy.py index cef0c8156d..4e67a7c4a0 100644 --- a/authentik/policies/password/tests/test_policy.py +++ b/authentik/policies/password/tests/test_policy.py @@ -1,4 +1,5 @@ """Password Policy tests""" + from django.test import TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/policies/password/tests/test_zxcvbn.py b/authentik/policies/password/tests/test_zxcvbn.py index dc2f47c5c4..71a974eb1d 100644 --- a/authentik/policies/password/tests/test_zxcvbn.py +++ b/authentik/policies/password/tests/test_zxcvbn.py @@ -1,4 +1,5 @@ """Password Policy zxcvbn tests""" + from django.test import TestCase from guardian.shortcuts import get_anonymous_user diff --git a/authentik/policies/password/urls.py b/authentik/policies/password/urls.py index c979d62ee1..6a4ed1fc24 100644 --- a/authentik/policies/password/urls.py +++ b/authentik/policies/password/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.password.api import PasswordPolicyViewSet api_urlpatterns = [("policies/password", PasswordPolicyViewSet)] diff --git a/authentik/policies/process.py b/authentik/policies/process.py index 61ada16b73..3e568fd32f 100644 --- a/authentik/policies/process.py +++ b/authentik/policies/process.py @@ -1,4 +1,5 @@ """authentik policy task""" + from multiprocessing import get_context from multiprocessing.connection import Connection from typing import Optional diff --git a/authentik/policies/reputation/api.py b/authentik/policies/reputation/api.py index 885f6c1620..deb66eb1bb 100644 --- a/authentik/policies/reputation/api.py +++ b/authentik/policies/reputation/api.py @@ -1,4 +1,5 @@ """Reputation policy API Views""" + from django.utils.translation import gettext_lazy as _ from rest_framework import mixins from rest_framework.exceptions import ValidationError diff --git a/authentik/policies/reputation/apps.py b/authentik/policies/reputation/apps.py index 94a080a70f..4c3628ac71 100644 --- a/authentik/policies/reputation/apps.py +++ b/authentik/policies/reputation/apps.py @@ -1,4 +1,5 @@ """Authentik reputation_policy app config""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/policies/reputation/models.py b/authentik/policies/reputation/models.py index ea8ac2bd6c..8326124571 100644 --- a/authentik/policies/reputation/models.py +++ b/authentik/policies/reputation/models.py @@ -1,4 +1,5 @@ """authentik reputation request policy""" + from datetime import timedelta from uuid import uuid4 diff --git a/authentik/policies/reputation/settings.py b/authentik/policies/reputation/settings.py index b51ecc1879..72abd27cf7 100644 --- a/authentik/policies/reputation/settings.py +++ b/authentik/policies/reputation/settings.py @@ -1,4 +1,5 @@ """Reputation Settings""" + from celery.schedules import crontab CELERY_BEAT_SCHEDULE = { diff --git a/authentik/policies/reputation/signals.py b/authentik/policies/reputation/signals.py index 5307672d45..354b8492db 100644 --- a/authentik/policies/reputation/signals.py +++ b/authentik/policies/reputation/signals.py @@ -1,4 +1,5 @@ """authentik reputation request signals""" + from django.contrib.auth.signals import user_logged_in from django.core.cache import cache from django.dispatch import receiver diff --git a/authentik/policies/reputation/tasks.py b/authentik/policies/reputation/tasks.py index 94d080d7c9..f04ccac99a 100644 --- a/authentik/policies/reputation/tasks.py +++ b/authentik/policies/reputation/tasks.py @@ -1,4 +1,5 @@ """Reputation tasks""" + from django.core.cache import cache from structlog.stdlib import get_logger diff --git a/authentik/policies/reputation/tests.py b/authentik/policies/reputation/tests.py index 76a8cea4a5..96429f5fa6 100644 --- a/authentik/policies/reputation/tests.py +++ b/authentik/policies/reputation/tests.py @@ -1,4 +1,5 @@ """test reputation signals and policy""" + from django.core.cache import cache from django.test import RequestFactory, TestCase diff --git a/authentik/policies/reputation/urls.py b/authentik/policies/reputation/urls.py index 7af81ae5c4..b3f1d55ad2 100644 --- a/authentik/policies/reputation/urls.py +++ b/authentik/policies/reputation/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.reputation.api import ReputationPolicyViewSet, ReputationViewSet api_urlpatterns = [ diff --git a/authentik/policies/signals.py b/authentik/policies/signals.py index 767d733cbd..7b806eeacc 100644 --- a/authentik/policies/signals.py +++ b/authentik/policies/signals.py @@ -1,4 +1,5 @@ """authentik policy signals""" + from django.core.cache import cache from django.db import connection from django.db.models.signals import post_save diff --git a/authentik/policies/tests/test_bindings_api.py b/authentik/policies/tests/test_bindings_api.py index 17046d6caa..3d1c42bba6 100644 --- a/authentik/policies/tests/test_bindings_api.py +++ b/authentik/policies/tests/test_bindings_api.py @@ -1,4 +1,5 @@ """Test bindings API""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/policies/tests/test_engine.py b/authentik/policies/tests/test_engine.py index d173e40ac4..89b49ef1cb 100644 --- a/authentik/policies/tests/test_engine.py +++ b/authentik/policies/tests/test_engine.py @@ -1,4 +1,5 @@ """policy engine tests""" + from django.core.cache import cache from django.test import TestCase diff --git a/authentik/policies/tests/test_policies_api.py b/authentik/policies/tests/test_policies_api.py index ecb83925b8..ad9f9fe23f 100644 --- a/authentik/policies/tests/test_policies_api.py +++ b/authentik/policies/tests/test_policies_api.py @@ -1,4 +1,5 @@ """Test policies API""" + from json import loads from unittest.mock import MagicMock, patch diff --git a/authentik/policies/tests/test_process.py b/authentik/policies/tests/test_process.py index 6c7c941c7c..20e6db9f51 100644 --- a/authentik/policies/tests/test_process.py +++ b/authentik/policies/tests/test_process.py @@ -1,4 +1,5 @@ """policy process tests""" + from django.contrib.auth.models import AnonymousUser from django.core.cache import cache from django.test import RequestFactory, TestCase diff --git a/authentik/policies/types.py b/authentik/policies/types.py index c9e2e8d869..be14dcea8c 100644 --- a/authentik/policies/types.py +++ b/authentik/policies/types.py @@ -1,4 +1,5 @@ """policy structures""" + from __future__ import annotations from dataclasses import dataclass diff --git a/authentik/policies/urls.py b/authentik/policies/urls.py index 377578080e..b8b5ba9191 100644 --- a/authentik/policies/urls.py +++ b/authentik/policies/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.policies.api.bindings import PolicyBindingViewSet from authentik.policies.api.policies import PolicyViewSet diff --git a/authentik/policies/utils.py b/authentik/policies/utils.py index 8ac49024e1..b4332f712a 100644 --- a/authentik/policies/utils.py +++ b/authentik/policies/utils.py @@ -1,4 +1,5 @@ """Policy Utils""" + from typing import Any diff --git a/authentik/policies/views.py b/authentik/policies/views.py index 293be99f72..99f28dd224 100644 --- a/authentik/policies/views.py +++ b/authentik/policies/views.py @@ -1,4 +1,5 @@ """authentik access helper classes""" + from typing import Any, Optional from django.contrib import messages diff --git a/authentik/providers/ldap/api.py b/authentik/providers/ldap/api.py index 21438ef432..70fa78ccae 100644 --- a/authentik/providers/ldap/api.py +++ b/authentik/providers/ldap/api.py @@ -1,4 +1,5 @@ """LDAPProvider API Views""" + from django.db.models import QuerySet from django.db.models.query import Q from django_filters.filters import BooleanFilter diff --git a/authentik/providers/ldap/apps.py b/authentik/providers/ldap/apps.py index 7adc551ffd..ffd5d75310 100644 --- a/authentik/providers/ldap/apps.py +++ b/authentik/providers/ldap/apps.py @@ -1,4 +1,5 @@ """authentik ldap provider app config""" + from django.apps import AppConfig diff --git a/authentik/providers/ldap/controllers/docker.py b/authentik/providers/ldap/controllers/docker.py index ccb9e0a328..f61066c9c4 100644 --- a/authentik/providers/ldap/controllers/docker.py +++ b/authentik/providers/ldap/controllers/docker.py @@ -1,4 +1,5 @@ """LDAP Provider Docker Controller""" + from authentik.outposts.controllers.base import DeploymentPort from authentik.outposts.controllers.docker import DockerController from authentik.outposts.models import DockerServiceConnection, Outpost diff --git a/authentik/providers/ldap/controllers/kubernetes.py b/authentik/providers/ldap/controllers/kubernetes.py index da55e838ec..e980f6f5d1 100644 --- a/authentik/providers/ldap/controllers/kubernetes.py +++ b/authentik/providers/ldap/controllers/kubernetes.py @@ -1,4 +1,5 @@ """LDAP Provider Kubernetes Controller""" + from authentik.outposts.controllers.base import DeploymentPort from authentik.outposts.controllers.kubernetes import KubernetesController from authentik.outposts.models import KubernetesServiceConnection, Outpost diff --git a/authentik/providers/ldap/models.py b/authentik/providers/ldap/models.py index d03f5e1f3e..42dbbdb13f 100644 --- a/authentik/providers/ldap/models.py +++ b/authentik/providers/ldap/models.py @@ -1,4 +1,5 @@ """LDAP Provider""" + from typing import Iterable, Optional from django.db import models diff --git a/authentik/providers/ldap/tests/test_api.py b/authentik/providers/ldap/tests/test_api.py index 1271f7640f..3ecec6dd2c 100644 --- a/authentik/providers/ldap/tests/test_api.py +++ b/authentik/providers/ldap/tests/test_api.py @@ -1,4 +1,5 @@ """LDAP Provider API tests""" + from json import loads from django.urls import reverse diff --git a/authentik/providers/ldap/urls.py b/authentik/providers/ldap/urls.py index ae916f9f74..24c339bfb8 100644 --- a/authentik/providers/ldap/urls.py +++ b/authentik/providers/ldap/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.providers.ldap.api import LDAPOutpostConfigViewSet, LDAPProviderViewSet api_urlpatterns = [ diff --git a/authentik/providers/oauth2/api/providers.py b/authentik/providers/oauth2/api/providers.py index 03d88d2904..66a3939929 100644 --- a/authentik/providers/oauth2/api/providers.py +++ b/authentik/providers/oauth2/api/providers.py @@ -1,4 +1,5 @@ """OAuth2Provider API Views""" + from copy import copy from django.urls import reverse diff --git a/authentik/providers/oauth2/api/scopes.py b/authentik/providers/oauth2/api/scopes.py index 5b88b698ac..f23fadc278 100644 --- a/authentik/providers/oauth2/api/scopes.py +++ b/authentik/providers/oauth2/api/scopes.py @@ -1,4 +1,5 @@ """OAuth2Provider API Views""" + from django_filters.filters import AllValuesMultipleFilter from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes diff --git a/authentik/providers/oauth2/api/tokens.py b/authentik/providers/oauth2/api/tokens.py index 86b12cef70..efe8dd9625 100644 --- a/authentik/providers/oauth2/api/tokens.py +++ b/authentik/providers/oauth2/api/tokens.py @@ -1,4 +1,5 @@ """OAuth2Provider API Views""" + from json import dumps from django_filters.rest_framework import DjangoFilterBackend diff --git a/authentik/providers/oauth2/apps.py b/authentik/providers/oauth2/apps.py index 75a39d7646..1a33aba798 100644 --- a/authentik/providers/oauth2/apps.py +++ b/authentik/providers/oauth2/apps.py @@ -1,4 +1,5 @@ """authentik oauth provider app config""" + from django.apps import AppConfig diff --git a/authentik/providers/oauth2/errors.py b/authentik/providers/oauth2/errors.py index fd124cb91b..35dd85912b 100644 --- a/authentik/providers/oauth2/errors.py +++ b/authentik/providers/oauth2/errors.py @@ -1,4 +1,5 @@ """OAuth errors""" + from typing import Optional from urllib.parse import quote, urlparse diff --git a/authentik/providers/oauth2/id_token.py b/authentik/providers/oauth2/id_token.py index b51116f8d2..8970b4612b 100644 --- a/authentik/providers/oauth2/id_token.py +++ b/authentik/providers/oauth2/id_token.py @@ -1,4 +1,5 @@ """id_token utils""" + from dataclasses import asdict, dataclass, field from typing import TYPE_CHECKING, Any, Optional, Union diff --git a/authentik/providers/oauth2/models.py b/authentik/providers/oauth2/models.py index 2917f607fe..f5225b1534 100644 --- a/authentik/providers/oauth2/models.py +++ b/authentik/providers/oauth2/models.py @@ -1,4 +1,5 @@ """OAuth Provider Models""" + import base64 import binascii import json diff --git a/authentik/providers/oauth2/tests/test_api.py b/authentik/providers/oauth2/tests/test_api.py index 5aecb3a0eb..827b68b0c4 100644 --- a/authentik/providers/oauth2/tests/test_api.py +++ b/authentik/providers/oauth2/tests/test_api.py @@ -1,4 +1,5 @@ """Test OAuth2 API""" + from json import loads from sys import version_info from unittest import skipUnless diff --git a/authentik/providers/oauth2/tests/test_authorize.py b/authentik/providers/oauth2/tests/test_authorize.py index cc82c3b9c3..a6569a3b0c 100644 --- a/authentik/providers/oauth2/tests/test_authorize.py +++ b/authentik/providers/oauth2/tests/test_authorize.py @@ -1,4 +1,5 @@ """Test authorize view""" + from unittest.mock import MagicMock, patch from django.test import RequestFactory diff --git a/authentik/providers/oauth2/tests/test_device_backchannel.py b/authentik/providers/oauth2/tests/test_device_backchannel.py index a191e128bf..6a30ce0310 100644 --- a/authentik/providers/oauth2/tests/test_device_backchannel.py +++ b/authentik/providers/oauth2/tests/test_device_backchannel.py @@ -1,4 +1,5 @@ """Device backchannel tests""" + from json import loads from django.urls import reverse diff --git a/authentik/providers/oauth2/tests/test_device_init.py b/authentik/providers/oauth2/tests/test_device_init.py index 5e36492014..9a763d9853 100644 --- a/authentik/providers/oauth2/tests/test_device_init.py +++ b/authentik/providers/oauth2/tests/test_device_init.py @@ -1,4 +1,5 @@ """Device init tests""" + from urllib.parse import urlencode from django.urls import reverse diff --git a/authentik/providers/oauth2/tests/test_introspect.py b/authentik/providers/oauth2/tests/test_introspect.py index dd35d5f6f9..26a8001644 100644 --- a/authentik/providers/oauth2/tests/test_introspect.py +++ b/authentik/providers/oauth2/tests/test_introspect.py @@ -1,4 +1,5 @@ """Test introspect view""" + import json from base64 import b64encode from dataclasses import asdict diff --git a/authentik/providers/oauth2/tests/test_jwks.py b/authentik/providers/oauth2/tests/test_jwks.py index 2a678b4a9a..53792c2f6b 100644 --- a/authentik/providers/oauth2/tests/test_jwks.py +++ b/authentik/providers/oauth2/tests/test_jwks.py @@ -1,4 +1,5 @@ """JWKS tests""" + import base64 import json diff --git a/authentik/providers/oauth2/tests/test_revoke.py b/authentik/providers/oauth2/tests/test_revoke.py index 74acbec02f..a0312ef71a 100644 --- a/authentik/providers/oauth2/tests/test_revoke.py +++ b/authentik/providers/oauth2/tests/test_revoke.py @@ -1,4 +1,5 @@ """Test revoke view""" + import json from base64 import b64encode from dataclasses import asdict diff --git a/authentik/providers/oauth2/tests/test_token.py b/authentik/providers/oauth2/tests/test_token.py index 5904d38be4..659abb6e9f 100644 --- a/authentik/providers/oauth2/tests/test_token.py +++ b/authentik/providers/oauth2/tests/test_token.py @@ -1,4 +1,5 @@ """Test token view""" + from base64 import b64encode from json import dumps diff --git a/authentik/providers/oauth2/tests/test_token_cc.py b/authentik/providers/oauth2/tests/test_token_cc.py index 81f595d63c..a766a687ab 100644 --- a/authentik/providers/oauth2/tests/test_token_cc.py +++ b/authentik/providers/oauth2/tests/test_token_cc.py @@ -1,4 +1,5 @@ """Test token view""" + from json import loads from django.test import RequestFactory diff --git a/authentik/providers/oauth2/tests/test_token_cc_jwt_source.py b/authentik/providers/oauth2/tests/test_token_cc_jwt_source.py index a95c7c3a5a..df508ce311 100644 --- a/authentik/providers/oauth2/tests/test_token_cc_jwt_source.py +++ b/authentik/providers/oauth2/tests/test_token_cc_jwt_source.py @@ -1,4 +1,5 @@ """Test token view""" + from datetime import datetime, timedelta from json import loads diff --git a/authentik/providers/oauth2/tests/test_token_device.py b/authentik/providers/oauth2/tests/test_token_device.py index 0d7474f927..308b8d2d28 100644 --- a/authentik/providers/oauth2/tests/test_token_device.py +++ b/authentik/providers/oauth2/tests/test_token_device.py @@ -1,4 +1,5 @@ """Test token view""" + from json import loads from django.test import RequestFactory diff --git a/authentik/providers/oauth2/tests/test_token_pkce.py b/authentik/providers/oauth2/tests/test_token_pkce.py index 9cbad7fc05..f892ee4bd8 100644 --- a/authentik/providers/oauth2/tests/test_token_pkce.py +++ b/authentik/providers/oauth2/tests/test_token_pkce.py @@ -1,4 +1,5 @@ """Test token view""" + from base64 import b64encode, urlsafe_b64encode from hashlib import sha256 diff --git a/authentik/providers/oauth2/tests/test_userinfo.py b/authentik/providers/oauth2/tests/test_userinfo.py index 431b2f18f7..96e48754f7 100644 --- a/authentik/providers/oauth2/tests/test_userinfo.py +++ b/authentik/providers/oauth2/tests/test_userinfo.py @@ -1,4 +1,5 @@ """Test userinfo view""" + import json from dataclasses import asdict diff --git a/authentik/providers/oauth2/tests/utils.py b/authentik/providers/oauth2/tests/utils.py index 77bad32529..8904f0224d 100644 --- a/authentik/providers/oauth2/tests/utils.py +++ b/authentik/providers/oauth2/tests/utils.py @@ -1,4 +1,5 @@ """OAuth test helpers""" + from typing import Any from django.test import TestCase diff --git a/authentik/providers/oauth2/urls.py b/authentik/providers/oauth2/urls.py index f310fa1bc1..9eefeb582e 100644 --- a/authentik/providers/oauth2/urls.py +++ b/authentik/providers/oauth2/urls.py @@ -1,4 +1,5 @@ """OAuth provider URLs""" + from django.urls import path from django.views.generic.base import RedirectView diff --git a/authentik/providers/oauth2/urls_root.py b/authentik/providers/oauth2/urls_root.py index 9f7fe05ac8..02d89e9dd6 100644 --- a/authentik/providers/oauth2/urls_root.py +++ b/authentik/providers/oauth2/urls_root.py @@ -1,4 +1,5 @@ """authentik oauth_provider urls""" + from django.contrib.auth.decorators import login_required from django.urls import include, path diff --git a/authentik/providers/oauth2/utils.py b/authentik/providers/oauth2/utils.py index 513994b805..2dda028e73 100644 --- a/authentik/providers/oauth2/utils.py +++ b/authentik/providers/oauth2/utils.py @@ -1,4 +1,5 @@ """OAuth2/OpenID Utils""" + import re from base64 import b64decode from binascii import Error @@ -161,9 +162,9 @@ def protected_resource_view(scopes: list[str]): raise BearerTokenError("insufficient_scope") except BearerTokenError as error: response = HttpResponse(status=error.status) - response[ - "WWW-Authenticate" - ] = f'error="{error.code}", error_description="{error.description}"' + response["WWW-Authenticate"] = ( + f'error="{error.code}", error_description="{error.description}"' + ) return response kwargs["token"] = token CTX_AUTH_VIA.set("oauth_token") diff --git a/authentik/providers/oauth2/views/authorize.py b/authentik/providers/oauth2/views/authorize.py index 0baa942b49..bc99b04390 100644 --- a/authentik/providers/oauth2/views/authorize.py +++ b/authentik/providers/oauth2/views/authorize.py @@ -1,4 +1,5 @@ """authentik OAuth2 Authorization views""" + from dataclasses import InitVar, dataclass, field from datetime import timedelta from hashlib import sha256 diff --git a/authentik/providers/oauth2/views/device_backchannel.py b/authentik/providers/oauth2/views/device_backchannel.py index 79f723a737..32b674a719 100644 --- a/authentik/providers/oauth2/views/device_backchannel.py +++ b/authentik/providers/oauth2/views/device_backchannel.py @@ -1,4 +1,5 @@ """Device flow views""" + from typing import Optional from urllib.parse import urlencode diff --git a/authentik/providers/oauth2/views/device_finish.py b/authentik/providers/oauth2/views/device_finish.py index 774ef1df03..e543510956 100644 --- a/authentik/providers/oauth2/views/device_finish.py +++ b/authentik/providers/oauth2/views/device_finish.py @@ -1,4 +1,5 @@ """Device flow finish stage""" + from django.http import HttpResponse from rest_framework.fields import CharField diff --git a/authentik/providers/oauth2/views/device_init.py b/authentik/providers/oauth2/views/device_init.py index 35123b7450..c038e8577b 100644 --- a/authentik/providers/oauth2/views/device_init.py +++ b/authentik/providers/oauth2/views/device_init.py @@ -1,4 +1,5 @@ """Device flow views""" + from typing import Optional from django.http import HttpRequest, HttpResponse diff --git a/authentik/providers/oauth2/views/introspection.py b/authentik/providers/oauth2/views/introspection.py index ca702eda73..7c2d096f70 100644 --- a/authentik/providers/oauth2/views/introspection.py +++ b/authentik/providers/oauth2/views/introspection.py @@ -1,4 +1,5 @@ """authentik OAuth2 Token Introspection Views""" + from dataclasses import dataclass, field from django.http import HttpRequest, HttpResponse diff --git a/authentik/providers/oauth2/views/jwks.py b/authentik/providers/oauth2/views/jwks.py index 166d583f4e..88e4328f8a 100644 --- a/authentik/providers/oauth2/views/jwks.py +++ b/authentik/providers/oauth2/views/jwks.py @@ -1,4 +1,5 @@ """authentik OAuth2 JWKS Views""" + from base64 import b64encode, urlsafe_b64encode from typing import Optional diff --git a/authentik/providers/oauth2/views/provider.py b/authentik/providers/oauth2/views/provider.py index ab6fbc328e..1843f45ae5 100644 --- a/authentik/providers/oauth2/views/provider.py +++ b/authentik/providers/oauth2/views/provider.py @@ -1,4 +1,5 @@ """authentik OAuth2 OpenID well-known views""" + from typing import Any from django.http import HttpRequest, HttpResponse, JsonResponse diff --git a/authentik/providers/oauth2/views/token.py b/authentik/providers/oauth2/views/token.py index 4467579c3f..58a85507aa 100644 --- a/authentik/providers/oauth2/views/token.py +++ b/authentik/providers/oauth2/views/token.py @@ -1,4 +1,5 @@ """authentik OAuth2 Token views""" + from base64 import urlsafe_b64encode from dataclasses import InitVar, dataclass from datetime import datetime diff --git a/authentik/providers/oauth2/views/token_revoke.py b/authentik/providers/oauth2/views/token_revoke.py index e4a5bd0788..c0809ba725 100644 --- a/authentik/providers/oauth2/views/token_revoke.py +++ b/authentik/providers/oauth2/views/token_revoke.py @@ -1,4 +1,5 @@ """Token revocation endpoint""" + from dataclasses import dataclass from django.http import Http404, HttpRequest, HttpResponse diff --git a/authentik/providers/oauth2/views/userinfo.py b/authentik/providers/oauth2/views/userinfo.py index 061e43fc8e..19a3fb5bc9 100644 --- a/authentik/providers/oauth2/views/userinfo.py +++ b/authentik/providers/oauth2/views/userinfo.py @@ -1,4 +1,5 @@ """authentik OAuth2 OpenID Userinfo views""" + from typing import Any, Optional from deepmerge import always_merger diff --git a/authentik/providers/proxy/api.py b/authentik/providers/proxy/api.py index 30f77d83d1..3da9a98450 100644 --- a/authentik/providers/proxy/api.py +++ b/authentik/providers/proxy/api.py @@ -1,4 +1,5 @@ """ProxyProvider API Views""" + from typing import Any, Optional from django.utils.translation import gettext_lazy as _ diff --git a/authentik/providers/proxy/apps.py b/authentik/providers/proxy/apps.py index 2149bc7eff..a5c0af761c 100644 --- a/authentik/providers/proxy/apps.py +++ b/authentik/providers/proxy/apps.py @@ -1,4 +1,5 @@ """authentik Proxy app""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/providers/proxy/controllers/docker.py b/authentik/providers/proxy/controllers/docker.py index 32cc9ff337..a95f699599 100644 --- a/authentik/providers/proxy/controllers/docker.py +++ b/authentik/providers/proxy/controllers/docker.py @@ -1,4 +1,5 @@ """Proxy Provider Docker Controller""" + from urllib.parse import urlparse from authentik.outposts.controllers.base import DeploymentPort @@ -26,16 +27,16 @@ class ProxyDockerController(DockerController): traefik_name = self.name labels = super()._get_labels() labels["traefik.enable"] = "true" - labels[ - f"traefik.http.routers.{traefik_name}-router.rule" - ] = f"Host({','.join(hosts)}) && PathPrefix(`/outpost.goauthentik.io`)" + labels[f"traefik.http.routers.{traefik_name}-router.rule"] = ( + f"Host({','.join(hosts)}) && PathPrefix(`/outpost.goauthentik.io`)" + ) labels[f"traefik.http.routers.{traefik_name}-router.tls"] = "true" labels[f"traefik.http.routers.{traefik_name}-router.service"] = f"{traefik_name}-service" - labels[ - f"traefik.http.services.{traefik_name}-service.loadbalancer.healthcheck.path" - ] = "/outpost.goauthentik.io/ping" - labels[ - f"traefik.http.services.{traefik_name}-service.loadbalancer.healthcheck.port" - ] = "9300" + labels[f"traefik.http.services.{traefik_name}-service.loadbalancer.healthcheck.path"] = ( + "/outpost.goauthentik.io/ping" + ) + labels[f"traefik.http.services.{traefik_name}-service.loadbalancer.healthcheck.port"] = ( + "9300" + ) labels[f"traefik.http.services.{traefik_name}-service.loadbalancer.server.port"] = "9000" return labels diff --git a/authentik/providers/proxy/controllers/k8s/ingress.py b/authentik/providers/proxy/controllers/k8s/ingress.py index e0cc54dba6..842490821c 100644 --- a/authentik/providers/proxy/controllers/k8s/ingress.py +++ b/authentik/providers/proxy/controllers/k8s/ingress.py @@ -1,4 +1,5 @@ """Kubernetes Ingress Reconciler""" + from typing import TYPE_CHECKING from urllib.parse import urlparse diff --git a/authentik/providers/proxy/controllers/k8s/traefik.py b/authentik/providers/proxy/controllers/k8s/traefik.py index 4be6438674..406619231f 100644 --- a/authentik/providers/proxy/controllers/k8s/traefik.py +++ b/authentik/providers/proxy/controllers/k8s/traefik.py @@ -1,4 +1,5 @@ """Kubernetes Traefik Middleware Reconciler""" + from authentik.outposts.controllers.k8s.base import KubernetesObjectReconciler from authentik.outposts.controllers.kubernetes import KubernetesController from authentik.providers.proxy.controllers.k8s.traefik_2 import Traefik2MiddlewareReconciler diff --git a/authentik/providers/proxy/controllers/k8s/traefik_2.py b/authentik/providers/proxy/controllers/k8s/traefik_2.py index 907659efa0..16e4011bc2 100644 --- a/authentik/providers/proxy/controllers/k8s/traefik_2.py +++ b/authentik/providers/proxy/controllers/k8s/traefik_2.py @@ -1,4 +1,5 @@ """Kubernetes Traefik Middleware Reconciler""" + from typing import TYPE_CHECKING from authentik.providers.proxy.controllers.k8s.traefik_3 import Traefik3MiddlewareReconciler diff --git a/authentik/providers/proxy/controllers/k8s/traefik_3.py b/authentik/providers/proxy/controllers/k8s/traefik_3.py index c6c5a6c4c7..2e101ce2df 100644 --- a/authentik/providers/proxy/controllers/k8s/traefik_3.py +++ b/authentik/providers/proxy/controllers/k8s/traefik_3.py @@ -1,4 +1,5 @@ """Kubernetes Traefik Middleware Reconciler""" + from dataclasses import asdict, dataclass, field from typing import TYPE_CHECKING diff --git a/authentik/providers/proxy/controllers/kubernetes.py b/authentik/providers/proxy/controllers/kubernetes.py index 22d9f40838..73b0ea8bc0 100644 --- a/authentik/providers/proxy/controllers/kubernetes.py +++ b/authentik/providers/proxy/controllers/kubernetes.py @@ -1,4 +1,5 @@ """Proxy Provider Kubernetes Controller""" + from authentik.outposts.controllers.base import DeploymentPort from authentik.outposts.controllers.kubernetes import KubernetesController from authentik.outposts.models import KubernetesServiceConnection, Outpost @@ -17,8 +18,8 @@ class ProxyKubernetesController(KubernetesController): DeploymentPort(9443, "https", "tcp"), ] self.reconcilers[IngressReconciler.reconciler_name()] = IngressReconciler - self.reconcilers[ - TraefikMiddlewareReconciler.reconciler_name() - ] = TraefikMiddlewareReconciler + self.reconcilers[TraefikMiddlewareReconciler.reconciler_name()] = ( + TraefikMiddlewareReconciler + ) self.reconcile_order.append(IngressReconciler.reconciler_name()) self.reconcile_order.append(TraefikMiddlewareReconciler.reconciler_name()) diff --git a/authentik/providers/proxy/models.py b/authentik/providers/proxy/models.py index 18aef3d3e8..9ec1e4d71e 100644 --- a/authentik/providers/proxy/models.py +++ b/authentik/providers/proxy/models.py @@ -1,4 +1,5 @@ """authentik proxy models""" + import string from random import SystemRandom from typing import Iterable, Optional diff --git a/authentik/providers/proxy/signals.py b/authentik/providers/proxy/signals.py index 3e199d3c38..7ada0492b4 100644 --- a/authentik/providers/proxy/signals.py +++ b/authentik/providers/proxy/signals.py @@ -1,4 +1,5 @@ """Proxy provider signals""" + from django.contrib.auth.signals import user_logged_out from django.db.models.signals import pre_delete from django.dispatch import receiver diff --git a/authentik/providers/proxy/tasks.py b/authentik/providers/proxy/tasks.py index 1496ff6ec8..8b2f94c035 100644 --- a/authentik/providers/proxy/tasks.py +++ b/authentik/providers/proxy/tasks.py @@ -1,4 +1,5 @@ """proxy provider tasks""" + from hashlib import sha256 from asgiref.sync import async_to_sync diff --git a/authentik/providers/proxy/tests.py b/authentik/providers/proxy/tests.py index 5c5b77a6e2..b0686cc221 100644 --- a/authentik/providers/proxy/tests.py +++ b/authentik/providers/proxy/tests.py @@ -1,4 +1,5 @@ """proxy provider tests""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/providers/proxy/urls.py b/authentik/providers/proxy/urls.py index 384cc1d6f6..dc86a5dba8 100644 --- a/authentik/providers/proxy/urls.py +++ b/authentik/providers/proxy/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.providers.proxy.api import ProxyOutpostConfigViewSet, ProxyProviderViewSet api_urlpatterns = [ diff --git a/authentik/providers/radius/api.py b/authentik/providers/radius/api.py index af43424bfe..e2ac193b82 100644 --- a/authentik/providers/radius/api.py +++ b/authentik/providers/radius/api.py @@ -1,4 +1,5 @@ """RadiusProvider API Views""" + from rest_framework.fields import CharField, ListField from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet diff --git a/authentik/providers/radius/apps.py b/authentik/providers/radius/apps.py index 5972cdf76d..ac84219117 100644 --- a/authentik/providers/radius/apps.py +++ b/authentik/providers/radius/apps.py @@ -1,4 +1,5 @@ """authentik radius provider app config""" + from django.apps import AppConfig diff --git a/authentik/providers/radius/controllers/docker.py b/authentik/providers/radius/controllers/docker.py index cf17fd36a3..a05cdfed63 100644 --- a/authentik/providers/radius/controllers/docker.py +++ b/authentik/providers/radius/controllers/docker.py @@ -1,4 +1,5 @@ """Radius Provider Docker Controller""" + from authentik.outposts.controllers.base import DeploymentPort from authentik.outposts.controllers.docker import DockerController from authentik.outposts.models import DockerServiceConnection, Outpost diff --git a/authentik/providers/radius/controllers/kubernetes.py b/authentik/providers/radius/controllers/kubernetes.py index cdec2cd9ac..dbc0d45374 100644 --- a/authentik/providers/radius/controllers/kubernetes.py +++ b/authentik/providers/radius/controllers/kubernetes.py @@ -1,4 +1,5 @@ """Radius Provider Kubernetes Controller""" + from authentik.outposts.controllers.base import DeploymentPort from authentik.outposts.controllers.kubernetes import KubernetesController from authentik.outposts.models import KubernetesServiceConnection, Outpost diff --git a/authentik/providers/radius/models.py b/authentik/providers/radius/models.py index 781023fd62..3fb32b576a 100644 --- a/authentik/providers/radius/models.py +++ b/authentik/providers/radius/models.py @@ -1,4 +1,5 @@ """Radius Provider""" + from typing import Optional, Type from django.db import models diff --git a/authentik/providers/radius/urls.py b/authentik/providers/radius/urls.py index 9cbef52ef0..56e304b0cf 100644 --- a/authentik/providers/radius/urls.py +++ b/authentik/providers/radius/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.providers.radius.api import RadiusOutpostConfigViewSet, RadiusProviderViewSet api_urlpatterns = [ diff --git a/authentik/providers/saml/api/property_mapping.py b/authentik/providers/saml/api/property_mapping.py index 33ca6e4bd3..0849b54150 100644 --- a/authentik/providers/saml/api/property_mapping.py +++ b/authentik/providers/saml/api/property_mapping.py @@ -1,4 +1,5 @@ """SAML Property mappings API Views""" + from django_filters.filters import AllValuesMultipleFilter from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes diff --git a/authentik/providers/saml/api/providers.py b/authentik/providers/saml/api/providers.py index 1e2eaa20e8..62782c8c62 100644 --- a/authentik/providers/saml/api/providers.py +++ b/authentik/providers/saml/api/providers.py @@ -1,4 +1,5 @@ """SAMLProvider API Views""" + from copy import copy from xml.etree.ElementTree import ParseError # nosec @@ -222,9 +223,9 @@ class SAMLProviderViewSet(UsedByMixin, ModelViewSet): metadata = proc.build_entity_descriptor() if "download" in request.query_params: response = HttpResponse(metadata, content_type="application/xml") - response[ - "Content-Disposition" - ] = f'attachment; filename="{provider.name}_authentik_meta.xml"' + response["Content-Disposition"] = ( + f'attachment; filename="{provider.name}_authentik_meta.xml"' + ) return response return Response({"metadata": metadata}) except Provider.application.RelatedObjectDoesNotExist: # pylint: disable=no-member diff --git a/authentik/providers/saml/exceptions.py b/authentik/providers/saml/exceptions.py index b32453c6c7..10f87a9724 100644 --- a/authentik/providers/saml/exceptions.py +++ b/authentik/providers/saml/exceptions.py @@ -1,4 +1,5 @@ """authentik SAML IDP Exceptions""" + from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/providers/saml/models.py b/authentik/providers/saml/models.py index 1a706df8e0..e7955cae8b 100644 --- a/authentik/providers/saml/models.py +++ b/authentik/providers/saml/models.py @@ -1,4 +1,5 @@ """authentik saml_idp Models""" + from typing import Optional from django.db import models diff --git a/authentik/providers/saml/processors/assertion.py b/authentik/providers/saml/processors/assertion.py index 15940dec63..fff0b2a551 100644 --- a/authentik/providers/saml/processors/assertion.py +++ b/authentik/providers/saml/processors/assertion.py @@ -1,4 +1,5 @@ """SAML Assertion generator""" + from hashlib import sha256 from types import GeneratorType diff --git a/authentik/providers/saml/processors/authn_request_parser.py b/authentik/providers/saml/processors/authn_request_parser.py index 5587cb6951..2e86d8ba49 100644 --- a/authentik/providers/saml/processors/authn_request_parser.py +++ b/authentik/providers/saml/processors/authn_request_parser.py @@ -1,4 +1,5 @@ """SAML AuthNRequest Parser and dataclass""" + from base64 import b64decode from dataclasses import dataclass from typing import Optional diff --git a/authentik/providers/saml/processors/logout_request_parser.py b/authentik/providers/saml/processors/logout_request_parser.py index df15694fd9..6bb6ec6288 100644 --- a/authentik/providers/saml/processors/logout_request_parser.py +++ b/authentik/providers/saml/processors/logout_request_parser.py @@ -1,4 +1,5 @@ """LogoutRequest parser""" + from base64 import b64decode from dataclasses import dataclass from typing import Optional diff --git a/authentik/providers/saml/processors/metadata.py b/authentik/providers/saml/processors/metadata.py index 5aecf24f67..ec2641cde2 100644 --- a/authentik/providers/saml/processors/metadata.py +++ b/authentik/providers/saml/processors/metadata.py @@ -1,4 +1,5 @@ """SAML Identity Provider Metadata Processor""" + from hashlib import sha256 from typing import Iterator, Optional diff --git a/authentik/providers/saml/processors/metadata_parser.py b/authentik/providers/saml/processors/metadata_parser.py index db284ee221..c9e8fb27d5 100644 --- a/authentik/providers/saml/processors/metadata_parser.py +++ b/authentik/providers/saml/processors/metadata_parser.py @@ -1,4 +1,5 @@ """SAML ServiceProvider Metadata Parser and dataclass""" + from dataclasses import dataclass from typing import Optional diff --git a/authentik/providers/saml/tests/test_api.py b/authentik/providers/saml/tests/test_api.py index de86d5cbb2..8ccb0c29a2 100644 --- a/authentik/providers/saml/tests/test_api.py +++ b/authentik/providers/saml/tests/test_api.py @@ -1,4 +1,5 @@ """SAML Provider API Tests""" + from json import loads from tempfile import TemporaryFile diff --git a/authentik/providers/saml/tests/test_auth_n_request.py b/authentik/providers/saml/tests/test_auth_n_request.py index df19eb7368..88a563ef87 100644 --- a/authentik/providers/saml/tests/test_auth_n_request.py +++ b/authentik/providers/saml/tests/test_auth_n_request.py @@ -1,4 +1,5 @@ """Test AuthN Request generator and parser""" + from base64 import b64encode from django.http.request import QueryDict diff --git a/authentik/providers/saml/tests/test_logout_request.py b/authentik/providers/saml/tests/test_logout_request.py index f09361fb76..d7dde73e95 100644 --- a/authentik/providers/saml/tests/test_logout_request.py +++ b/authentik/providers/saml/tests/test_logout_request.py @@ -1,4 +1,5 @@ """logout request tests""" + from django.test import TestCase from authentik.blueprints.tests import apply_blueprint diff --git a/authentik/providers/saml/tests/test_metadata.py b/authentik/providers/saml/tests/test_metadata.py index bc4156b5b9..ce4819e3cf 100644 --- a/authentik/providers/saml/tests/test_metadata.py +++ b/authentik/providers/saml/tests/test_metadata.py @@ -1,4 +1,5 @@ """Test Service-Provider Metadata Parser""" + import xmlsec from defusedxml.lxml import fromstring from django.test import RequestFactory, TestCase diff --git a/authentik/providers/saml/tests/test_schema.py b/authentik/providers/saml/tests/test_schema.py index 479e993fdf..34e33cf8ac 100644 --- a/authentik/providers/saml/tests/test_schema.py +++ b/authentik/providers/saml/tests/test_schema.py @@ -1,4 +1,5 @@ """Test Requests and Responses against schema""" + from base64 import b64encode from django.test import TestCase diff --git a/authentik/providers/saml/urls.py b/authentik/providers/saml/urls.py index 02dda0c383..9a684ca2c9 100644 --- a/authentik/providers/saml/urls.py +++ b/authentik/providers/saml/urls.py @@ -1,4 +1,5 @@ """authentik SAML IDP URLs""" + from django.urls import path from authentik.providers.saml.api.property_mapping import SAMLPropertyMappingViewSet diff --git a/authentik/providers/saml/utils/__init__.py b/authentik/providers/saml/utils/__init__.py index 16c18a18e7..41e474665d 100644 --- a/authentik/providers/saml/utils/__init__.py +++ b/authentik/providers/saml/utils/__init__.py @@ -1,4 +1,5 @@ """Small helper functions""" + import uuid diff --git a/authentik/providers/saml/utils/encoding.py b/authentik/providers/saml/utils/encoding.py index cdc0f7ce3b..0631e627c8 100644 --- a/authentik/providers/saml/utils/encoding.py +++ b/authentik/providers/saml/utils/encoding.py @@ -1,4 +1,5 @@ """Wrappers to de/encode and de/inflate strings""" + import base64 import zlib diff --git a/authentik/providers/saml/utils/time.py b/authentik/providers/saml/utils/time.py index c807315a28..678fa299d2 100644 --- a/authentik/providers/saml/utils/time.py +++ b/authentik/providers/saml/utils/time.py @@ -1,4 +1,5 @@ """Time utilities""" + import datetime from typing import Optional diff --git a/authentik/providers/saml/views/flows.py b/authentik/providers/saml/views/flows.py index 479686bd03..af0c142e93 100644 --- a/authentik/providers/saml/views/flows.py +++ b/authentik/providers/saml/views/flows.py @@ -1,4 +1,5 @@ """authentik SAML IDP Views""" + from django.core.validators import URLValidator from django.http import HttpRequest, HttpResponse from django.http.response import HttpResponseBadRequest diff --git a/authentik/providers/saml/views/metadata.py b/authentik/providers/saml/views/metadata.py index a4335839d0..e76b997804 100644 --- a/authentik/providers/saml/views/metadata.py +++ b/authentik/providers/saml/views/metadata.py @@ -1,4 +1,5 @@ """metadata redirect""" + from django.http import Http404, HttpRequest, HttpResponse from django.shortcuts import get_object_or_404, redirect from django.urls import reverse diff --git a/authentik/providers/saml/views/slo.py b/authentik/providers/saml/views/slo.py index aecdadec73..ef7b7edfd5 100644 --- a/authentik/providers/saml/views/slo.py +++ b/authentik/providers/saml/views/slo.py @@ -1,4 +1,5 @@ """SLO Views""" + from typing import Optional from django.http import HttpRequest diff --git a/authentik/providers/saml/views/sso.py b/authentik/providers/saml/views/sso.py index 99844150ae..0cf281bb62 100644 --- a/authentik/providers/saml/views/sso.py +++ b/authentik/providers/saml/views/sso.py @@ -1,4 +1,5 @@ """authentik SAML IDP Views""" + from typing import Optional from django.http import Http404, HttpRequest, HttpResponse diff --git a/authentik/providers/scim/api/property_mapping.py b/authentik/providers/scim/api/property_mapping.py index 80c9093294..bdfbcca4ec 100644 --- a/authentik/providers/scim/api/property_mapping.py +++ b/authentik/providers/scim/api/property_mapping.py @@ -1,4 +1,5 @@ """scim Property mappings API Views""" + from django_filters.filters import AllValuesMultipleFilter from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes diff --git a/authentik/providers/scim/api/providers.py b/authentik/providers/scim/api/providers.py index 1b095c7bb0..e3a4e6588a 100644 --- a/authentik/providers/scim/api/providers.py +++ b/authentik/providers/scim/api/providers.py @@ -1,4 +1,5 @@ """SCIM Provider API Views""" + from django.utils.text import slugify from drf_spectacular.utils import OpenApiResponse, extend_schema from guardian.shortcuts import get_objects_for_user diff --git a/authentik/providers/scim/apps.py b/authentik/providers/scim/apps.py index dffd4b8b57..efba40a977 100644 --- a/authentik/providers/scim/apps.py +++ b/authentik/providers/scim/apps.py @@ -1,4 +1,5 @@ """authentik SCIM Provider app config""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/providers/scim/clients/__init__.py b/authentik/providers/scim/clients/__init__.py index 0e2e573b5a..2290fb00b5 100644 --- a/authentik/providers/scim/clients/__init__.py +++ b/authentik/providers/scim/clients/__init__.py @@ -1,3 +1,4 @@ """SCIM constants""" + PAGE_SIZE = 100 PAGE_TIMEOUT = 60 * 60 * 0.5 # Half an hour diff --git a/authentik/providers/scim/clients/base.py b/authentik/providers/scim/clients/base.py index b214c30e4c..4038a14942 100644 --- a/authentik/providers/scim/clients/base.py +++ b/authentik/providers/scim/clients/base.py @@ -1,4 +1,5 @@ """SCIM Client""" + from typing import Generic, TypeVar from pydantic import ValidationError diff --git a/authentik/providers/scim/clients/exceptions.py b/authentik/providers/scim/clients/exceptions.py index 62c7e78c5c..dc6d7a7b2b 100644 --- a/authentik/providers/scim/clients/exceptions.py +++ b/authentik/providers/scim/clients/exceptions.py @@ -1,4 +1,5 @@ """SCIM Client exceptions""" + from typing import Optional from pydantic import ValidationError diff --git a/authentik/providers/scim/clients/group.py b/authentik/providers/scim/clients/group.py index 306cc21f99..467bd93037 100644 --- a/authentik/providers/scim/clients/group.py +++ b/authentik/providers/scim/clients/group.py @@ -1,4 +1,5 @@ """Group client""" + from deepmerge import always_merger from pydantic import ValidationError from pydanticscim.group import GroupMember diff --git a/authentik/providers/scim/clients/schema.py b/authentik/providers/scim/clients/schema.py index b1c2682556..9e96710059 100644 --- a/authentik/providers/scim/clients/schema.py +++ b/authentik/providers/scim/clients/schema.py @@ -1,4 +1,5 @@ """Custom SCIM schemas""" + from typing import Optional from pydanticscim.group import Group as BaseGroup diff --git a/authentik/providers/scim/clients/user.py b/authentik/providers/scim/clients/user.py index 11ef6a159c..84b2df6394 100644 --- a/authentik/providers/scim/clients/user.py +++ b/authentik/providers/scim/clients/user.py @@ -1,4 +1,5 @@ """User client""" + from deepmerge import always_merger from pydantic import ValidationError diff --git a/authentik/providers/scim/management/commands/scim_sync.py b/authentik/providers/scim/management/commands/scim_sync.py index 40fa068a62..25924c2a08 100644 --- a/authentik/providers/scim/management/commands/scim_sync.py +++ b/authentik/providers/scim/management/commands/scim_sync.py @@ -1,4 +1,5 @@ """SCIM Sync""" + from structlog.stdlib import get_logger from authentik.providers.scim.models import SCIMProvider diff --git a/authentik/providers/scim/models.py b/authentik/providers/scim/models.py index 821e3cceca..7f58288e2e 100644 --- a/authentik/providers/scim/models.py +++ b/authentik/providers/scim/models.py @@ -1,4 +1,5 @@ """SCIM Provider models""" + from django.core.cache import cache from django.db import models from django.db.models import QuerySet diff --git a/authentik/providers/scim/settings.py b/authentik/providers/scim/settings.py index 02b2e6e6ee..bf28b8ef12 100644 --- a/authentik/providers/scim/settings.py +++ b/authentik/providers/scim/settings.py @@ -1,4 +1,5 @@ """SCIM task Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/providers/scim/signals.py b/authentik/providers/scim/signals.py index e799044d60..a40d36f3b5 100644 --- a/authentik/providers/scim/signals.py +++ b/authentik/providers/scim/signals.py @@ -1,4 +1,5 @@ """SCIM provider signals""" + from django.db.models import Model from django.db.models.signals import m2m_changed, post_save, pre_delete from django.dispatch import receiver diff --git a/authentik/providers/scim/tasks.py b/authentik/providers/scim/tasks.py index 5b529dede5..a98392a2ec 100644 --- a/authentik/providers/scim/tasks.py +++ b/authentik/providers/scim/tasks.py @@ -1,4 +1,5 @@ """SCIM Provider tasks""" + from typing import Any, Optional from celery.result import allow_join_result diff --git a/authentik/providers/scim/tests/test_client.py b/authentik/providers/scim/tests/test_client.py index 2e298cb1b4..0d3dd57e51 100644 --- a/authentik/providers/scim/tests/test_client.py +++ b/authentik/providers/scim/tests/test_client.py @@ -1,4 +1,5 @@ """SCIM Client tests""" + from django.test import TestCase from requests_mock import Mocker diff --git a/authentik/providers/scim/tests/test_group.py b/authentik/providers/scim/tests/test_group.py index f6739f3a10..9aaa245a72 100644 --- a/authentik/providers/scim/tests/test_group.py +++ b/authentik/providers/scim/tests/test_group.py @@ -1,4 +1,5 @@ """SCIM Group tests""" + from json import loads from django.test import TestCase diff --git a/authentik/providers/scim/tests/test_membership.py b/authentik/providers/scim/tests/test_membership.py index d1e0d07f07..b8e31ec660 100644 --- a/authentik/providers/scim/tests/test_membership.py +++ b/authentik/providers/scim/tests/test_membership.py @@ -1,4 +1,5 @@ """SCIM Membership tests""" + from django.test import TestCase from requests_mock import Mocker diff --git a/authentik/providers/scim/tests/test_user.py b/authentik/providers/scim/tests/test_user.py index 0582b1de7e..2f22e82b1d 100644 --- a/authentik/providers/scim/tests/test_user.py +++ b/authentik/providers/scim/tests/test_user.py @@ -1,4 +1,5 @@ """SCIM User tests""" + from json import loads from django.test import TestCase diff --git a/authentik/providers/scim/urls.py b/authentik/providers/scim/urls.py index 045862dba9..80c90cd5df 100644 --- a/authentik/providers/scim/urls.py +++ b/authentik/providers/scim/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.providers.scim.api.property_mapping import SCIMMappingViewSet from authentik.providers.scim.api.providers import SCIMProviderViewSet diff --git a/authentik/rbac/api/rbac.py b/authentik/rbac/api/rbac.py index 2ce5b8d33f..517217ec64 100644 --- a/authentik/rbac/api/rbac.py +++ b/authentik/rbac/api/rbac.py @@ -1,4 +1,5 @@ """common RBAC serializers""" + from django.apps import apps from django.contrib.auth.models import Permission from django.db.models import QuerySet diff --git a/authentik/rbac/api/rbac_assigned_by_roles.py b/authentik/rbac/api/rbac_assigned_by_roles.py index 5dcdcab129..c96a3e82ed 100644 --- a/authentik/rbac/api/rbac_assigned_by_roles.py +++ b/authentik/rbac/api/rbac_assigned_by_roles.py @@ -1,4 +1,5 @@ """common RBAC serializers""" + from django.db.models import Q, QuerySet from django.db.transaction import atomic from django_filters.filters import CharFilter, ChoiceFilter diff --git a/authentik/rbac/api/rbac_assigned_by_users.py b/authentik/rbac/api/rbac_assigned_by_users.py index d69b30a522..b2e1fb7163 100644 --- a/authentik/rbac/api/rbac_assigned_by_users.py +++ b/authentik/rbac/api/rbac_assigned_by_users.py @@ -1,4 +1,5 @@ """common RBAC serializers""" + from django.db.models import Q, QuerySet from django.db.transaction import atomic from django_filters.filters import CharFilter, ChoiceFilter diff --git a/authentik/rbac/api/rbac_roles.py b/authentik/rbac/api/rbac_roles.py index 1ef13c115e..37124b2393 100644 --- a/authentik/rbac/api/rbac_roles.py +++ b/authentik/rbac/api/rbac_roles.py @@ -1,4 +1,5 @@ """common RBAC serializers""" + from typing import Optional from django.apps import apps diff --git a/authentik/rbac/api/rbac_users.py b/authentik/rbac/api/rbac_users.py index 6de2e8bcee..0909c6e537 100644 --- a/authentik/rbac/api/rbac_users.py +++ b/authentik/rbac/api/rbac_users.py @@ -1,4 +1,5 @@ """common RBAC serializers""" + from typing import Optional from django.apps import apps diff --git a/authentik/rbac/api/roles.py b/authentik/rbac/api/roles.py index 36eef8a193..96df4a7039 100644 --- a/authentik/rbac/api/roles.py +++ b/authentik/rbac/api/roles.py @@ -1,4 +1,5 @@ """RBAC Roles""" + from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet diff --git a/authentik/rbac/apps.py b/authentik/rbac/apps.py index f4e8a43f6f..e04979bce3 100644 --- a/authentik/rbac/apps.py +++ b/authentik/rbac/apps.py @@ -1,4 +1,5 @@ """authentik rbac app config""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/rbac/filters.py b/authentik/rbac/filters.py index 22f5a768e5..1b083fd75d 100644 --- a/authentik/rbac/filters.py +++ b/authentik/rbac/filters.py @@ -1,4 +1,5 @@ """RBAC API Filter""" + from django.db.models import QuerySet from rest_framework.exceptions import PermissionDenied from rest_framework.request import Request diff --git a/authentik/rbac/models.py b/authentik/rbac/models.py index b3ff7e493e..4d6ae48f60 100644 --- a/authentik/rbac/models.py +++ b/authentik/rbac/models.py @@ -1,4 +1,5 @@ """RBAC models""" + from typing import Optional from uuid import uuid4 diff --git a/authentik/rbac/permissions.py b/authentik/rbac/permissions.py index 011a027158..882be0e0f7 100644 --- a/authentik/rbac/permissions.py +++ b/authentik/rbac/permissions.py @@ -1,4 +1,5 @@ """RBAC Permissions""" + from django.db.models import Model from rest_framework.permissions import BasePermission, DjangoObjectPermissions from rest_framework.request import Request diff --git a/authentik/rbac/signals.py b/authentik/rbac/signals.py index f3bbbc036d..b9650ac3e4 100644 --- a/authentik/rbac/signals.py +++ b/authentik/rbac/signals.py @@ -1,4 +1,5 @@ """rbac signals""" + from django.contrib.auth.models import Group as DjangoGroup from django.db.models.signals import m2m_changed, pre_save from django.db.transaction import atomic diff --git a/authentik/rbac/tests/test_api_assigned_by_roles.py b/authentik/rbac/tests/test_api_assigned_by_roles.py index 07032e8050..a7ea300721 100644 --- a/authentik/rbac/tests/test_api_assigned_by_roles.py +++ b/authentik/rbac/tests/test_api_assigned_by_roles.py @@ -1,4 +1,5 @@ """Test RoleAssignedPermissionViewSet api""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/rbac/tests/test_api_assigned_by_users.py b/authentik/rbac/tests/test_api_assigned_by_users.py index fa1238495b..5df6f5fd0e 100644 --- a/authentik/rbac/tests/test_api_assigned_by_users.py +++ b/authentik/rbac/tests/test_api_assigned_by_users.py @@ -1,4 +1,5 @@ """Test UserAssignedPermissionViewSet api""" + from django.urls import reverse from guardian.shortcuts import assign_perm from rest_framework.test import APITestCase diff --git a/authentik/rbac/tests/test_api_filters.py b/authentik/rbac/tests/test_api_filters.py index 91bd707d7d..424b18bce3 100644 --- a/authentik/rbac/tests/test_api_filters.py +++ b/authentik/rbac/tests/test_api_filters.py @@ -1,4 +1,5 @@ """RBAC role tests""" + from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/rbac/tests/test_roles.py b/authentik/rbac/tests/test_roles.py index f9cbfdabb8..0a2c4ba3db 100644 --- a/authentik/rbac/tests/test_roles.py +++ b/authentik/rbac/tests/test_roles.py @@ -1,4 +1,5 @@ """RBAC role tests""" + from rest_framework.test import APITestCase from authentik.core.models import Group diff --git a/authentik/rbac/urls.py b/authentik/rbac/urls.py index 586264a503..e39ef8f1bb 100644 --- a/authentik/rbac/urls.py +++ b/authentik/rbac/urls.py @@ -1,4 +1,5 @@ """RBAC API urls""" + from authentik.rbac.api.rbac import RBACPermissionViewSet from authentik.rbac.api.rbac_assigned_by_roles import RoleAssignedPermissionViewSet from authentik.rbac.api.rbac_assigned_by_users import UserAssignedPermissionViewSet diff --git a/authentik/recovery/apps.py b/authentik/recovery/apps.py index e9f33fd6b1..85bbfa7b71 100644 --- a/authentik/recovery/apps.py +++ b/authentik/recovery/apps.py @@ -1,4 +1,5 @@ """authentik Recovery app config""" + from django.apps import AppConfig diff --git a/authentik/recovery/lib.py b/authentik/recovery/lib.py index b700c4a8ff..3aa386a2f9 100644 --- a/authentik/recovery/lib.py +++ b/authentik/recovery/lib.py @@ -1,4 +1,5 @@ """Recovery helper functions.""" + from datetime import datetime from django.urls import reverse diff --git a/authentik/recovery/management/commands/create_admin_group.py b/authentik/recovery/management/commands/create_admin_group.py index cb2b1fe11c..979717877e 100644 --- a/authentik/recovery/management/commands/create_admin_group.py +++ b/authentik/recovery/management/commands/create_admin_group.py @@ -1,4 +1,5 @@ """authentik recovery create_admin_group""" + from django.utils.translation import gettext as _ from authentik.core.models import User diff --git a/authentik/recovery/management/commands/create_recovery_key.py b/authentik/recovery/management/commands/create_recovery_key.py index 9e41ba9445..870daefd29 100644 --- a/authentik/recovery/management/commands/create_recovery_key.py +++ b/authentik/recovery/management/commands/create_recovery_key.py @@ -1,4 +1,5 @@ """authentik recovery createkey command""" + from datetime import timedelta from getpass import getuser diff --git a/authentik/recovery/tests.py b/authentik/recovery/tests.py index 4255424582..b6cca0c59d 100644 --- a/authentik/recovery/tests.py +++ b/authentik/recovery/tests.py @@ -1,4 +1,5 @@ """recovery tests""" + from io import StringIO from django.core.management import call_command diff --git a/authentik/recovery/views.py b/authentik/recovery/views.py index 200b44f52d..db06c58b8a 100644 --- a/authentik/recovery/views.py +++ b/authentik/recovery/views.py @@ -1,4 +1,5 @@ """recovery views""" + from django.contrib import messages from django.contrib.auth import login from django.http import Http404, HttpRequest, HttpResponse diff --git a/authentik/root/asgi.py b/authentik/root/asgi.py index 6412c114e0..c6cbab73ae 100644 --- a/authentik/root/asgi.py +++ b/authentik/root/asgi.py @@ -6,6 +6,7 @@ It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ """ + import django from channels.routing import ProtocolTypeRouter, URLRouter from defusedxml import defuse_stdlib diff --git a/authentik/root/asgi_middleware.py b/authentik/root/asgi_middleware.py index 33c5195e2c..cecdb54e05 100644 --- a/authentik/root/asgi_middleware.py +++ b/authentik/root/asgi_middleware.py @@ -1,4 +1,5 @@ """ASGI middleware""" + from channels.db import database_sync_to_async from channels.sessions import InstanceSessionWrapper as UpstreamInstanceSessionWrapper from channels.sessions import SessionMiddleware as UpstreamSessionMiddleware diff --git a/authentik/root/celery.py b/authentik/root/celery.py index d88cb44d97..48645673b2 100644 --- a/authentik/root/celery.py +++ b/authentik/root/celery.py @@ -1,4 +1,5 @@ """authentik core celery""" + import os from contextvars import ContextVar from logging.config import dictConfig diff --git a/authentik/root/db/base.py b/authentik/root/db/base.py index 70e8595f71..c1297998e6 100644 --- a/authentik/root/db/base.py +++ b/authentik/root/db/base.py @@ -1,4 +1,5 @@ """authentik database backend""" + from django_tenants.postgresql_backend.base import DatabaseWrapper as BaseDatabaseWrapper from authentik.lib.config import CONFIG diff --git a/authentik/root/install_id.py b/authentik/root/install_id.py index e786b2b659..5dc64472b9 100644 --- a/authentik/root/install_id.py +++ b/authentik/root/install_id.py @@ -1,4 +1,5 @@ """install ID""" + from functools import lru_cache from uuid import uuid4 diff --git a/authentik/root/messages/consumer.py b/authentik/root/messages/consumer.py index 3fa9301b10..964ea6bba1 100644 --- a/authentik/root/messages/consumer.py +++ b/authentik/root/messages/consumer.py @@ -1,4 +1,5 @@ """websocket Message consumer""" + from channels.generic.websocket import JsonWebsocketConsumer from django.core.cache import cache diff --git a/authentik/root/messages/storage.py b/authentik/root/messages/storage.py index 4f9262d8d5..4fb9760254 100644 --- a/authentik/root/messages/storage.py +++ b/authentik/root/messages/storage.py @@ -1,4 +1,5 @@ """Channels Messages storage""" + from asgiref.sync import async_to_sync from channels.layers import get_channel_layer from django.contrib.messages.storage.base import Message diff --git a/authentik/root/middleware.py b/authentik/root/middleware.py index ba5465d4f8..d61ed5510d 100644 --- a/authentik/root/middleware.py +++ b/authentik/root/middleware.py @@ -1,4 +1,5 @@ """Dynamically set SameSite depending if the upstream connection is TLS or not""" + from hashlib import sha512 from time import time from timeit import default_timer diff --git a/authentik/root/monitoring.py b/authentik/root/monitoring.py index 7b4ba1e4f6..5234a81d6d 100644 --- a/authentik/root/monitoring.py +++ b/authentik/root/monitoring.py @@ -1,4 +1,5 @@ """Metrics view""" + from base64 import b64encode from django.conf import settings diff --git a/authentik/root/sessions/pickle.py b/authentik/root/sessions/pickle.py index 94c7f6fc04..a01eaaf8ad 100644 --- a/authentik/root/sessions/pickle.py +++ b/authentik/root/sessions/pickle.py @@ -1,6 +1,7 @@ """ Module for abstract serializer/unserializer base classes. """ + import pickle # nosec diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 4798e4392c..5aabaa62f5 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -1,4 +1,5 @@ """root settings for authentik""" + import importlib import os from collections import OrderedDict @@ -417,9 +418,9 @@ if CONFIG.get("storage.media.backend", "file") == "s3": "signature_version": "s3v4", "file_overwrite": False, "location": "media", - "url_protocol": "https:" - if CONFIG.get("storage.media.s3.secure_urls", True) - else "http:", + "url_protocol": ( + "https:" if CONFIG.get("storage.media.s3.secure_urls", True) else "http:" + ), "custom_domain": CONFIG.get("storage.media.s3.custom_domain", None), }, } diff --git a/authentik/root/storages.py b/authentik/root/storages.py index 347200f964..0fbc4260b4 100644 --- a/authentik/root/storages.py +++ b/authentik/root/storages.py @@ -1,4 +1,5 @@ """authentik storage backends""" + import os from django.conf import settings diff --git a/authentik/root/test_runner.py b/authentik/root/test_runner.py index 59956febb8..e9d90270e7 100644 --- a/authentik/root/test_runner.py +++ b/authentik/root/test_runner.py @@ -1,4 +1,5 @@ """Integrate ./manage.py test with pytest""" + import os from argparse import ArgumentParser from unittest import TestCase diff --git a/authentik/root/tests.py b/authentik/root/tests.py index 444a4ada63..f0cee99fe9 100644 --- a/authentik/root/tests.py +++ b/authentik/root/tests.py @@ -1,4 +1,5 @@ """root tests""" + from base64 import b64encode from django.conf import settings diff --git a/authentik/root/urls.py b/authentik/root/urls.py index b3913090a4..0da8ee814c 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -1,4 +1,5 @@ """authentik URL Configuration""" + from django.urls import include, path from structlog.stdlib import get_logger diff --git a/authentik/root/websocket.py b/authentik/root/websocket.py index df32a35af1..5d2a0be250 100644 --- a/authentik/root/websocket.py +++ b/authentik/root/websocket.py @@ -1,4 +1,5 @@ """root Websocket URLS""" + from importlib import import_module from structlog.stdlib import get_logger diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index e4bdf79d73..34def44b03 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -1,4 +1,5 @@ """Source API Views""" + from typing import Any, Optional from django.core.cache import cache diff --git a/authentik/sources/ldap/apps.py b/authentik/sources/ldap/apps.py index eb1f5e2c08..a7380f4f70 100644 --- a/authentik/sources/ldap/apps.py +++ b/authentik/sources/ldap/apps.py @@ -1,4 +1,5 @@ """authentik ldap source config""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/sources/ldap/auth.py b/authentik/sources/ldap/auth.py index 508aacb3ea..7d351c8be5 100644 --- a/authentik/sources/ldap/auth.py +++ b/authentik/sources/ldap/auth.py @@ -1,4 +1,5 @@ """authentik LDAP Authentication Backend""" + from typing import Optional from django.http import HttpRequest diff --git a/authentik/sources/ldap/management/commands/ldap_check_connection.py b/authentik/sources/ldap/management/commands/ldap_check_connection.py index c3caed86b7..0bde7bfec5 100644 --- a/authentik/sources/ldap/management/commands/ldap_check_connection.py +++ b/authentik/sources/ldap/management/commands/ldap_check_connection.py @@ -1,4 +1,5 @@ """LDAP Connection check""" + from json import dumps from structlog.stdlib import get_logger diff --git a/authentik/sources/ldap/management/commands/ldap_sync.py b/authentik/sources/ldap/management/commands/ldap_sync.py index fd0a48d635..22404ad49e 100644 --- a/authentik/sources/ldap/management/commands/ldap_sync.py +++ b/authentik/sources/ldap/management/commands/ldap_sync.py @@ -1,4 +1,5 @@ """LDAP Sync""" + from structlog.stdlib import get_logger from authentik.sources.ldap.models import LDAPSource diff --git a/authentik/sources/ldap/models.py b/authentik/sources/ldap/models.py index c9ecda4efd..1c3552879b 100644 --- a/authentik/sources/ldap/models.py +++ b/authentik/sources/ldap/models.py @@ -1,4 +1,5 @@ """authentik LDAP Models""" + from os import chmod from os.path import dirname, exists from shutil import rmtree diff --git a/authentik/sources/ldap/password.py b/authentik/sources/ldap/password.py index 0593b2078f..2b8d70fb49 100644 --- a/authentik/sources/ldap/password.py +++ b/authentik/sources/ldap/password.py @@ -1,4 +1,5 @@ """Help validate and update passwords in LDAP""" + from enum import IntFlag from re import split from typing import Optional diff --git a/authentik/sources/ldap/settings.py b/authentik/sources/ldap/settings.py index b141687f59..c82dbeb0cb 100644 --- a/authentik/sources/ldap/settings.py +++ b/authentik/sources/ldap/settings.py @@ -1,4 +1,5 @@ """LDAP Settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/sources/ldap/signals.py b/authentik/sources/ldap/signals.py index f95662e335..3213f9fc2a 100644 --- a/authentik/sources/ldap/signals.py +++ b/authentik/sources/ldap/signals.py @@ -1,4 +1,5 @@ """authentik ldap source signals""" + from typing import Any from django.db.models.signals import post_save diff --git a/authentik/sources/ldap/sync/base.py b/authentik/sources/ldap/sync/base.py index d3ae11f321..1ebacfc643 100644 --- a/authentik/sources/ldap/sync/base.py +++ b/authentik/sources/ldap/sync/base.py @@ -1,4 +1,5 @@ """Sync LDAP Users and groups into authentik""" + from typing import Any, Generator from django.conf import settings diff --git a/authentik/sources/ldap/sync/groups.py b/authentik/sources/ldap/sync/groups.py index 92781c3ac9..2f2f67307c 100644 --- a/authentik/sources/ldap/sync/groups.py +++ b/authentik/sources/ldap/sync/groups.py @@ -1,4 +1,5 @@ """Sync LDAP Users and groups into authentik""" + from typing import Generator from django.core.exceptions import FieldError diff --git a/authentik/sources/ldap/sync/membership.py b/authentik/sources/ldap/sync/membership.py index 134f12380d..987ac59b9c 100644 --- a/authentik/sources/ldap/sync/membership.py +++ b/authentik/sources/ldap/sync/membership.py @@ -1,4 +1,5 @@ """Sync LDAP Users and groups into authentik""" + from typing import Any, Generator, Optional from django.db.models import Q diff --git a/authentik/sources/ldap/sync/users.py b/authentik/sources/ldap/sync/users.py index 6c4d3bd0e5..7e3afef54a 100644 --- a/authentik/sources/ldap/sync/users.py +++ b/authentik/sources/ldap/sync/users.py @@ -1,4 +1,5 @@ """Sync LDAP Users into authentik""" + from typing import Generator from django.core.exceptions import FieldError diff --git a/authentik/sources/ldap/sync/vendor/freeipa.py b/authentik/sources/ldap/sync/vendor/freeipa.py index d8014f7161..e8fc046834 100644 --- a/authentik/sources/ldap/sync/vendor/freeipa.py +++ b/authentik/sources/ldap/sync/vendor/freeipa.py @@ -1,4 +1,5 @@ """FreeIPA specific""" + from datetime import datetime, timezone from typing import Any, Generator diff --git a/authentik/sources/ldap/sync/vendor/ms_ad.py b/authentik/sources/ldap/sync/vendor/ms_ad.py index 342b104d97..fef2653622 100644 --- a/authentik/sources/ldap/sync/vendor/ms_ad.py +++ b/authentik/sources/ldap/sync/vendor/ms_ad.py @@ -1,4 +1,5 @@ """Active Directory specific""" + from datetime import datetime, timezone from enum import IntFlag from typing import Any, Generator diff --git a/authentik/sources/ldap/tasks.py b/authentik/sources/ldap/tasks.py index 0b5dd5ab26..0f58349028 100644 --- a/authentik/sources/ldap/tasks.py +++ b/authentik/sources/ldap/tasks.py @@ -1,4 +1,5 @@ """LDAP Sync tasks""" + from typing import Optional from uuid import uuid4 diff --git a/authentik/sources/ldap/tests/test_api.py b/authentik/sources/ldap/tests/test_api.py index 9618fa6aed..e7dcf42320 100644 --- a/authentik/sources/ldap/tests/test_api.py +++ b/authentik/sources/ldap/tests/test_api.py @@ -1,4 +1,5 @@ """LDAP Source API tests""" + from rest_framework.test import APITestCase from authentik.lib.generators import generate_key diff --git a/authentik/sources/ldap/tests/test_auth.py b/authentik/sources/ldap/tests/test_auth.py index d764715b1a..48f04bf293 100644 --- a/authentik/sources/ldap/tests/test_auth.py +++ b/authentik/sources/ldap/tests/test_auth.py @@ -1,4 +1,5 @@ """LDAP Source tests""" + from unittest.mock import MagicMock, Mock, patch from django.db.models import Q diff --git a/authentik/sources/ldap/tests/test_password.py b/authentik/sources/ldap/tests/test_password.py index aa01016794..18fadaceb9 100644 --- a/authentik/sources/ldap/tests/test_password.py +++ b/authentik/sources/ldap/tests/test_password.py @@ -1,4 +1,5 @@ """LDAP Source tests""" + from unittest.mock import MagicMock, patch from django.test import TestCase diff --git a/authentik/sources/ldap/tests/test_sync.py b/authentik/sources/ldap/tests/test_sync.py index 5012007bd0..8ccca9f906 100644 --- a/authentik/sources/ldap/tests/test_sync.py +++ b/authentik/sources/ldap/tests/test_sync.py @@ -1,4 +1,5 @@ """LDAP Source tests""" + from unittest.mock import MagicMock, patch from django.db.models import Q diff --git a/authentik/sources/ldap/urls.py b/authentik/sources/ldap/urls.py index 30390f3326..361e9dccde 100644 --- a/authentik/sources/ldap/urls.py +++ b/authentik/sources/ldap/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.sources.ldap.api import LDAPPropertyMappingViewSet, LDAPSourceViewSet api_urlpatterns = [ diff --git a/authentik/sources/oauth/api/source.py b/authentik/sources/oauth/api/source.py index 398ce96719..16a862d1be 100644 --- a/authentik/sources/oauth/api/source.py +++ b/authentik/sources/oauth/api/source.py @@ -1,4 +1,5 @@ """OAuth Source Serializer""" + from django.urls.base import reverse_lazy from django_filters.filters import BooleanFilter from django_filters.filterset import FilterSet diff --git a/authentik/sources/oauth/api/source_connection.py b/authentik/sources/oauth/api/source_connection.py index 311ce5bad9..2ae1dc421a 100644 --- a/authentik/sources/oauth/api/source_connection.py +++ b/authentik/sources/oauth/api/source_connection.py @@ -1,4 +1,5 @@ """OAuth Source Serializer""" + from django_filters.rest_framework import DjangoFilterBackend from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.viewsets import ModelViewSet diff --git a/authentik/sources/oauth/apps.py b/authentik/sources/oauth/apps.py index e497c56476..5a50989f46 100644 --- a/authentik/sources/oauth/apps.py +++ b/authentik/sources/oauth/apps.py @@ -1,4 +1,5 @@ """authentik oauth_client config""" + from structlog.stdlib import get_logger from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/sources/oauth/clients/base.py b/authentik/sources/oauth/clients/base.py index 2c3f972485..f86011b17f 100644 --- a/authentik/sources/oauth/clients/base.py +++ b/authentik/sources/oauth/clients/base.py @@ -1,4 +1,5 @@ """OAuth Clients""" + from typing import Any, Optional from urllib.parse import parse_qs, quote, urlencode, urlparse, urlunparse diff --git a/authentik/sources/oauth/clients/oauth1.py b/authentik/sources/oauth/clients/oauth1.py index 1299a585c0..739ebfb6aa 100644 --- a/authentik/sources/oauth/clients/oauth1.py +++ b/authentik/sources/oauth/clients/oauth1.py @@ -1,4 +1,5 @@ """OAuth 1 Clients""" + from typing import Any, Optional from urllib.parse import parse_qsl diff --git a/authentik/sources/oauth/clients/oauth2.py b/authentik/sources/oauth/clients/oauth2.py index b29f366636..ec2fa2f5a5 100644 --- a/authentik/sources/oauth/clients/oauth2.py +++ b/authentik/sources/oauth/clients/oauth2.py @@ -1,4 +1,5 @@ """OAuth 2 Clients""" + from json import loads from typing import Any, Optional from urllib.parse import parse_qsl diff --git a/authentik/sources/oauth/exceptions.py b/authentik/sources/oauth/exceptions.py index 0929e74c45..0798638dfa 100644 --- a/authentik/sources/oauth/exceptions.py +++ b/authentik/sources/oauth/exceptions.py @@ -1,4 +1,5 @@ """OAuth Source Exception""" + from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/sources/oauth/models.py b/authentik/sources/oauth/models.py index 7acbb92230..aaaf1f2ddf 100644 --- a/authentik/sources/oauth/models.py +++ b/authentik/sources/oauth/models.py @@ -1,4 +1,5 @@ """OAuth Client models""" + from typing import TYPE_CHECKING, Optional from django.db import models diff --git a/authentik/sources/oauth/settings.py b/authentik/sources/oauth/settings.py index c839c338db..6580a906f5 100644 --- a/authentik/sources/oauth/settings.py +++ b/authentik/sources/oauth/settings.py @@ -1,4 +1,5 @@ """OAuth source settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/sources/oauth/tasks.py b/authentik/sources/oauth/tasks.py index cfac09f093..871bc2f2b1 100644 --- a/authentik/sources/oauth/tasks.py +++ b/authentik/sources/oauth/tasks.py @@ -1,4 +1,5 @@ """OAuth Source tasks""" + from json import dumps from requests import RequestException diff --git a/authentik/sources/oauth/tests/test_tasks.py b/authentik/sources/oauth/tests/test_tasks.py index 54f1290b6f..3671fbc4ba 100644 --- a/authentik/sources/oauth/tests/test_tasks.py +++ b/authentik/sources/oauth/tests/test_tasks.py @@ -1,4 +1,5 @@ """Test OAuth Source tasks""" + from django.test import TestCase from requests_mock import Mocker diff --git a/authentik/sources/oauth/tests/test_type_azure_ad.py b/authentik/sources/oauth/tests/test_type_azure_ad.py index 2f1e1731e0..e34892fad3 100644 --- a/authentik/sources/oauth/tests/test_type_azure_ad.py +++ b/authentik/sources/oauth/tests/test_type_azure_ad.py @@ -1,4 +1,5 @@ """azure ad Type tests""" + from django.test import TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_type_discord.py b/authentik/sources/oauth/tests/test_type_discord.py index c3aa56efc1..e1c996a2d1 100644 --- a/authentik/sources/oauth/tests/test_type_discord.py +++ b/authentik/sources/oauth/tests/test_type_discord.py @@ -1,4 +1,5 @@ """Discord Type tests""" + from django.test import TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_type_github.py b/authentik/sources/oauth/tests/test_type_github.py index ad62a6f50e..a24cdaaa75 100644 --- a/authentik/sources/oauth/tests/test_type_github.py +++ b/authentik/sources/oauth/tests/test_type_github.py @@ -1,4 +1,5 @@ """GitHub Type tests""" + from copy import copy from django.test import RequestFactory, TestCase diff --git a/authentik/sources/oauth/tests/test_type_google.py b/authentik/sources/oauth/tests/test_type_google.py index 5b1780e9bd..0b6d3888e2 100644 --- a/authentik/sources/oauth/tests/test_type_google.py +++ b/authentik/sources/oauth/tests/test_type_google.py @@ -1,4 +1,5 @@ """google Type tests""" + from django.contrib.sessions.middleware import SessionMiddleware from django.test import TestCase from django.test.client import RequestFactory diff --git a/authentik/sources/oauth/tests/test_type_mailcow.py b/authentik/sources/oauth/tests/test_type_mailcow.py index 2687bf3cfe..8a7a4b30db 100644 --- a/authentik/sources/oauth/tests/test_type_mailcow.py +++ b/authentik/sources/oauth/tests/test_type_mailcow.py @@ -1,4 +1,5 @@ """Mailcow Type tests""" + from django.test import TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_type_openid.py b/authentik/sources/oauth/tests/test_type_openid.py index e04bea4b0c..f8c7805489 100644 --- a/authentik/sources/oauth/tests/test_type_openid.py +++ b/authentik/sources/oauth/tests/test_type_openid.py @@ -1,4 +1,5 @@ """OpenID Type tests""" + from django.test import RequestFactory, TestCase from requests_mock import Mocker diff --git a/authentik/sources/oauth/tests/test_type_patreon.py b/authentik/sources/oauth/tests/test_type_patreon.py index 670b7d6657..680df0724c 100644 --- a/authentik/sources/oauth/tests/test_type_patreon.py +++ b/authentik/sources/oauth/tests/test_type_patreon.py @@ -1,4 +1,5 @@ """Patreon Type tests""" + from django.test import RequestFactory, TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_type_twitch.py b/authentik/sources/oauth/tests/test_type_twitch.py index f18e4eaf22..e9fbe4acd7 100644 --- a/authentik/sources/oauth/tests/test_type_twitch.py +++ b/authentik/sources/oauth/tests/test_type_twitch.py @@ -1,4 +1,5 @@ """Twitch Type tests""" + from django.test import TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_type_twitter.py b/authentik/sources/oauth/tests/test_type_twitter.py index 80abefd6dc..8ff9f2ffd5 100644 --- a/authentik/sources/oauth/tests/test_type_twitter.py +++ b/authentik/sources/oauth/tests/test_type_twitter.py @@ -1,4 +1,5 @@ """Twitter Type tests""" + from django.test import TestCase from authentik.sources.oauth.models import OAuthSource diff --git a/authentik/sources/oauth/tests/test_views.py b/authentik/sources/oauth/tests/test_views.py index 2a849d0a9c..3a3152f5e0 100644 --- a/authentik/sources/oauth/tests/test_views.py +++ b/authentik/sources/oauth/tests/test_views.py @@ -1,4 +1,5 @@ """OAuth Source tests""" + from django.urls import reverse from requests_mock import Mocker from rest_framework.test import APITestCase diff --git a/authentik/sources/oauth/types/apple.py b/authentik/sources/oauth/types/apple.py index 5ead5bdbda..a92ce95147 100644 --- a/authentik/sources/oauth/types/apple.py +++ b/authentik/sources/oauth/types/apple.py @@ -1,4 +1,5 @@ """Apple OAuth Views""" + from time import time from typing import Any, Optional diff --git a/authentik/sources/oauth/types/azure_ad.py b/authentik/sources/oauth/types/azure_ad.py index 80c92141b0..341831138f 100644 --- a/authentik/sources/oauth/types/azure_ad.py +++ b/authentik/sources/oauth/types/azure_ad.py @@ -1,4 +1,5 @@ """AzureAD OAuth2 Views""" + from typing import Any from structlog.stdlib import get_logger diff --git a/authentik/sources/oauth/types/discord.py b/authentik/sources/oauth/types/discord.py index 4fb34c6726..a67c07bf13 100644 --- a/authentik/sources/oauth/types/discord.py +++ b/authentik/sources/oauth/types/discord.py @@ -1,4 +1,5 @@ """Discord OAuth Views""" + from typing import Any from authentik.sources.oauth.types.registry import SourceType, registry diff --git a/authentik/sources/oauth/types/facebook.py b/authentik/sources/oauth/types/facebook.py index 69893298b7..7225109dcb 100644 --- a/authentik/sources/oauth/types/facebook.py +++ b/authentik/sources/oauth/types/facebook.py @@ -1,4 +1,5 @@ """Facebook OAuth Views""" + from typing import Any, Optional from facebook import GraphAPI diff --git a/authentik/sources/oauth/types/github.py b/authentik/sources/oauth/types/github.py index b9e5ed17cb..ce88ae78d0 100644 --- a/authentik/sources/oauth/types/github.py +++ b/authentik/sources/oauth/types/github.py @@ -1,4 +1,5 @@ """GitHub OAuth Views""" + from typing import Any from requests.exceptions import RequestException diff --git a/authentik/sources/oauth/types/google.py b/authentik/sources/oauth/types/google.py index 94b6f78428..add0eab845 100644 --- a/authentik/sources/oauth/types/google.py +++ b/authentik/sources/oauth/types/google.py @@ -1,4 +1,5 @@ """Google OAuth Views""" + from typing import Any from authentik.sources.oauth.types.registry import SourceType, registry diff --git a/authentik/sources/oauth/types/mailcow.py b/authentik/sources/oauth/types/mailcow.py index 8bff86af55..0f64994fe4 100644 --- a/authentik/sources/oauth/types/mailcow.py +++ b/authentik/sources/oauth/types/mailcow.py @@ -1,4 +1,5 @@ """Mailcow OAuth Views""" + from typing import Any, Optional from requests.exceptions import RequestException diff --git a/authentik/sources/oauth/types/oidc.py b/authentik/sources/oauth/types/oidc.py index 4e32f3fee5..017e04b5e2 100644 --- a/authentik/sources/oauth/types/oidc.py +++ b/authentik/sources/oauth/types/oidc.py @@ -1,4 +1,5 @@ """OpenID Connect OAuth Views""" + from typing import Any from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient diff --git a/authentik/sources/oauth/types/okta.py b/authentik/sources/oauth/types/okta.py index 1f1f07dc7e..1698cf2d1f 100644 --- a/authentik/sources/oauth/types/okta.py +++ b/authentik/sources/oauth/types/okta.py @@ -1,4 +1,5 @@ """Okta OAuth Views""" + from typing import Any from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient diff --git a/authentik/sources/oauth/types/patreon.py b/authentik/sources/oauth/types/patreon.py index 8d11bf27ad..07bf307f09 100644 --- a/authentik/sources/oauth/types/patreon.py +++ b/authentik/sources/oauth/types/patreon.py @@ -1,4 +1,5 @@ """Patreon OAuth Views""" + from typing import Any from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient diff --git a/authentik/sources/oauth/types/reddit.py b/authentik/sources/oauth/types/reddit.py index 7d558cbb3c..1b901bb37a 100644 --- a/authentik/sources/oauth/types/reddit.py +++ b/authentik/sources/oauth/types/reddit.py @@ -1,4 +1,5 @@ """Reddit OAuth Views""" + from typing import Any from requests.auth import HTTPBasicAuth diff --git a/authentik/sources/oauth/types/registry.py b/authentik/sources/oauth/types/registry.py index 99cb87dd5d..c86badb200 100644 --- a/authentik/sources/oauth/types/registry.py +++ b/authentik/sources/oauth/types/registry.py @@ -1,4 +1,5 @@ """Source type manager""" + from enum import Enum from typing import Callable, Optional, Type diff --git a/authentik/sources/oauth/types/twitch.py b/authentik/sources/oauth/types/twitch.py index 52b8bae0bc..ada73ce499 100644 --- a/authentik/sources/oauth/types/twitch.py +++ b/authentik/sources/oauth/types/twitch.py @@ -1,4 +1,5 @@ """Twitch OAuth Views""" + from json import dumps from typing import Any, Optional diff --git a/authentik/sources/oauth/types/twitter.py b/authentik/sources/oauth/types/twitter.py index 7b75f04ea8..5753b4694c 100644 --- a/authentik/sources/oauth/types/twitter.py +++ b/authentik/sources/oauth/types/twitter.py @@ -1,4 +1,5 @@ """Twitter OAuth Views""" + from typing import Any, Optional from authentik.lib.generators import generate_id diff --git a/authentik/sources/oauth/views/base.py b/authentik/sources/oauth/views/base.py index 399f3f4931..2948cdac6e 100644 --- a/authentik/sources/oauth/views/base.py +++ b/authentik/sources/oauth/views/base.py @@ -1,4 +1,5 @@ """OAuth Base views""" + from typing import Optional from django.http.request import HttpRequest diff --git a/authentik/sources/oauth/views/callback.py b/authentik/sources/oauth/views/callback.py index 893a5003c5..37bb51aaaf 100644 --- a/authentik/sources/oauth/views/callback.py +++ b/authentik/sources/oauth/views/callback.py @@ -1,4 +1,5 @@ """OAuth Callback Views""" + from json import JSONDecodeError from typing import Any, Optional diff --git a/authentik/sources/oauth/views/dispatcher.py b/authentik/sources/oauth/views/dispatcher.py index 234b936b3e..9fe4339fd6 100644 --- a/authentik/sources/oauth/views/dispatcher.py +++ b/authentik/sources/oauth/views/dispatcher.py @@ -1,4 +1,5 @@ """Dispatch OAuth views to respective views""" + from django.shortcuts import get_object_or_404 from django.utils.decorators import method_decorator from django.views import View diff --git a/authentik/sources/oauth/views/redirect.py b/authentik/sources/oauth/views/redirect.py index d5d38050d3..97d5356eb3 100644 --- a/authentik/sources/oauth/views/redirect.py +++ b/authentik/sources/oauth/views/redirect.py @@ -1,4 +1,5 @@ """OAuth Redirect Views""" + from typing import Any from django.http import Http404 diff --git a/authentik/sources/plex/api/source.py b/authentik/sources/plex/api/source.py index dd15b9a2b3..9e39494061 100644 --- a/authentik/sources/plex/api/source.py +++ b/authentik/sources/plex/api/source.py @@ -1,4 +1,5 @@ """Plex Source Serializer""" + from django.shortcuts import get_object_or_404 from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema diff --git a/authentik/sources/plex/api/source_connection.py b/authentik/sources/plex/api/source_connection.py index f046a300f3..dcda9279a6 100644 --- a/authentik/sources/plex/api/source_connection.py +++ b/authentik/sources/plex/api/source_connection.py @@ -1,4 +1,5 @@ """Plex Source connection Serializer""" + from django_filters.rest_framework import DjangoFilterBackend from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.viewsets import ModelViewSet diff --git a/authentik/sources/plex/apps.py b/authentik/sources/plex/apps.py index a8c89447b7..2170a61dc8 100644 --- a/authentik/sources/plex/apps.py +++ b/authentik/sources/plex/apps.py @@ -1,4 +1,5 @@ """authentik plex config""" + from django.apps import AppConfig diff --git a/authentik/sources/plex/models.py b/authentik/sources/plex/models.py index e20c809a33..6621d4d269 100644 --- a/authentik/sources/plex/models.py +++ b/authentik/sources/plex/models.py @@ -1,4 +1,5 @@ """Plex source""" + from typing import Optional from django.contrib.postgres.fields import ArrayField diff --git a/authentik/sources/plex/plex.py b/authentik/sources/plex/plex.py index 1c30db551d..9e324f0ae8 100644 --- a/authentik/sources/plex/plex.py +++ b/authentik/sources/plex/plex.py @@ -1,4 +1,5 @@ """Plex Views""" + from urllib.parse import urlencode from django.http.response import Http404 diff --git a/authentik/sources/plex/settings.py b/authentik/sources/plex/settings.py index c231434843..5884bbe220 100644 --- a/authentik/sources/plex/settings.py +++ b/authentik/sources/plex/settings.py @@ -1,4 +1,5 @@ """Plex source settings""" + from celery.schedules import crontab from authentik.lib.utils.time import fqdn_rand diff --git a/authentik/sources/plex/tasks.py b/authentik/sources/plex/tasks.py index 63c8b83b0d..06b108edb6 100644 --- a/authentik/sources/plex/tasks.py +++ b/authentik/sources/plex/tasks.py @@ -1,4 +1,5 @@ """Plex tasks""" + from requests import RequestException from authentik.events.models import Event, EventAction, TaskStatus diff --git a/authentik/sources/plex/tests.py b/authentik/sources/plex/tests.py index 6a60433f7a..9e5eedefac 100644 --- a/authentik/sources/plex/tests.py +++ b/authentik/sources/plex/tests.py @@ -1,4 +1,5 @@ """plex Source tests""" + from django.test import TestCase from requests.exceptions import RequestException from requests_mock import Mocker diff --git a/authentik/sources/plex/urls.py b/authentik/sources/plex/urls.py index d47b269309..d1fa679dad 100644 --- a/authentik/sources/plex/urls.py +++ b/authentik/sources/plex/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.sources.plex.api.source import PlexSourceViewSet from authentik.sources.plex.api.source_connection import PlexSourceConnectionViewSet diff --git a/authentik/sources/saml/api/source.py b/authentik/sources/saml/api/source.py index e0dacad046..a3f0e9bd41 100644 --- a/authentik/sources/saml/api/source.py +++ b/authentik/sources/saml/api/source.py @@ -1,4 +1,5 @@ """SAMLSource API Views""" + from django.urls import reverse from drf_spectacular.utils import extend_schema from rest_framework.decorators import action diff --git a/authentik/sources/saml/api/source_connection.py b/authentik/sources/saml/api/source_connection.py index 25351569d8..8e81b78cf9 100644 --- a/authentik/sources/saml/api/source_connection.py +++ b/authentik/sources/saml/api/source_connection.py @@ -1,4 +1,5 @@ """SAML Source Serializer""" + from django_filters.rest_framework import DjangoFilterBackend from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.viewsets import ModelViewSet diff --git a/authentik/sources/saml/apps.py b/authentik/sources/saml/apps.py index f7c2847e77..53d35f8eae 100644 --- a/authentik/sources/saml/apps.py +++ b/authentik/sources/saml/apps.py @@ -1,4 +1,5 @@ """Authentik SAML app config""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/sources/saml/exceptions.py b/authentik/sources/saml/exceptions.py index 344ee005bf..057a040aa2 100644 --- a/authentik/sources/saml/exceptions.py +++ b/authentik/sources/saml/exceptions.py @@ -1,4 +1,5 @@ """authentik saml source exceptions""" + from authentik.lib.sentry import SentryIgnoredException diff --git a/authentik/sources/saml/models.py b/authentik/sources/saml/models.py index 6c24abf8d4..b05fd61007 100644 --- a/authentik/sources/saml/models.py +++ b/authentik/sources/saml/models.py @@ -1,4 +1,5 @@ """saml sp models""" + from typing import Optional from django.db import models diff --git a/authentik/sources/saml/processors/constants.py b/authentik/sources/saml/processors/constants.py index d7e4bcd07e..ef8ab7c122 100644 --- a/authentik/sources/saml/processors/constants.py +++ b/authentik/sources/saml/processors/constants.py @@ -1,4 +1,5 @@ """SAML Source processor constants""" + import xmlsec NS_SAML_PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol" diff --git a/authentik/sources/saml/processors/metadata.py b/authentik/sources/saml/processors/metadata.py index 4ea8257106..2aea4ba871 100644 --- a/authentik/sources/saml/processors/metadata.py +++ b/authentik/sources/saml/processors/metadata.py @@ -1,4 +1,5 @@ """SAML Service Provider Metadata Processor""" + from typing import Iterator, Optional from django.http import HttpRequest @@ -63,9 +64,9 @@ class MetadataProcessor: entity_descriptor.attrib["entityID"] = self.source.get_issuer(self.http_request) sp_sso_descriptor = SubElement(entity_descriptor, f"{{{NS_SAML_METADATA}}}SPSSODescriptor") - sp_sso_descriptor.attrib[ - "protocolSupportEnumeration" - ] = "urn:oasis:names:tc:SAML:2.0:protocol" + sp_sso_descriptor.attrib["protocolSupportEnumeration"] = ( + "urn:oasis:names:tc:SAML:2.0:protocol" + ) signing_descriptor = self.get_signing_key_descriptor() if signing_descriptor is not None: diff --git a/authentik/sources/saml/processors/request.py b/authentik/sources/saml/processors/request.py index c7a81029c8..ff36812a1f 100644 --- a/authentik/sources/saml/processors/request.py +++ b/authentik/sources/saml/processors/request.py @@ -1,4 +1,5 @@ """SAML AuthnRequest Processor""" + from base64 import b64encode from urllib.parse import quote_plus diff --git a/authentik/sources/saml/processors/response.py b/authentik/sources/saml/processors/response.py index 78a8d19930..d10879fafe 100644 --- a/authentik/sources/saml/processors/response.py +++ b/authentik/sources/saml/processors/response.py @@ -1,4 +1,5 @@ """authentik saml source processor""" + from base64 import b64decode from time import mktime from typing import TYPE_CHECKING, Any diff --git a/authentik/sources/saml/signals.py b/authentik/sources/saml/signals.py index 6c37b1aaf1..ebcb8bae99 100644 --- a/authentik/sources/saml/signals.py +++ b/authentik/sources/saml/signals.py @@ -1,4 +1,5 @@ """authentik saml source signal listener""" + from django.contrib.auth.signals import user_logged_out from django.dispatch import receiver from django.http import HttpRequest diff --git a/authentik/sources/saml/tests/test_metadata.py b/authentik/sources/saml/tests/test_metadata.py index d81033e120..953745c2dc 100644 --- a/authentik/sources/saml/tests/test_metadata.py +++ b/authentik/sources/saml/tests/test_metadata.py @@ -1,4 +1,5 @@ """SAML Source tests""" + from defusedxml import ElementTree from django.test import RequestFactory, TestCase from lxml import etree # nosec diff --git a/authentik/sources/saml/tests/test_response.py b/authentik/sources/saml/tests/test_response.py index f66a28b231..b22957c8d3 100644 --- a/authentik/sources/saml/tests/test_response.py +++ b/authentik/sources/saml/tests/test_response.py @@ -1,4 +1,5 @@ """SAML Source tests""" + from base64 import b64encode from django.contrib.sessions.middleware import SessionMiddleware diff --git a/authentik/sources/saml/urls.py b/authentik/sources/saml/urls.py index ee95631db6..6abeb3f4db 100644 --- a/authentik/sources/saml/urls.py +++ b/authentik/sources/saml/urls.py @@ -1,4 +1,5 @@ """saml sp urls""" + from django.urls import path from authentik.sources.saml.api.source import SAMLSourceViewSet diff --git a/authentik/sources/saml/views.py b/authentik/sources/saml/views.py index 1ab6c860ab..502a96603b 100644 --- a/authentik/sources/saml/views.py +++ b/authentik/sources/saml/views.py @@ -1,4 +1,5 @@ """saml sp views""" + from urllib.parse import parse_qsl, urlparse, urlunparse from django.contrib.auth import logout diff --git a/authentik/stages/authenticator/__init__.py b/authentik/stages/authenticator/__init__.py index a6d3087e8a..bf675f04e9 100644 --- a/authentik/stages/authenticator/__init__.py +++ b/authentik/stages/authenticator/__init__.py @@ -1,4 +1,5 @@ """Authenticator devices helpers""" + from django.db import transaction diff --git a/authentik/stages/authenticator/apps.py b/authentik/stages/authenticator/apps.py index 5fb866e2db..dd33812bbf 100644 --- a/authentik/stages/authenticator/apps.py +++ b/authentik/stages/authenticator/apps.py @@ -1,4 +1,5 @@ """Authenticator""" + from django.apps import AppConfig diff --git a/authentik/stages/authenticator/models.py b/authentik/stages/authenticator/models.py index 0404a0668c..3843d0fbf2 100644 --- a/authentik/stages/authenticator/models.py +++ b/authentik/stages/authenticator/models.py @@ -1,4 +1,5 @@ """Base authenticator models""" + from datetime import timedelta from django.apps import apps diff --git a/authentik/stages/authenticator/oath.py b/authentik/stages/authenticator/oath.py index 443079067f..0a1a99b8e6 100644 --- a/authentik/stages/authenticator/oath.py +++ b/authentik/stages/authenticator/oath.py @@ -1,4 +1,5 @@ """OATH helpers""" + import hmac from hashlib import sha1 from struct import pack diff --git a/authentik/stages/authenticator/tests.py b/authentik/stages/authenticator/tests.py index 9a619828a9..5e17eb0360 100644 --- a/authentik/stages/authenticator/tests.py +++ b/authentik/stages/authenticator/tests.py @@ -1,4 +1,5 @@ """Base authenticator tests""" + from datetime import timedelta from threading import Thread diff --git a/authentik/stages/authenticator/util.py b/authentik/stages/authenticator/util.py index 26b9dc64df..afef00cb52 100644 --- a/authentik/stages/authenticator/util.py +++ b/authentik/stages/authenticator/util.py @@ -1,4 +1,5 @@ """Authenticator utils""" + import random import string from binascii import unhexlify diff --git a/authentik/stages/authenticator_duo/api.py b/authentik/stages/authenticator_duo/api.py index 3d038de31a..c5093a8ff2 100644 --- a/authentik/stages/authenticator_duo/api.py +++ b/authentik/stages/authenticator_duo/api.py @@ -1,4 +1,5 @@ """AuthenticatorDuoStage API Views""" + from django.http import Http404 from django_filters.rest_framework.backends import DjangoFilterBackend from drf_spectacular.types import OpenApiTypes diff --git a/authentik/stages/authenticator_duo/models.py b/authentik/stages/authenticator_duo/models.py index d1dce81f09..f8b0f7ff48 100644 --- a/authentik/stages/authenticator_duo/models.py +++ b/authentik/stages/authenticator_duo/models.py @@ -1,4 +1,5 @@ """Duo stage""" + from typing import Optional from django.contrib.auth import get_user_model diff --git a/authentik/stages/authenticator_duo/stage.py b/authentik/stages/authenticator_duo/stage.py index df44a7259b..a19880fe38 100644 --- a/authentik/stages/authenticator_duo/stage.py +++ b/authentik/stages/authenticator_duo/stage.py @@ -1,4 +1,5 @@ """Duo stage""" + from django.http import HttpResponse from django.utils.timezone import now from rest_framework.fields import CharField diff --git a/authentik/stages/authenticator_duo/tasks.py b/authentik/stages/authenticator_duo/tasks.py index 338f6d8f0a..b97c1e39ee 100644 --- a/authentik/stages/authenticator_duo/tasks.py +++ b/authentik/stages/authenticator_duo/tasks.py @@ -1,4 +1,5 @@ """duo tasks""" + from structlog.stdlib import get_logger from authentik.core.models import User diff --git a/authentik/stages/authenticator_duo/tests.py b/authentik/stages/authenticator_duo/tests.py index a11bbd5847..3262589f69 100644 --- a/authentik/stages/authenticator_duo/tests.py +++ b/authentik/stages/authenticator_duo/tests.py @@ -1,4 +1,5 @@ """Test duo stage""" + from unittest.mock import MagicMock, patch from uuid import uuid4 diff --git a/authentik/stages/authenticator_duo/urls.py b/authentik/stages/authenticator_duo/urls.py index 8a41247415..dd7e083c7f 100644 --- a/authentik/stages/authenticator_duo/urls.py +++ b/authentik/stages/authenticator_duo/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_duo.api import ( AuthenticatorDuoStageViewSet, DuoAdminDeviceViewSet, diff --git a/authentik/stages/authenticator_sms/api.py b/authentik/stages/authenticator_sms/api.py index bfa0b323e9..b8784ce210 100644 --- a/authentik/stages/authenticator_sms/api.py +++ b/authentik/stages/authenticator_sms/api.py @@ -1,4 +1,5 @@ """AuthenticatorSMSStage API Views""" + from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework import mixins from rest_framework.filters import OrderingFilter, SearchFilter diff --git a/authentik/stages/authenticator_sms/apps.py b/authentik/stages/authenticator_sms/apps.py index 97d9d6ae0b..d5d6f749ee 100644 --- a/authentik/stages/authenticator_sms/apps.py +++ b/authentik/stages/authenticator_sms/apps.py @@ -1,4 +1,5 @@ """SMS""" + from django.apps import AppConfig diff --git a/authentik/stages/authenticator_sms/models.py b/authentik/stages/authenticator_sms/models.py index 042cbd6984..27bd07faf9 100644 --- a/authentik/stages/authenticator_sms/models.py +++ b/authentik/stages/authenticator_sms/models.py @@ -1,4 +1,5 @@ """SMS Authenticator models""" + from hashlib import sha256 from typing import Optional diff --git a/authentik/stages/authenticator_sms/stage.py b/authentik/stages/authenticator_sms/stage.py index e2c6610896..3802adb709 100644 --- a/authentik/stages/authenticator_sms/stage.py +++ b/authentik/stages/authenticator_sms/stage.py @@ -1,4 +1,5 @@ """SMS Setup stage""" + from typing import Optional from django.db.models import Q diff --git a/authentik/stages/authenticator_sms/tests.py b/authentik/stages/authenticator_sms/tests.py index 1ab16aa561..b3d5ec29c2 100644 --- a/authentik/stages/authenticator_sms/tests.py +++ b/authentik/stages/authenticator_sms/tests.py @@ -1,4 +1,5 @@ """Test SMS API""" + from unittest.mock import MagicMock, patch from urllib.parse import parse_qsl diff --git a/authentik/stages/authenticator_sms/urls.py b/authentik/stages/authenticator_sms/urls.py index 56b315f619..dd4274b787 100644 --- a/authentik/stages/authenticator_sms/urls.py +++ b/authentik/stages/authenticator_sms/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_sms.api import ( AuthenticatorSMSStageViewSet, SMSAdminDeviceViewSet, diff --git a/authentik/stages/authenticator_static/api.py b/authentik/stages/authenticator_static/api.py index d9f474eb16..2bc0eb6e97 100644 --- a/authentik/stages/authenticator_static/api.py +++ b/authentik/stages/authenticator_static/api.py @@ -1,4 +1,5 @@ """AuthenticatorStaticStage API Views""" + from django_filters.rest_framework import DjangoFilterBackend from rest_framework import mixins from rest_framework.filters import OrderingFilter, SearchFilter diff --git a/authentik/stages/authenticator_static/apps.py b/authentik/stages/authenticator_static/apps.py index 09c6202d6c..9cbcd5b372 100644 --- a/authentik/stages/authenticator_static/apps.py +++ b/authentik/stages/authenticator_static/apps.py @@ -1,4 +1,5 @@ """Authenticator Static stage""" + from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/stages/authenticator_static/models.py b/authentik/stages/authenticator_static/models.py index 3b1ade6297..eb11c6ab9f 100644 --- a/authentik/stages/authenticator_static/models.py +++ b/authentik/stages/authenticator_static/models.py @@ -1,4 +1,5 @@ """Static Authenticator models""" + from base64 import b32encode from os import urandom from typing import Optional diff --git a/authentik/stages/authenticator_static/signals.py b/authentik/stages/authenticator_static/signals.py index 5b0428eef8..a654b95160 100644 --- a/authentik/stages/authenticator_static/signals.py +++ b/authentik/stages/authenticator_static/signals.py @@ -1,4 +1,5 @@ """totp authenticator signals""" + from django.db.models.signals import pre_delete from django.dispatch import receiver diff --git a/authentik/stages/authenticator_static/stage.py b/authentik/stages/authenticator_static/stage.py index 47efbfad71..ef4a808b12 100644 --- a/authentik/stages/authenticator_static/stage.py +++ b/authentik/stages/authenticator_static/stage.py @@ -1,4 +1,5 @@ """Static OTP Setup stage""" + from django.http import HttpRequest, HttpResponse from rest_framework.fields import CharField, ListField diff --git a/authentik/stages/authenticator_static/tests.py b/authentik/stages/authenticator_static/tests.py index 92e40f752e..d002e5c040 100644 --- a/authentik/stages/authenticator_static/tests.py +++ b/authentik/stages/authenticator_static/tests.py @@ -1,4 +1,5 @@ """Test Static API""" + from django.test.utils import override_settings from django.urls import reverse from rest_framework.test import APITestCase diff --git a/authentik/stages/authenticator_static/urls.py b/authentik/stages/authenticator_static/urls.py index 57a79cae73..3bccfc3d4b 100644 --- a/authentik/stages/authenticator_static/urls.py +++ b/authentik/stages/authenticator_static/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_static.api import ( AuthenticatorStaticStageViewSet, StaticAdminDeviceViewSet, diff --git a/authentik/stages/authenticator_totp/api.py b/authentik/stages/authenticator_totp/api.py index 3baffb3ff4..b0ca4d480e 100644 --- a/authentik/stages/authenticator_totp/api.py +++ b/authentik/stages/authenticator_totp/api.py @@ -1,4 +1,5 @@ """AuthenticatorTOTPStage API Views""" + from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework import mixins from rest_framework.fields import ChoiceField diff --git a/authentik/stages/authenticator_totp/apps.py b/authentik/stages/authenticator_totp/apps.py index 9ca682cda2..7e624a95dd 100644 --- a/authentik/stages/authenticator_totp/apps.py +++ b/authentik/stages/authenticator_totp/apps.py @@ -1,4 +1,5 @@ """TOTP""" + from django.apps import AppConfig diff --git a/authentik/stages/authenticator_totp/models.py b/authentik/stages/authenticator_totp/models.py index 9f4ccacdcc..77a76d3fd3 100644 --- a/authentik/stages/authenticator_totp/models.py +++ b/authentik/stages/authenticator_totp/models.py @@ -1,4 +1,5 @@ """OTP Time-based models""" + import time from base64 import b32encode from binascii import unhexlify diff --git a/authentik/stages/authenticator_totp/stage.py b/authentik/stages/authenticator_totp/stage.py index d87cc6e3cc..1a0791f785 100644 --- a/authentik/stages/authenticator_totp/stage.py +++ b/authentik/stages/authenticator_totp/stage.py @@ -1,4 +1,5 @@ """TOTP Setup stage""" + from urllib.parse import quote from django.http import HttpRequest, HttpResponse diff --git a/authentik/stages/authenticator_totp/tests.py b/authentik/stages/authenticator_totp/tests.py index 8ee7577ad1..44c6dc9b6e 100644 --- a/authentik/stages/authenticator_totp/tests.py +++ b/authentik/stages/authenticator_totp/tests.py @@ -1,4 +1,5 @@ """Test TOTP API""" + from time import time from urllib.parse import parse_qs, urlsplit diff --git a/authentik/stages/authenticator_totp/urls.py b/authentik/stages/authenticator_totp/urls.py index 7be8d5f795..3c20499df0 100644 --- a/authentik/stages/authenticator_totp/urls.py +++ b/authentik/stages/authenticator_totp/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_totp.api import ( AuthenticatorTOTPStageViewSet, TOTPAdminDeviceViewSet, diff --git a/authentik/stages/authenticator_validate/api.py b/authentik/stages/authenticator_validate/api.py index f4ea36fc18..7808c9c481 100644 --- a/authentik/stages/authenticator_validate/api.py +++ b/authentik/stages/authenticator_validate/api.py @@ -1,4 +1,5 @@ """AuthenticatorValidateStage API Views""" + from rest_framework.serializers import ValidationError from rest_framework.viewsets import ModelViewSet diff --git a/authentik/stages/authenticator_validate/apps.py b/authentik/stages/authenticator_validate/apps.py index e50715bf8d..922440f955 100644 --- a/authentik/stages/authenticator_validate/apps.py +++ b/authentik/stages/authenticator_validate/apps.py @@ -1,4 +1,5 @@ """Authenticator Validation Stage""" + from django.apps import AppConfig diff --git a/authentik/stages/authenticator_validate/challenge.py b/authentik/stages/authenticator_validate/challenge.py index eeed5adcb3..1a78292495 100644 --- a/authentik/stages/authenticator_validate/challenge.py +++ b/authentik/stages/authenticator_validate/challenge.py @@ -1,4 +1,5 @@ """Validation stage challenge checking""" + from json import loads from typing import Optional from urllib.parse import urlencode diff --git a/authentik/stages/authenticator_validate/stage.py b/authentik/stages/authenticator_validate/stage.py index 8a730414ab..10c3466c2d 100644 --- a/authentik/stages/authenticator_validate/stage.py +++ b/authentik/stages/authenticator_validate/stage.py @@ -1,4 +1,5 @@ """Authenticator Validation""" + from datetime import datetime from hashlib import sha256 from typing import Optional diff --git a/authentik/stages/authenticator_validate/tests/test_duo.py b/authentik/stages/authenticator_validate/tests/test_duo.py index bdd1c59842..38cca7811a 100644 --- a/authentik/stages/authenticator_validate/tests/test_duo.py +++ b/authentik/stages/authenticator_validate/tests/test_duo.py @@ -1,4 +1,5 @@ """Test validator stage""" + from unittest.mock import MagicMock, patch from django.contrib.sessions.middleware import SessionMiddleware diff --git a/authentik/stages/authenticator_validate/tests/test_sms.py b/authentik/stages/authenticator_validate/tests/test_sms.py index e171b1ef87..5cce796207 100644 --- a/authentik/stages/authenticator_validate/tests/test_sms.py +++ b/authentik/stages/authenticator_validate/tests/test_sms.py @@ -1,4 +1,5 @@ """Test validator stage""" + from unittest.mock import MagicMock, patch from django.test.client import RequestFactory diff --git a/authentik/stages/authenticator_validate/tests/test_stage.py b/authentik/stages/authenticator_validate/tests/test_stage.py index f5c8c281c5..98fe5d2fe4 100644 --- a/authentik/stages/authenticator_validate/tests/test_stage.py +++ b/authentik/stages/authenticator_validate/tests/test_stage.py @@ -1,4 +1,5 @@ """Test validator stage""" + from unittest.mock import MagicMock, patch from django.test.client import RequestFactory diff --git a/authentik/stages/authenticator_validate/tests/test_totp.py b/authentik/stages/authenticator_validate/tests/test_totp.py index 5873a4f691..8efcec7eb4 100644 --- a/authentik/stages/authenticator_validate/tests/test_totp.py +++ b/authentik/stages/authenticator_validate/tests/test_totp.py @@ -1,4 +1,5 @@ """Test validator stage""" + from datetime import datetime, timedelta from hashlib import sha256 from time import sleep diff --git a/authentik/stages/authenticator_validate/tests/test_webauthn.py b/authentik/stages/authenticator_validate/tests/test_webauthn.py index 8ea9c68560..9d64bff9dc 100644 --- a/authentik/stages/authenticator_validate/tests/test_webauthn.py +++ b/authentik/stages/authenticator_validate/tests/test_webauthn.py @@ -1,4 +1,5 @@ """Test validator stage""" + from time import sleep from django.test.client import RequestFactory diff --git a/authentik/stages/authenticator_validate/urls.py b/authentik/stages/authenticator_validate/urls.py index 30565eaee7..cb5ceae357 100644 --- a/authentik/stages/authenticator_validate/urls.py +++ b/authentik/stages/authenticator_validate/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_validate.api import AuthenticatorValidateStageViewSet api_urlpatterns = [("stages/authenticator/validate", AuthenticatorValidateStageViewSet)] diff --git a/authentik/stages/authenticator_webauthn/api.py b/authentik/stages/authenticator_webauthn/api.py index 9d19143530..18f3065cb7 100644 --- a/authentik/stages/authenticator_webauthn/api.py +++ b/authentik/stages/authenticator_webauthn/api.py @@ -1,4 +1,5 @@ """AuthenticateWebAuthnStage API Views""" + from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework import mixins from rest_framework.filters import OrderingFilter, SearchFilter diff --git a/authentik/stages/authenticator_webauthn/apps.py b/authentik/stages/authenticator_webauthn/apps.py index 36a2f3f0d4..881e8a06cf 100644 --- a/authentik/stages/authenticator_webauthn/apps.py +++ b/authentik/stages/authenticator_webauthn/apps.py @@ -1,4 +1,5 @@ """authentik webauthn app config""" + from django.apps import AppConfig diff --git a/authentik/stages/authenticator_webauthn/models.py b/authentik/stages/authenticator_webauthn/models.py index 5f47681956..6d7551837e 100644 --- a/authentik/stages/authenticator_webauthn/models.py +++ b/authentik/stages/authenticator_webauthn/models.py @@ -1,4 +1,5 @@ """WebAuthn stage""" + from typing import Optional from django.contrib.auth import get_user_model diff --git a/authentik/stages/authenticator_webauthn/stage.py b/authentik/stages/authenticator_webauthn/stage.py index 35b42e6aee..836e05df08 100644 --- a/authentik/stages/authenticator_webauthn/stage.py +++ b/authentik/stages/authenticator_webauthn/stage.py @@ -1,4 +1,5 @@ """WebAuthn stage""" + from json import loads from django.http import HttpRequest, HttpResponse diff --git a/authentik/stages/authenticator_webauthn/tests.py b/authentik/stages/authenticator_webauthn/tests.py index 28f67a6c92..ecba7ee7ed 100644 --- a/authentik/stages/authenticator_webauthn/tests.py +++ b/authentik/stages/authenticator_webauthn/tests.py @@ -1,4 +1,5 @@ """Test WebAuthn API""" + from base64 import b64decode from django.urls import reverse diff --git a/authentik/stages/authenticator_webauthn/urls.py b/authentik/stages/authenticator_webauthn/urls.py index 9116dbceab..62b13a96bb 100644 --- a/authentik/stages/authenticator_webauthn/urls.py +++ b/authentik/stages/authenticator_webauthn/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.authenticator_webauthn.api import ( AuthenticateWebAuthnStageViewSet, WebAuthnAdminDeviceViewSet, diff --git a/authentik/stages/captcha/api.py b/authentik/stages/captcha/api.py index b8ff793ceb..8d833197cd 100644 --- a/authentik/stages/captcha/api.py +++ b/authentik/stages/captcha/api.py @@ -1,4 +1,5 @@ """CaptchaStage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/captcha/apps.py b/authentik/stages/captcha/apps.py index 69df384a2c..26c454ec3f 100644 --- a/authentik/stages/captcha/apps.py +++ b/authentik/stages/captcha/apps.py @@ -1,4 +1,5 @@ """authentik captcha app""" + from django.apps import AppConfig diff --git a/authentik/stages/captcha/tests.py b/authentik/stages/captcha/tests.py index e83fdd1169..d5d63d8c20 100644 --- a/authentik/stages/captcha/tests.py +++ b/authentik/stages/captcha/tests.py @@ -1,4 +1,5 @@ """captcha tests""" + from django.urls import reverse from authentik.core.tests.utils import create_test_admin_user, create_test_flow diff --git a/authentik/stages/captcha/urls.py b/authentik/stages/captcha/urls.py index b0fd79df66..67484428ca 100644 --- a/authentik/stages/captcha/urls.py +++ b/authentik/stages/captcha/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.captcha.api import CaptchaStageViewSet api_urlpatterns = [("stages/captcha", CaptchaStageViewSet)] diff --git a/authentik/stages/consent/api.py b/authentik/stages/consent/api.py index ee8940325e..8c22a2d250 100644 --- a/authentik/stages/consent/api.py +++ b/authentik/stages/consent/api.py @@ -1,4 +1,5 @@ """ConsentStage API Views""" + from django_filters.rest_framework import DjangoFilterBackend from guardian.utils import get_anonymous_user from rest_framework import mixins diff --git a/authentik/stages/consent/apps.py b/authentik/stages/consent/apps.py index ba4b04e60c..0c0e664fb7 100644 --- a/authentik/stages/consent/apps.py +++ b/authentik/stages/consent/apps.py @@ -1,4 +1,5 @@ """authentik consent app""" + from django.apps import AppConfig diff --git a/authentik/stages/consent/stage.py b/authentik/stages/consent/stage.py index 61677559cd..eda0d03f60 100644 --- a/authentik/stages/consent/stage.py +++ b/authentik/stages/consent/stage.py @@ -1,4 +1,5 @@ """authentik consent stage""" + from typing import Optional from uuid import uuid4 diff --git a/authentik/stages/consent/tests.py b/authentik/stages/consent/tests.py index 35b508a5a8..09e1541b85 100644 --- a/authentik/stages/consent/tests.py +++ b/authentik/stages/consent/tests.py @@ -1,4 +1,5 @@ """consent tests""" + from time import sleep from django.urls import reverse diff --git a/authentik/stages/consent/urls.py b/authentik/stages/consent/urls.py index 5be8f69c42..cc2457b6c7 100644 --- a/authentik/stages/consent/urls.py +++ b/authentik/stages/consent/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.consent.api import ConsentStageViewSet, UserConsentViewSet api_urlpatterns = [ diff --git a/authentik/stages/deny/api.py b/authentik/stages/deny/api.py index bdadff7491..ed55253326 100644 --- a/authentik/stages/deny/api.py +++ b/authentik/stages/deny/api.py @@ -1,4 +1,5 @@ """deny Stage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/deny/apps.py b/authentik/stages/deny/apps.py index f7ccba4620..4b1e4a1709 100644 --- a/authentik/stages/deny/apps.py +++ b/authentik/stages/deny/apps.py @@ -1,4 +1,5 @@ """authentik deny stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/deny/models.py b/authentik/stages/deny/models.py index c5ab2c2519..b57776966f 100644 --- a/authentik/stages/deny/models.py +++ b/authentik/stages/deny/models.py @@ -1,4 +1,5 @@ """deny stage models""" + from django.db import models from django.utils.translation import gettext_lazy as _ from django.views import View diff --git a/authentik/stages/deny/stage.py b/authentik/stages/deny/stage.py index 606f504a10..a5cd134661 100644 --- a/authentik/stages/deny/stage.py +++ b/authentik/stages/deny/stage.py @@ -1,4 +1,5 @@ """Deny stage logic""" + from django.http import HttpRequest, HttpResponse from authentik.flows.stage import StageView diff --git a/authentik/stages/deny/tests.py b/authentik/stages/deny/tests.py index 17e9d49bb6..f61bc7cfdd 100644 --- a/authentik/stages/deny/tests.py +++ b/authentik/stages/deny/tests.py @@ -1,4 +1,5 @@ """deny tests""" + from django.urls import reverse from authentik.core.tests.utils import create_test_admin_user, create_test_flow diff --git a/authentik/stages/deny/urls.py b/authentik/stages/deny/urls.py index 4c31ee8955..f5da121473 100644 --- a/authentik/stages/deny/urls.py +++ b/authentik/stages/deny/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.deny.api import DenyStageViewSet api_urlpatterns = [("stages/deny", DenyStageViewSet)] diff --git a/authentik/stages/dummy/api.py b/authentik/stages/dummy/api.py index b443b822c1..4792329696 100644 --- a/authentik/stages/dummy/api.py +++ b/authentik/stages/dummy/api.py @@ -1,4 +1,5 @@ """DummyStage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/dummy/models.py b/authentik/stages/dummy/models.py index 41aa022184..cfd14b914f 100644 --- a/authentik/stages/dummy/models.py +++ b/authentik/stages/dummy/models.py @@ -1,4 +1,5 @@ """dummy stage models""" + from django.db import models from django.utils.translation import gettext as _ from django.views import View diff --git a/authentik/stages/dummy/stage.py b/authentik/stages/dummy/stage.py index 77423dd4e4..e6468420c2 100644 --- a/authentik/stages/dummy/stage.py +++ b/authentik/stages/dummy/stage.py @@ -1,4 +1,5 @@ """authentik multi-stage authentication engine""" + from django.http.response import HttpResponse from rest_framework.fields import CharField diff --git a/authentik/stages/dummy/tests.py b/authentik/stages/dummy/tests.py index 20296802a6..1b52f76ef8 100644 --- a/authentik/stages/dummy/tests.py +++ b/authentik/stages/dummy/tests.py @@ -1,4 +1,5 @@ """dummy tests""" + from django.urls import reverse from authentik.core.tests.utils import create_test_admin_user, create_test_flow diff --git a/authentik/stages/dummy/urls.py b/authentik/stages/dummy/urls.py index 195c5487b9..f57b2437aa 100644 --- a/authentik/stages/dummy/urls.py +++ b/authentik/stages/dummy/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.dummy.api import DummyStageViewSet api_urlpatterns = [("stages/dummy", DummyStageViewSet)] diff --git a/authentik/stages/email/api.py b/authentik/stages/email/api.py index b77fff2e7e..67f0f26f06 100644 --- a/authentik/stages/email/api.py +++ b/authentik/stages/email/api.py @@ -1,4 +1,5 @@ """EmailStage API Views""" + from drf_spectacular.utils import extend_schema from rest_framework.decorators import action from rest_framework.request import Request diff --git a/authentik/stages/email/apps.py b/authentik/stages/email/apps.py index ba748c18fd..cc1c4fb97b 100644 --- a/authentik/stages/email/apps.py +++ b/authentik/stages/email/apps.py @@ -1,4 +1,5 @@ """authentik email stage config""" + from structlog.stdlib import get_logger from authentik.blueprints.apps import ManagedAppConfig diff --git a/authentik/stages/email/management/commands/test_email.py b/authentik/stages/email/management/commands/test_email.py index fd65b9e5c4..e550097da0 100644 --- a/authentik/stages/email/management/commands/test_email.py +++ b/authentik/stages/email/management/commands/test_email.py @@ -1,4 +1,5 @@ """Send a test-email with global settings""" + from uuid import uuid4 from django.core.management.base import no_translations diff --git a/authentik/stages/email/models.py b/authentik/stages/email/models.py index fcc63868c8..0a0f488db1 100644 --- a/authentik/stages/email/models.py +++ b/authentik/stages/email/models.py @@ -1,4 +1,5 @@ """email stage models""" + from os import R_OK, access from pathlib import Path from typing import Type diff --git a/authentik/stages/email/stage.py b/authentik/stages/email/stage.py index 160a68e922..369fdfe9dd 100644 --- a/authentik/stages/email/stage.py +++ b/authentik/stages/email/stage.py @@ -1,4 +1,5 @@ """authentik multi-stage authentication engine""" + from datetime import timedelta from uuid import uuid4 diff --git a/authentik/stages/email/tasks.py b/authentik/stages/email/tasks.py index 407995b29f..2a8c0eb4c9 100644 --- a/authentik/stages/email/tasks.py +++ b/authentik/stages/email/tasks.py @@ -1,4 +1,5 @@ """email stage tasks""" + from email.utils import make_msgid from smtplib import SMTPException from typing import Any, Optional diff --git a/authentik/stages/email/templatetags/authentik_stages_email.py b/authentik/stages/email/templatetags/authentik_stages_email.py index 9b3dfb194a..6b55da2bd6 100644 --- a/authentik/stages/email/templatetags/authentik_stages_email.py +++ b/authentik/stages/email/templatetags/authentik_stages_email.py @@ -1,4 +1,5 @@ """authentik core inlining template tags""" + from base64 import b64encode from pathlib import Path diff --git a/authentik/stages/email/tests/test_api.py b/authentik/stages/email/tests/test_api.py index 4488a578e7..04194e368c 100644 --- a/authentik/stages/email/tests/test_api.py +++ b/authentik/stages/email/tests/test_api.py @@ -1,4 +1,5 @@ """email stage api tests""" + from django.urls import reverse from rest_framework.serializers import ValidationError from rest_framework.test import APITestCase diff --git a/authentik/stages/email/tests/test_sending.py b/authentik/stages/email/tests/test_sending.py index 5c67c8842f..fd7f3eca3e 100644 --- a/authentik/stages/email/tests/test_sending.py +++ b/authentik/stages/email/tests/test_sending.py @@ -1,4 +1,5 @@ """email tests""" + from smtplib import SMTPException from unittest.mock import MagicMock, PropertyMock, patch diff --git a/authentik/stages/email/tests/test_stage.py b/authentik/stages/email/tests/test_stage.py index 2775499373..e1a6665ad8 100644 --- a/authentik/stages/email/tests/test_stage.py +++ b/authentik/stages/email/tests/test_stage.py @@ -1,4 +1,5 @@ """email tests""" + from unittest.mock import MagicMock, PropertyMock, patch from django.core import mail diff --git a/authentik/stages/email/tests/test_templates.py b/authentik/stages/email/tests/test_templates.py index f8531b078e..d65bdb2194 100644 --- a/authentik/stages/email/tests/test_templates.py +++ b/authentik/stages/email/tests/test_templates.py @@ -1,4 +1,5 @@ """email tests""" + from os import chmod, unlink from pathlib import Path from shutil import rmtree diff --git a/authentik/stages/email/urls.py b/authentik/stages/email/urls.py index f435ae56e5..fbbfdfe4e9 100644 --- a/authentik/stages/email/urls.py +++ b/authentik/stages/email/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.email.api import EmailStageViewSet api_urlpatterns = [("stages/email", EmailStageViewSet)] diff --git a/authentik/stages/email/utils.py b/authentik/stages/email/utils.py index 8f7f702ce2..a086250596 100644 --- a/authentik/stages/email/utils.py +++ b/authentik/stages/email/utils.py @@ -1,4 +1,5 @@ """email utils""" + from email.mime.image import MIMEImage from functools import lru_cache from pathlib import Path diff --git a/authentik/stages/identification/api.py b/authentik/stages/identification/api.py index 1f2ab50578..9ad97320e8 100644 --- a/authentik/stages/identification/api.py +++ b/authentik/stages/identification/api.py @@ -1,4 +1,5 @@ """Identification Stage API Views""" + from django.utils.translation import gettext_lazy as _ from rest_framework.exceptions import ValidationError from rest_framework.viewsets import ModelViewSet diff --git a/authentik/stages/identification/apps.py b/authentik/stages/identification/apps.py index e44ebc159f..184a52af77 100644 --- a/authentik/stages/identification/apps.py +++ b/authentik/stages/identification/apps.py @@ -1,4 +1,5 @@ """authentik identification stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/identification/signals.py b/authentik/stages/identification/signals.py index c5d1bdca6f..7eb44435f3 100644 --- a/authentik/stages/identification/signals.py +++ b/authentik/stages/identification/signals.py @@ -1,4 +1,5 @@ """authentik identification signals""" + from django.core.signals import Signal # Arguments: request: HttpRequest, uid_field: Value entered by user diff --git a/authentik/stages/identification/stage.py b/authentik/stages/identification/stage.py index b71792ff60..f8d0928531 100644 --- a/authentik/stages/identification/stage.py +++ b/authentik/stages/identification/stage.py @@ -1,4 +1,5 @@ """Identification stage logic""" + from dataclasses import asdict from random import SystemRandom from time import sleep @@ -245,7 +246,7 @@ class IdentificationStageView(ChallengeStageView): self.executor.plan.context[PLAN_CONTEXT_PENDING_USER] = response.pre_user current_stage: IdentificationStage = self.executor.current_stage if not current_stage.show_matched_user: - self.executor.plan.context[ - PLAN_CONTEXT_PENDING_USER_IDENTIFIER - ] = response.validated_data.get("uid_field") + self.executor.plan.context[PLAN_CONTEXT_PENDING_USER_IDENTIFIER] = ( + response.validated_data.get("uid_field") + ) return self.executor.stage_ok() diff --git a/authentik/stages/identification/tests.py b/authentik/stages/identification/tests.py index 375a9d04da..469da0eae5 100644 --- a/authentik/stages/identification/tests.py +++ b/authentik/stages/identification/tests.py @@ -1,4 +1,5 @@ """identification tests""" + from django.urls import reverse from rest_framework.exceptions import ValidationError diff --git a/authentik/stages/identification/urls.py b/authentik/stages/identification/urls.py index a25cd978e3..b2606fc9d5 100644 --- a/authentik/stages/identification/urls.py +++ b/authentik/stages/identification/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.identification.api import IdentificationStageViewSet api_urlpatterns = [("stages/identification", IdentificationStageViewSet)] diff --git a/authentik/stages/invitation/api.py b/authentik/stages/invitation/api.py index 827662d538..bc63ae38d8 100644 --- a/authentik/stages/invitation/api.py +++ b/authentik/stages/invitation/api.py @@ -1,4 +1,5 @@ """Invitation Stage API Views""" + from django_filters.filters import BooleanFilter from django_filters.filterset import FilterSet from rest_framework.serializers import ModelSerializer diff --git a/authentik/stages/invitation/apps.py b/authentik/stages/invitation/apps.py index efd799420b..ff37676584 100644 --- a/authentik/stages/invitation/apps.py +++ b/authentik/stages/invitation/apps.py @@ -1,4 +1,5 @@ """authentik invitation stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/invitation/models.py b/authentik/stages/invitation/models.py index ef6cb1cb27..4296031a9a 100644 --- a/authentik/stages/invitation/models.py +++ b/authentik/stages/invitation/models.py @@ -1,4 +1,5 @@ """invitation stage models""" + from uuid import uuid4 from django.db import models diff --git a/authentik/stages/invitation/signals.py b/authentik/stages/invitation/signals.py index 2b42214072..34e91b4986 100644 --- a/authentik/stages/invitation/signals.py +++ b/authentik/stages/invitation/signals.py @@ -1,4 +1,5 @@ """authentik invitation signals""" + from django.core.signals import Signal # Arguments: request: HttpRequest, invitation: Invitation diff --git a/authentik/stages/invitation/stage.py b/authentik/stages/invitation/stage.py index 742fde1601..2527727ff5 100644 --- a/authentik/stages/invitation/stage.py +++ b/authentik/stages/invitation/stage.py @@ -1,4 +1,5 @@ """invitation stage logic""" + from typing import Optional from deepmerge import always_merger diff --git a/authentik/stages/invitation/tests.py b/authentik/stages/invitation/tests.py index 75989a147c..20d4f92259 100644 --- a/authentik/stages/invitation/tests.py +++ b/authentik/stages/invitation/tests.py @@ -1,4 +1,5 @@ """invitation tests""" + from unittest.mock import MagicMock, patch from django.urls import reverse diff --git a/authentik/stages/invitation/urls.py b/authentik/stages/invitation/urls.py index 6a8f087c96..5422cb05f5 100644 --- a/authentik/stages/invitation/urls.py +++ b/authentik/stages/invitation/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.invitation.api import InvitationStageViewSet, InvitationViewSet api_urlpatterns = [ diff --git a/authentik/stages/password/__init__.py b/authentik/stages/password/__init__.py index d5c73cc96b..6c59258a05 100644 --- a/authentik/stages/password/__init__.py +++ b/authentik/stages/password/__init__.py @@ -1,4 +1,5 @@ """Backend paths""" + BACKEND_INBUILT = "authentik.core.auth.InbuiltBackend" BACKEND_LDAP = "authentik.sources.ldap.auth.LDAPBackend" BACKEND_APP_PASSWORD = "authentik.core.auth.TokenBackend" # nosec diff --git a/authentik/stages/password/api.py b/authentik/stages/password/api.py index d90450e5e7..7ede2ade8f 100644 --- a/authentik/stages/password/api.py +++ b/authentik/stages/password/api.py @@ -1,4 +1,5 @@ """PasswordStage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/password/apps.py b/authentik/stages/password/apps.py index 2ff268260b..d8231d7b72 100644 --- a/authentik/stages/password/apps.py +++ b/authentik/stages/password/apps.py @@ -1,4 +1,5 @@ """authentik core app config""" + from django.apps import AppConfig diff --git a/authentik/stages/password/models.py b/authentik/stages/password/models.py index 792a81afc3..56542f3e49 100644 --- a/authentik/stages/password/models.py +++ b/authentik/stages/password/models.py @@ -1,4 +1,5 @@ """password stage models""" + from typing import Optional from django.contrib.postgres.fields import ArrayField diff --git a/authentik/stages/password/stage.py b/authentik/stages/password/stage.py index de80c67250..964652a080 100644 --- a/authentik/stages/password/stage.py +++ b/authentik/stages/password/stage.py @@ -1,4 +1,5 @@ """authentik password stage""" + from typing import Any, Optional from django.contrib.auth import _clean_credentials diff --git a/authentik/stages/password/tests.py b/authentik/stages/password/tests.py index 4d8b9a38f6..0d48e0e74e 100644 --- a/authentik/stages/password/tests.py +++ b/authentik/stages/password/tests.py @@ -1,4 +1,5 @@ """password tests""" + from unittest.mock import MagicMock, patch from django.core.exceptions import PermissionDenied diff --git a/authentik/stages/password/urls.py b/authentik/stages/password/urls.py index 8e89847ca0..094df29ff5 100644 --- a/authentik/stages/password/urls.py +++ b/authentik/stages/password/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.password.api import PasswordStageViewSet api_urlpatterns = [("stages/password", PasswordStageViewSet)] diff --git a/authentik/stages/prompt/api.py b/authentik/stages/prompt/api.py index 7d484f5988..b9337104d7 100644 --- a/authentik/stages/prompt/api.py +++ b/authentik/stages/prompt/api.py @@ -1,4 +1,5 @@ """Prompt Stage API Views""" + from drf_spectacular.utils import extend_schema from rest_framework.decorators import action from rest_framework.request import Request diff --git a/authentik/stages/prompt/apps.py b/authentik/stages/prompt/apps.py index c584b2968c..d2f794ef76 100644 --- a/authentik/stages/prompt/apps.py +++ b/authentik/stages/prompt/apps.py @@ -1,4 +1,5 @@ """authentik prompt stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/prompt/models.py b/authentik/stages/prompt/models.py index 3005c157d5..c30de6a3e1 100644 --- a/authentik/stages/prompt/models.py +++ b/authentik/stages/prompt/models.py @@ -1,4 +1,5 @@ """prompt models""" + from typing import Any, Optional, Type from urllib.parse import urlparse, urlunparse from uuid import uuid4 diff --git a/authentik/stages/prompt/signals.py b/authentik/stages/prompt/signals.py index a98f249ba5..b2a05aaa54 100644 --- a/authentik/stages/prompt/signals.py +++ b/authentik/stages/prompt/signals.py @@ -1,4 +1,5 @@ """authentik prompt stage signals""" + from django.core.signals import Signal # Arguments: password: str, plan_context: dict[str, Any] diff --git a/authentik/stages/prompt/stage.py b/authentik/stages/prompt/stage.py index df0af1be70..63733bf83d 100644 --- a/authentik/stages/prompt/stage.py +++ b/authentik/stages/prompt/stage.py @@ -1,4 +1,5 @@ """Prompt Stage Logic""" + from email.policy import Policy from types import MethodType from typing import Any, Callable, Iterator diff --git a/authentik/stages/prompt/tests.py b/authentik/stages/prompt/tests.py index 43232fc753..a52d80a0ab 100644 --- a/authentik/stages/prompt/tests.py +++ b/authentik/stages/prompt/tests.py @@ -1,4 +1,5 @@ """Prompt tests""" + from unittest.mock import MagicMock, patch from django.test import RequestFactory diff --git a/authentik/stages/prompt/urls.py b/authentik/stages/prompt/urls.py index dca48c8ade..61d0fe6215 100644 --- a/authentik/stages/prompt/urls.py +++ b/authentik/stages/prompt/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.prompt.api import PromptStageViewSet, PromptViewSet api_urlpatterns = [ diff --git a/authentik/stages/user_delete/api.py b/authentik/stages/user_delete/api.py index 1c557d7146..4f931154e4 100644 --- a/authentik/stages/user_delete/api.py +++ b/authentik/stages/user_delete/api.py @@ -1,4 +1,5 @@ """User Delete Stage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/user_delete/apps.py b/authentik/stages/user_delete/apps.py index b1ca8455cd..e73dbfaab9 100644 --- a/authentik/stages/user_delete/apps.py +++ b/authentik/stages/user_delete/apps.py @@ -1,4 +1,5 @@ """authentik delete stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/user_delete/stage.py b/authentik/stages/user_delete/stage.py index a17c98addb..3ea73f1268 100644 --- a/authentik/stages/user_delete/stage.py +++ b/authentik/stages/user_delete/stage.py @@ -1,4 +1,5 @@ """Delete stage logic""" + from django.contrib import messages from django.contrib.auth import logout from django.http import HttpRequest, HttpResponse diff --git a/authentik/stages/user_delete/tests.py b/authentik/stages/user_delete/tests.py index 832b8d0173..b0ff6ff09b 100644 --- a/authentik/stages/user_delete/tests.py +++ b/authentik/stages/user_delete/tests.py @@ -1,4 +1,5 @@ """delete tests""" + from unittest.mock import patch from django.urls import reverse diff --git a/authentik/stages/user_delete/urls.py b/authentik/stages/user_delete/urls.py index e629a5220e..bf45df6540 100644 --- a/authentik/stages/user_delete/urls.py +++ b/authentik/stages/user_delete/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.user_delete.api import UserDeleteStageViewSet api_urlpatterns = [("stages/user_delete", UserDeleteStageViewSet)] diff --git a/authentik/stages/user_login/api.py b/authentik/stages/user_login/api.py index dad5f777c0..4107b3d66b 100644 --- a/authentik/stages/user_login/api.py +++ b/authentik/stages/user_login/api.py @@ -1,4 +1,5 @@ """Login Stage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/user_login/apps.py b/authentik/stages/user_login/apps.py index 1fcc87d43a..a8a65ef4fe 100644 --- a/authentik/stages/user_login/apps.py +++ b/authentik/stages/user_login/apps.py @@ -1,4 +1,5 @@ """authentik login stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/user_login/middleware.py b/authentik/stages/user_login/middleware.py index 73e42e1acb..1a70b412b4 100644 --- a/authentik/stages/user_login/middleware.py +++ b/authentik/stages/user_login/middleware.py @@ -1,4 +1,5 @@ """Sessions bound to ASN/Network and GeoIP/Continent/etc""" + from django.conf import settings from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.signals import user_logged_out diff --git a/authentik/stages/user_login/stage.py b/authentik/stages/user_login/stage.py index f771f8faaf..a4e60fe890 100644 --- a/authentik/stages/user_login/stage.py +++ b/authentik/stages/user_login/stage.py @@ -1,4 +1,5 @@ """Login stage logic""" + from datetime import timedelta from django.contrib import messages diff --git a/authentik/stages/user_login/tests.py b/authentik/stages/user_login/tests.py index b61f89fd59..d5dd7c05f1 100644 --- a/authentik/stages/user_login/tests.py +++ b/authentik/stages/user_login/tests.py @@ -1,4 +1,5 @@ """login tests""" + from time import sleep from unittest.mock import patch diff --git a/authentik/stages/user_login/urls.py b/authentik/stages/user_login/urls.py index 63e21c7466..2db9f89bed 100644 --- a/authentik/stages/user_login/urls.py +++ b/authentik/stages/user_login/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.user_login.api import UserLoginStageViewSet api_urlpatterns = [ diff --git a/authentik/stages/user_logout/api.py b/authentik/stages/user_logout/api.py index 2168df0fb6..07a8b39893 100644 --- a/authentik/stages/user_logout/api.py +++ b/authentik/stages/user_logout/api.py @@ -1,4 +1,5 @@ """Logout Stage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/user_logout/apps.py b/authentik/stages/user_logout/apps.py index 467b4a189b..1388728a58 100644 --- a/authentik/stages/user_logout/apps.py +++ b/authentik/stages/user_logout/apps.py @@ -1,4 +1,5 @@ """authentik logout stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/user_logout/stage.py b/authentik/stages/user_logout/stage.py index f0cf806664..84bba66dd3 100644 --- a/authentik/stages/user_logout/stage.py +++ b/authentik/stages/user_logout/stage.py @@ -1,4 +1,5 @@ """Logout stage logic""" + from django.contrib.auth import logout from django.http import HttpRequest, HttpResponse diff --git a/authentik/stages/user_logout/tests.py b/authentik/stages/user_logout/tests.py index fdca95e898..8f9035070b 100644 --- a/authentik/stages/user_logout/tests.py +++ b/authentik/stages/user_logout/tests.py @@ -1,4 +1,5 @@ """logout tests""" + from django.urls import reverse from authentik.core.tests.utils import create_test_admin_user, create_test_flow diff --git a/authentik/stages/user_logout/urls.py b/authentik/stages/user_logout/urls.py index 76a3b3ceb1..074f5a8bb0 100644 --- a/authentik/stages/user_logout/urls.py +++ b/authentik/stages/user_logout/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.user_logout.api import UserLogoutStageViewSet api_urlpatterns = [("stages/user_logout", UserLogoutStageViewSet)] diff --git a/authentik/stages/user_write/api.py b/authentik/stages/user_write/api.py index 1abca9e9f2..43d112aeb2 100644 --- a/authentik/stages/user_write/api.py +++ b/authentik/stages/user_write/api.py @@ -1,4 +1,5 @@ """User Write Stage API Views""" + from rest_framework.viewsets import ModelViewSet from authentik.core.api.used_by import UsedByMixin diff --git a/authentik/stages/user_write/apps.py b/authentik/stages/user_write/apps.py index 62e933daeb..c5cbb244c5 100644 --- a/authentik/stages/user_write/apps.py +++ b/authentik/stages/user_write/apps.py @@ -1,4 +1,5 @@ """authentik write stage app config""" + from django.apps import AppConfig diff --git a/authentik/stages/user_write/signals.py b/authentik/stages/user_write/signals.py index 34e7cfdba3..988931006b 100644 --- a/authentik/stages/user_write/signals.py +++ b/authentik/stages/user_write/signals.py @@ -1,4 +1,5 @@ """authentik user_write signals""" + from django.core.signals import Signal # Arguments: request: HttpRequest, user: User, data: dict[str, Any], created: bool diff --git a/authentik/stages/user_write/stage.py b/authentik/stages/user_write/stage.py index 5117f03583..348509e768 100644 --- a/authentik/stages/user_write/stage.py +++ b/authentik/stages/user_write/stage.py @@ -1,4 +1,5 @@ """Write stage logic""" + from typing import Any, Optional from django.contrib.auth import update_session_auth_hash diff --git a/authentik/stages/user_write/tests.py b/authentik/stages/user_write/tests.py index 0fe661e6bd..1fa3f18888 100644 --- a/authentik/stages/user_write/tests.py +++ b/authentik/stages/user_write/tests.py @@ -1,4 +1,5 @@ """write tests""" + from unittest.mock import patch from django.urls import reverse diff --git a/authentik/stages/user_write/urls.py b/authentik/stages/user_write/urls.py index c68a06e8c7..c6d6c79e8f 100644 --- a/authentik/stages/user_write/urls.py +++ b/authentik/stages/user_write/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from authentik.stages.user_write.api import UserWriteStageViewSet api_urlpatterns = [("stages/user_write", UserWriteStageViewSet)] diff --git a/authentik/tenants/api/domains.py b/authentik/tenants/api/domains.py index dc0fa244d6..9532edd7ba 100644 --- a/authentik/tenants/api/domains.py +++ b/authentik/tenants/api/domains.py @@ -1,4 +1,5 @@ """Serializer for tenants models""" + from django.apps import apps from django.http import HttpResponseNotFound from rest_framework.filters import OrderingFilter, SearchFilter diff --git a/authentik/tenants/api/settings.py b/authentik/tenants/api/settings.py index 3f45005e91..1c0a63670c 100644 --- a/authentik/tenants/api/settings.py +++ b/authentik/tenants/api/settings.py @@ -1,4 +1,5 @@ """Serializer for tenants models""" + from django_tenants.utils import get_public_schema_name from rest_framework.generics import RetrieveUpdateAPIView from rest_framework.permissions import SAFE_METHODS diff --git a/authentik/tenants/api/tenants.py b/authentik/tenants/api/tenants.py index 5662a392b8..33e28f81d9 100644 --- a/authentik/tenants/api/tenants.py +++ b/authentik/tenants/api/tenants.py @@ -1,4 +1,5 @@ """Serializer for tenants models""" + from datetime import timedelta from hmac import compare_digest diff --git a/authentik/tenants/apps.py b/authentik/tenants/apps.py index 851ae1e153..9322d33180 100644 --- a/authentik/tenants/apps.py +++ b/authentik/tenants/apps.py @@ -1,4 +1,5 @@ """authentik tenants app""" + from django.db import DEFAULT_DB_ALIAS from django.db.models.signals import post_migrate from django_tenants.utils import get_public_schema_name diff --git a/authentik/tenants/checks.py b/authentik/tenants/checks.py index 7b63c261d6..72c7228f51 100644 --- a/authentik/tenants/checks.py +++ b/authentik/tenants/checks.py @@ -1,4 +1,5 @@ """authentik tenants system checks""" + from django.core.checks import Error, register from authentik.lib.config import CONFIG diff --git a/authentik/tenants/management/__init__.py b/authentik/tenants/management/__init__.py index 032509107f..a666aad85b 100644 --- a/authentik/tenants/management/__init__.py +++ b/authentik/tenants/management/__init__.py @@ -1,4 +1,5 @@ """authentik tenants management command utils""" + from django.core.management.base import BaseCommand from django.db import connection from django_tenants.utils import get_public_schema_name diff --git a/authentik/tenants/models.py b/authentik/tenants/models.py index 0751956461..762c41c72e 100644 --- a/authentik/tenants/models.py +++ b/authentik/tenants/models.py @@ -1,4 +1,5 @@ """Tenant models""" + import re from uuid import uuid4 diff --git a/authentik/tenants/scheduler.py b/authentik/tenants/scheduler.py index b6189dfa5f..56fb1d80ab 100644 --- a/authentik/tenants/scheduler.py +++ b/authentik/tenants/scheduler.py @@ -1,4 +1,5 @@ """Tenant-aware Celery beat scheduler""" + from tenant_schemas_celery.scheduler import ( TenantAwarePersistentScheduler as BaseTenantAwarePersistentScheduler, ) diff --git a/authentik/tenants/tests/test_api.py b/authentik/tenants/tests/test_api.py index 263b9f2498..87f8490186 100644 --- a/authentik/tenants/tests/test_api.py +++ b/authentik/tenants/tests/test_api.py @@ -1,4 +1,5 @@ """Test Tenant API""" + from json import loads from django.urls import reverse diff --git a/authentik/tenants/tests/test_domain.py b/authentik/tenants/tests/test_domain.py index 36d3fa8115..03f6d224bc 100644 --- a/authentik/tenants/tests/test_domain.py +++ b/authentik/tenants/tests/test_domain.py @@ -1,4 +1,5 @@ """Test Domain API""" + from json import loads from django.urls import reverse diff --git a/authentik/tenants/tests/test_event_retention.py b/authentik/tenants/tests/test_event_retention.py index daaa908f10..7900e6ff2f 100644 --- a/authentik/tenants/tests/test_event_retention.py +++ b/authentik/tenants/tests/test_event_retention.py @@ -1,4 +1,5 @@ """Test event retention""" + from django.test.client import RequestFactory from django_tenants.utils import get_public_schema_name from rest_framework.test import APITestCase diff --git a/authentik/tenants/tests/test_recovery.py b/authentik/tenants/tests/test_recovery.py index bc90a38a79..e100dbd3c7 100644 --- a/authentik/tenants/tests/test_recovery.py +++ b/authentik/tenants/tests/test_recovery.py @@ -1,4 +1,5 @@ """Test Tenant Recovery API""" + from json import loads from django.urls import reverse diff --git a/authentik/tenants/urls.py b/authentik/tenants/urls.py index 8cac045520..b75ed6b43b 100644 --- a/authentik/tenants/urls.py +++ b/authentik/tenants/urls.py @@ -1,4 +1,5 @@ """API URLs""" + from django.conf import settings from django.urls import path diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index 0a7bf0c3e0..7983d27679 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -1,4 +1,5 @@ """Tenant utils""" + from django.db import connection from authentik.tenants.models import Tenant @@ -6,7 +7,4 @@ from authentik.tenants.models import Tenant def get_current_tenant() -> Tenant: """Get tenant for current request""" - tenant = getattr(connection, "tenant", None) - if tenant: - return tenant return Tenant.objects.get(schema_name=connection.schema_name) diff --git a/lifecycle/ak.py b/lifecycle/ak.py index deac5a7d6d..b17c070ab7 100644 --- a/lifecycle/ak.py +++ b/lifecycle/ak.py @@ -1,4 +1,5 @@ """Wrapper for lifecycle/ak, to be installed by poetry""" + from os import system from pathlib import Path from sys import argv diff --git a/lifecycle/gunicorn.conf.py b/lifecycle/gunicorn.conf.py index 2ae3d8ca8e..eb32cacfe4 100644 --- a/lifecycle/gunicorn.conf.py +++ b/lifecycle/gunicorn.conf.py @@ -1,4 +1,5 @@ """Gunicorn config""" + import os from hashlib import sha512 from multiprocessing import cpu_count diff --git a/lifecycle/worker.py b/lifecycle/worker.py index 41d09d5cbd..ad4c1ebdb6 100644 --- a/lifecycle/worker.py +++ b/lifecycle/worker.py @@ -1,4 +1,5 @@ """Uvicorn worker""" + from uvicorn.workers import UvicornWorker diff --git a/scripts/generate_config.py b/scripts/generate_config.py index 379ec18736..1f81aa224d 100644 --- a/scripts/generate_config.py +++ b/scripts/generate_config.py @@ -1,4 +1,5 @@ """Generate config for development""" + from yaml import safe_dump from authentik.lib.generators import generate_id diff --git a/scripts/npm_version.py b/scripts/npm_version.py index 2c0d3a9e2d..8ce53d8ace 100644 --- a/scripts/npm_version.py +++ b/scripts/npm_version.py @@ -1,4 +1,5 @@ """Helper script to generate an NPM Version""" + from time import time from authentik import __version__ diff --git a/tests/e2e/test_flows_authenticators.py b/tests/e2e/test_flows_authenticators.py index 80e55b6a6a..ec0327bb7a 100644 --- a/tests/e2e/test_flows_authenticators.py +++ b/tests/e2e/test_flows_authenticators.py @@ -1,4 +1,5 @@ """test flow with otp stages""" + from base64 import b32decode from time import sleep from urllib.parse import parse_qs, urlparse diff --git a/tests/e2e/test_flows_enroll.py b/tests/e2e/test_flows_enroll.py index ddf9959cc4..61b4da5faa 100644 --- a/tests/e2e/test_flows_enroll.py +++ b/tests/e2e/test_flows_enroll.py @@ -1,4 +1,5 @@ """Test Enroll flow""" + from time import sleep from selenium.webdriver.common.by import By diff --git a/tests/e2e/test_flows_login.py b/tests/e2e/test_flows_login.py index aa477a519a..51c8281f88 100644 --- a/tests/e2e/test_flows_login.py +++ b/tests/e2e/test_flows_login.py @@ -1,4 +1,5 @@ """test default login flow""" + from authentik.blueprints.tests import apply_blueprint from tests.e2e.utils import SeleniumTestCase, retry diff --git a/tests/e2e/test_flows_recovery.py b/tests/e2e/test_flows_recovery.py index ddddd9140c..42004bb2ce 100644 --- a/tests/e2e/test_flows_recovery.py +++ b/tests/e2e/test_flows_recovery.py @@ -1,4 +1,5 @@ """Test recovery flow""" + from time import sleep from selenium.webdriver.common.by import By diff --git a/tests/e2e/test_flows_stage_setup.py b/tests/e2e/test_flows_stage_setup.py index f0c791ffe6..a82b2b7a28 100644 --- a/tests/e2e/test_flows_stage_setup.py +++ b/tests/e2e/test_flows_stage_setup.py @@ -1,4 +1,5 @@ """test stage setup flows (password change)""" + from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys diff --git a/tests/e2e/test_provider_ldap.py b/tests/e2e/test_provider_ldap.py index 72f5131031..5a3a8d7f3f 100644 --- a/tests/e2e/test_provider_ldap.py +++ b/tests/e2e/test_provider_ldap.py @@ -1,4 +1,5 @@ """LDAP and Outpost e2e tests""" + from dataclasses import asdict from time import sleep diff --git a/tests/e2e/test_provider_oauth2_github.py b/tests/e2e/test_provider_oauth2_github.py index 5095421a8c..3fbdd7316b 100644 --- a/tests/e2e/test_provider_oauth2_github.py +++ b/tests/e2e/test_provider_oauth2_github.py @@ -1,4 +1,5 @@ """test OAuth Provider flow""" + from time import sleep from typing import Any, Optional diff --git a/tests/e2e/test_provider_oauth2_grafana.py b/tests/e2e/test_provider_oauth2_grafana.py index fa8f12d1d3..2a02f603a4 100644 --- a/tests/e2e/test_provider_oauth2_grafana.py +++ b/tests/e2e/test_provider_oauth2_grafana.py @@ -1,4 +1,5 @@ """test OAuth2 OpenID Provider flow""" + from time import sleep from typing import Any, Optional diff --git a/tests/e2e/test_provider_oidc.py b/tests/e2e/test_provider_oidc.py index c14a498a61..5af7e3f2a9 100644 --- a/tests/e2e/test_provider_oidc.py +++ b/tests/e2e/test_provider_oidc.py @@ -1,4 +1,5 @@ """test OAuth2 OpenID Provider flow""" + from json import loads from time import sleep diff --git a/tests/e2e/test_provider_oidc_implicit.py b/tests/e2e/test_provider_oidc_implicit.py index 37dff0aa32..9d35c2cc43 100644 --- a/tests/e2e/test_provider_oidc_implicit.py +++ b/tests/e2e/test_provider_oidc_implicit.py @@ -1,4 +1,5 @@ """test OAuth2 OpenID Provider flow""" + from json import loads from time import sleep diff --git a/tests/e2e/test_provider_proxy.py b/tests/e2e/test_provider_proxy.py index e91e806660..99d306dd90 100644 --- a/tests/e2e/test_provider_proxy.py +++ b/tests/e2e/test_provider_proxy.py @@ -1,4 +1,5 @@ """Proxy and Outpost e2e tests""" + from base64 import b64encode from dataclasses import asdict from sys import platform diff --git a/tests/e2e/test_provider_radius.py b/tests/e2e/test_provider_radius.py index b4856e034e..a0c7bf1b45 100644 --- a/tests/e2e/test_provider_radius.py +++ b/tests/e2e/test_provider_radius.py @@ -1,4 +1,5 @@ """Radius e2e tests""" + from dataclasses import asdict from time import sleep diff --git a/tests/e2e/test_provider_saml.py b/tests/e2e/test_provider_saml.py index eefb2c45e1..27c7c94fc4 100644 --- a/tests/e2e/test_provider_saml.py +++ b/tests/e2e/test_provider_saml.py @@ -1,4 +1,5 @@ """test SAML Provider flow""" + from json import loads from time import sleep diff --git a/tests/e2e/test_source_ldap_samba.py b/tests/e2e/test_source_ldap_samba.py index 7711389128..522b7a03f5 100644 --- a/tests/e2e/test_source_ldap_samba.py +++ b/tests/e2e/test_source_ldap_samba.py @@ -1,4 +1,5 @@ """test LDAP Source""" + from typing import Any, Optional from django.db.models import Q diff --git a/tests/e2e/test_source_oauth_oauth1.py b/tests/e2e/test_source_oauth_oauth1.py index 97152321f8..f1672b04be 100644 --- a/tests/e2e/test_source_oauth_oauth1.py +++ b/tests/e2e/test_source_oauth_oauth1.py @@ -1,4 +1,5 @@ """test OAuth Source""" + from time import sleep from typing import Any, Optional diff --git a/tests/e2e/test_source_oauth_oauth2.py b/tests/e2e/test_source_oauth_oauth2.py index 17a26279e5..7a312ef6a1 100644 --- a/tests/e2e/test_source_oauth_oauth2.py +++ b/tests/e2e/test_source_oauth_oauth2.py @@ -1,4 +1,5 @@ """test OAuth Source""" + from pathlib import Path from time import sleep from typing import Any, Optional diff --git a/tests/e2e/test_source_saml.py b/tests/e2e/test_source_saml.py index 788ec29ecf..233f38b9a2 100644 --- a/tests/e2e/test_source_saml.py +++ b/tests/e2e/test_source_saml.py @@ -1,4 +1,5 @@ """test SAML Source""" + from time import sleep from typing import Any, Optional diff --git a/tests/e2e/utils.py b/tests/e2e/utils.py index fdf742845b..77decd7951 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -1,4 +1,5 @@ """authentik e2e testing utilities""" + import json import os import socket diff --git a/tests/integration/test_outpost_docker.py b/tests/integration/test_outpost_docker.py index 99daf19159..1ea8bfc6d6 100644 --- a/tests/integration/test_outpost_docker.py +++ b/tests/integration/test_outpost_docker.py @@ -1,4 +1,5 @@ """outpost tests""" + from shutil import rmtree from tempfile import mkdtemp diff --git a/tests/integration/test_outpost_kubernetes.py b/tests/integration/test_outpost_kubernetes.py index 58a1195dda..068bab14d3 100644 --- a/tests/integration/test_outpost_kubernetes.py +++ b/tests/integration/test_outpost_kubernetes.py @@ -1,4 +1,5 @@ """outpost tests""" + from unittest.mock import MagicMock, patch import pytest diff --git a/tests/integration/test_proxy_docker.py b/tests/integration/test_proxy_docker.py index 7ba027cdd8..5db47da734 100644 --- a/tests/integration/test_proxy_docker.py +++ b/tests/integration/test_proxy_docker.py @@ -1,4 +1,5 @@ """outpost tests""" + from shutil import rmtree from tempfile import mkdtemp diff --git a/tests/integration/test_proxy_kubernetes.py b/tests/integration/test_proxy_kubernetes.py index 935c0c134d..4840ff8326 100644 --- a/tests/integration/test_proxy_kubernetes.py +++ b/tests/integration/test_proxy_kubernetes.py @@ -1,4 +1,5 @@ """Test Controllers""" + from typing import Optional import pytest diff --git a/web/package-lock.json b/web/package-lock.json index 515be9db44..27c5f33546 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -90,7 +90,7 @@ "npm-run-all": "^4.1.5", "prettier": "^3.2.4", "pseudolocale": "^2.0.0", - "pyright": "=1.1.349", + "pyright": "=1.1.338", "react": "^18.2.0", "react-dom": "^18.2.0", "rollup": "^4.9.6", @@ -15757,9 +15757,9 @@ } }, "node_modules/pyright": { - "version": "1.1.349", - "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.349.tgz", - "integrity": "sha512-AIS2OuIPSifLGeeIlM9NihSdHSCheT7eXPdKnVxIwTvuOXwOX75oQS7xsW1PK+Tkc+S5SzvXeCwPChbjXd+Ztg==", + "version": "1.1.338", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.338.tgz", + "integrity": "sha512-cY4p/LZjC3E1m6If48n19vZgBOUASIOX6zMTavIo2o2JlJRd6/+gy+aYaMdmljVF2mVP8NG6OuKiGxERSdpQOw==", "dev": true, "bin": { "pyright": "index.js", diff --git a/web/package.json b/web/package.json index 9205fc0096..77bc690146 100644 --- a/web/package.json +++ b/web/package.json @@ -115,7 +115,7 @@ "npm-run-all": "^4.1.5", "prettier": "^3.2.4", "pseudolocale": "^2.0.0", - "pyright": "=1.1.349", + "pyright": "=1.1.338", "react": "^18.2.0", "react-dom": "^18.2.0", "rollup": "^4.9.6",