@adonis-agora/authkit-server 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/build/assets/grafana/authkit-dashboard.json +118 -0
- package/build/commands/clients_create.d.ts +27 -0
- package/build/commands/clients_create.js +121 -0
- package/build/commands/commands.json +292 -0
- package/build/commands/configure.d.ts +2 -0
- package/build/commands/configure.js +45 -0
- package/build/commands/doctor.d.ts +10 -0
- package/build/commands/doctor.js +113 -0
- package/build/commands/eject.d.ts +11 -0
- package/build/commands/eject.js +96 -0
- package/build/commands/expire_scan.d.ts +28 -0
- package/build/commands/expire_scan.js +92 -0
- package/build/commands/import_users.d.ts +17 -0
- package/build/commands/import_users.js +80 -0
- package/build/commands/keys_rotate.d.ts +21 -0
- package/build/commands/keys_rotate.js +126 -0
- package/build/commands/main.d.ts +12 -0
- package/build/commands/main.js +38 -0
- package/build/commands/settings_get.d.ts +18 -0
- package/build/commands/settings_get.js +43 -0
- package/build/commands/settings_list.d.ts +17 -0
- package/build/commands/settings_list.js +39 -0
- package/build/commands/settings_set.d.ts +20 -0
- package/build/commands/settings_set.js +55 -0
- package/build/commands/settings_unset.d.ts +18 -0
- package/build/commands/settings_unset.js +46 -0
- package/build/commands/ui_preset.d.ts +4 -0
- package/build/commands/ui_preset.js +32 -0
- package/build/database/migrations/make_authkit_oidc_table.d.ts +6 -0
- package/build/database/migrations/make_authkit_oidc_table.js +19 -0
- package/build/host/ui/admin.html +29 -0
- package/build/host/views/account/apps.edge +59 -0
- package/build/host/views/account/confirm.edge +70 -0
- package/build/host/views/account/email-confirmed.edge +16 -0
- package/build/host/views/account/login.edge +33 -0
- package/build/host/views/account/mfa.edge +152 -0
- package/build/host/views/account/orgs.edge +58 -0
- package/build/host/views/account/security.edge +215 -0
- package/build/host/views/account/tokens.edge +75 -0
- package/build/host/views/consent.edge +20 -0
- package/build/host/views/forgot.edge +43 -0
- package/build/host/views/login.edge +251 -0
- package/build/host/views/maintenance.edge +32 -0
- package/build/host/views/mfa-challenge.edge +107 -0
- package/build/host/views/otp-unlock.edge +40 -0
- package/build/host/views/partials/styles.edge +2 -0
- package/build/host/views/reset.edge +30 -0
- package/build/host/views/signup.edge +62 -0
- package/build/host/views/verify-email.edge +17 -0
- package/build/index.d.ts +115 -0
- package/build/index.js +76 -0
- package/build/password/common_passwords.txt +10000 -0
- package/build/providers/authkit_server_provider.d.ts +27 -0
- package/build/providers/authkit_server_provider.js +242 -0
- package/build/src/accounts/account_store.d.ts +578 -0
- package/build/src/accounts/account_store.js +60 -0
- package/build/src/accounts/lucid_account_store.d.ts +156 -0
- package/build/src/accounts/lucid_account_store.js +294 -0
- package/build/src/accounts/lucid_store/core.d.ts +9 -0
- package/build/src/accounts/lucid_store/core.js +306 -0
- package/build/src/accounts/lucid_store/mfa.d.ts +15 -0
- package/build/src/accounts/lucid_store/mfa.js +108 -0
- package/build/src/accounts/lucid_store/organizations.d.ts +13 -0
- package/build/src/accounts/lucid_store/organizations.js +294 -0
- package/build/src/accounts/lucid_store/password_hygiene.d.ts +20 -0
- package/build/src/accounts/lucid_store/password_hygiene.js +130 -0
- package/build/src/accounts/lucid_store/provider_identity.d.ts +8 -0
- package/build/src/accounts/lucid_store/provider_identity.js +59 -0
- package/build/src/accounts/lucid_store/shared.d.ts +113 -0
- package/build/src/accounts/lucid_store/shared.js +130 -0
- package/build/src/accounts/lucid_store/status_profile.d.ts +34 -0
- package/build/src/accounts/lucid_store/status_profile.js +100 -0
- package/build/src/accounts/lucid_store/webauthn.d.ts +8 -0
- package/build/src/accounts/lucid_store/webauthn.js +140 -0
- package/build/src/accounts/lucid_stores.d.ts +45 -0
- package/build/src/accounts/lucid_stores.js +30 -0
- package/build/src/adapters/adapter_contract.d.ts +37 -0
- package/build/src/adapters/adapter_contract.js +1 -0
- package/build/src/adapters/database_adapter.d.ts +21 -0
- package/build/src/adapters/database_adapter.js +79 -0
- package/build/src/adapters/factory.d.ts +30 -0
- package/build/src/adapters/factory.js +43 -0
- package/build/src/adapters/redis_adapter.d.ts +24 -0
- package/build/src/adapters/redis_adapter.js +122 -0
- package/build/src/audit/audit_sink.d.ts +63 -0
- package/build/src/audit/audit_sink.js +1 -0
- package/build/src/audit/lucid_audit_sink.d.ts +10 -0
- package/build/src/audit/lucid_audit_sink.js +99 -0
- package/build/src/commands/expire_scan_command.d.ts +60 -0
- package/build/src/commands/expire_scan_command.js +229 -0
- package/build/src/commands/import_clients.d.ts +40 -0
- package/build/src/commands/import_clients.js +79 -0
- package/build/src/commands/import_users.d.ts +51 -0
- package/build/src/commands/import_users.js +94 -0
- package/build/src/commands/resolve_config.d.ts +13 -0
- package/build/src/commands/resolve_config.js +18 -0
- package/build/src/commands/settings_commands.d.ts +47 -0
- package/build/src/commands/settings_commands.js +270 -0
- package/build/src/controllers/oidc_callback_controller.d.ts +22 -0
- package/build/src/controllers/oidc_callback_controller.js +33 -0
- package/build/src/define_config.d.ts +772 -0
- package/build/src/define_config.js +351 -0
- package/build/src/doctor/checks.d.ts +197 -0
- package/build/src/doctor/checks.js +858 -0
- package/build/src/events/dispatcher.d.ts +45 -0
- package/build/src/events/dispatcher.js +117 -0
- package/build/src/host/account_api/account_api_controller.d.ts +245 -0
- package/build/src/host/account_api/account_api_controller.js +827 -0
- package/build/src/host/account_deletion_ops.d.ts +80 -0
- package/build/src/host/account_deletion_ops.js +118 -0
- package/build/src/host/account_deletion_service.d.ts +63 -0
- package/build/src/host/account_deletion_service.js +133 -0
- package/build/src/host/account_export_service.d.ts +76 -0
- package/build/src/host/account_export_service.js +140 -0
- package/build/src/host/account_home.d.ts +11 -0
- package/build/src/host/account_home.js +11 -0
- package/build/src/host/account_lockout.d.ts +86 -0
- package/build/src/host/account_lockout.js +185 -0
- package/build/src/host/active_org_cookie.d.ts +28 -0
- package/build/src/host/active_org_cookie.js +47 -0
- package/build/src/host/admin_api/admin_api_guard.d.ts +16 -0
- package/build/src/host/admin_api/admin_api_guard.js +59 -0
- package/build/src/host/admin_api/admin_orgs_service.d.ts +125 -0
- package/build/src/host/admin_api/admin_orgs_service.js +324 -0
- package/build/src/host/admin_api/admin_users_service.d.ts +163 -0
- package/build/src/host/admin_api/admin_users_service.js +308 -0
- package/build/src/host/admin_api/api_clients_controller.d.ts +54 -0
- package/build/src/host/admin_api/api_clients_controller.js +89 -0
- package/build/src/host/admin_api/api_keys_controller.d.ts +19 -0
- package/build/src/host/admin_api/api_keys_controller.js +36 -0
- package/build/src/host/admin_api/api_misc_controller.d.ts +19 -0
- package/build/src/host/admin_api/api_misc_controller.js +44 -0
- package/build/src/host/admin_api/api_orgs_controller.d.ts +108 -0
- package/build/src/host/admin_api/api_orgs_controller.js +189 -0
- package/build/src/host/admin_api/api_settings_controller.d.ts +55 -0
- package/build/src/host/admin_api/api_settings_controller.js +134 -0
- package/build/src/host/admin_api/api_users_controller.d.ts +108 -0
- package/build/src/host/admin_api/api_users_controller.js +187 -0
- package/build/src/host/admin_api/dto.d.ts +131 -0
- package/build/src/host/admin_api/dto.js +122 -0
- package/build/src/host/admin_api/token_verify_service.d.ts +34 -0
- package/build/src/host/admin_api/token_verify_service.js +74 -0
- package/build/src/host/admin_clients_service.d.ts +88 -0
- package/build/src/host/admin_clients_service.js +181 -0
- package/build/src/host/admin_console/admin_shell_controller.d.ts +27 -0
- package/build/src/host/admin_console/admin_shell_controller.js +167 -0
- package/build/src/host/admin_console/console_audit_controller.d.ts +17 -0
- package/build/src/host/admin_console/console_audit_controller.js +25 -0
- package/build/src/host/admin_console/console_clients_controller.d.ts +53 -0
- package/build/src/host/admin_console/console_clients_controller.js +102 -0
- package/build/src/host/admin_console/console_impersonation_controller.d.ts +23 -0
- package/build/src/host/admin_console/console_impersonation_controller.js +45 -0
- package/build/src/host/admin_console/console_keys_controller.d.ts +24 -0
- package/build/src/host/admin_console/console_keys_controller.js +41 -0
- package/build/src/host/admin_console/console_orgs_controller.d.ts +96 -0
- package/build/src/host/admin_console/console_orgs_controller.js +238 -0
- package/build/src/host/admin_console/console_overview_controller.d.ts +27 -0
- package/build/src/host/admin_console/console_overview_controller.js +44 -0
- package/build/src/host/admin_console/console_roles_controller.d.ts +31 -0
- package/build/src/host/admin_console/console_roles_controller.js +108 -0
- package/build/src/host/admin_console/console_sessions_controller.d.ts +91 -0
- package/build/src/host/admin_console/console_sessions_controller.js +125 -0
- package/build/src/host/admin_console/console_settings_controller.d.ts +47 -0
- package/build/src/host/admin_console/console_settings_controller.js +115 -0
- package/build/src/host/admin_console/console_users_controller.d.ts +110 -0
- package/build/src/host/admin_console/console_users_controller.js +212 -0
- package/build/src/host/admin_prefix.d.ts +50 -0
- package/build/src/host/admin_prefix.js +77 -0
- package/build/src/host/admin_sessions_service.d.ts +119 -0
- package/build/src/host/admin_sessions_service.js +284 -0
- package/build/src/host/admin_stats_service.d.ts +44 -0
- package/build/src/host/admin_stats_service.js +130 -0
- package/build/src/host/admin_validators.d.ts +247 -0
- package/build/src/host/admin_validators.js +197 -0
- package/build/src/host/augmentations.d.ts +12 -0
- package/build/src/host/augmentations.js +1 -0
- package/build/src/host/auth_host_config.d.ts +22 -0
- package/build/src/host/auth_host_config.js +13 -0
- package/build/src/host/avatar_storage.d.ts +68 -0
- package/build/src/host/avatar_storage.js +166 -0
- package/build/src/host/bot_protection.d.ts +187 -0
- package/build/src/host/bot_protection.js +132 -0
- package/build/src/host/branding.d.ts +19 -0
- package/build/src/host/branding.js +8 -0
- package/build/src/host/config_locks.d.ts +38 -0
- package/build/src/host/config_locks.js +70 -0
- package/build/src/host/console_session.d.ts +27 -0
- package/build/src/host/console_session.js +36 -0
- package/build/src/host/controllers/account_apps_controller.d.ts +15 -0
- package/build/src/host/controllers/account_apps_controller.js +61 -0
- package/build/src/host/controllers/account_confirm_controller.d.ts +24 -0
- package/build/src/host/controllers/account_confirm_controller.js +144 -0
- package/build/src/host/controllers/account_mfa_controller.d.ts +28 -0
- package/build/src/host/controllers/account_mfa_controller.js +208 -0
- package/build/src/host/controllers/account_orgs_controller.d.ts +80 -0
- package/build/src/host/controllers/account_orgs_controller.js +401 -0
- package/build/src/host/controllers/account_security_controller.d.ts +43 -0
- package/build/src/host/controllers/account_security_controller.js +546 -0
- package/build/src/host/controllers/account_session_controller.d.ts +21 -0
- package/build/src/host/controllers/account_session_controller.js +113 -0
- package/build/src/host/controllers/account_tokens_controller.d.ts +7 -0
- package/build/src/host/controllers/account_tokens_controller.js +67 -0
- package/build/src/host/controllers/interaction_controller.d.ts +125 -0
- package/build/src/host/controllers/interaction_controller.js +981 -0
- package/build/src/host/controllers/pat_introspection_controller.d.ts +22 -0
- package/build/src/host/controllers/pat_introspection_controller.js +46 -0
- package/build/src/host/controllers/registration_controller.d.ts +18 -0
- package/build/src/host/controllers/registration_controller.js +382 -0
- package/build/src/host/controllers/social_controller.d.ts +8 -0
- package/build/src/host/controllers/social_controller.js +89 -0
- package/build/src/host/csrf.d.ts +29 -0
- package/build/src/host/csrf.js +14 -0
- package/build/src/host/default_mailer.d.ts +112 -0
- package/build/src/host/default_mailer.js +417 -0
- package/build/src/host/durable/account_deletion_workflow.d.ts +48 -0
- package/build/src/host/durable/account_deletion_workflow.js +86 -0
- package/build/src/host/durable/account_export_workflow.d.ts +68 -0
- package/build/src/host/durable/account_export_workflow.js +93 -0
- package/build/src/host/durable/index.d.ts +68 -0
- package/build/src/host/durable/index.js +77 -0
- package/build/src/host/email_templates.d.ts +39 -0
- package/build/src/host/email_templates.js +69 -0
- package/build/src/host/geo.d.ts +22 -0
- package/build/src/host/geo.js +39 -0
- package/build/src/host/i18n.d.ts +1416 -0
- package/build/src/host/i18n.js +1583 -0
- package/build/src/host/impersonation.d.ts +25 -0
- package/build/src/host/impersonation.js +31 -0
- package/build/src/host/key_rotation.d.ts +14 -0
- package/build/src/host/key_rotation.js +27 -0
- package/build/src/host/key_rotation_actions.d.ts +42 -0
- package/build/src/host/key_rotation_actions.js +27 -0
- package/build/src/host/login_attempt.d.ts +98 -0
- package/build/src/host/login_attempt.js +211 -0
- package/build/src/host/login_notify.d.ts +27 -0
- package/build/src/host/login_notify.js +142 -0
- package/build/src/host/middleware/account_auth.d.ts +7 -0
- package/build/src/host/middleware/account_auth.js +11 -0
- package/build/src/host/otp_lockout.d.ts +103 -0
- package/build/src/host/otp_lockout.js +221 -0
- package/build/src/host/rate_limit.d.ts +39 -0
- package/build/src/host/rate_limit.js +94 -0
- package/build/src/host/register_auth_host.d.ts +97 -0
- package/build/src/host/register_auth_host.js +466 -0
- package/build/src/host/renderers/edge_renderer.d.ts +12 -0
- package/build/src/host/renderers/edge_renderer.js +38 -0
- package/build/src/host/renderers/inertia_renderer.d.ts +70 -0
- package/build/src/host/renderers/inertia_renderer.js +54 -0
- package/build/src/host/runtime_settings.d.ts +181 -0
- package/build/src/host/runtime_settings.js +307 -0
- package/build/src/host/runtime_toggles.d.ts +807 -0
- package/build/src/host/runtime_toggles.js +784 -0
- package/build/src/host/security_notice_service.d.ts +36 -0
- package/build/src/host/security_notice_service.js +87 -0
- package/build/src/host/session_context.d.ts +23 -0
- package/build/src/host/session_context.js +89 -0
- package/build/src/host/sudo_mode.d.ts +56 -0
- package/build/src/host/sudo_mode.js +99 -0
- package/build/src/host/svg_chart.d.ts +15 -0
- package/build/src/host/svg_chart.js +45 -0
- package/build/src/host/trusted_device.d.ts +61 -0
- package/build/src/host/trusted_device.js +65 -0
- package/build/src/host/ui-dist/assets/index-CRWcmsex.js +137 -0
- package/build/src/host/ui-dist/assets/index-DTSmD4RU.css +1 -0
- package/build/src/host/ui-dist/index.html +17 -0
- package/build/src/host/user_agent.d.ts +18 -0
- package/build/src/host/user_agent.js +50 -0
- package/build/src/host/validators.d.ts +127 -0
- package/build/src/host/validators.js +53 -0
- package/build/src/keys/jwks_manager.d.ts +6 -0
- package/build/src/keys/jwks_manager.js +11 -0
- package/build/src/keys/keystore.d.ts +52 -0
- package/build/src/keys/keystore.js +68 -0
- package/build/src/keys/keystore_codec.d.ts +20 -0
- package/build/src/keys/keystore_codec.js +42 -0
- package/build/src/keys/keystore_crypto.d.ts +9 -0
- package/build/src/keys/keystore_crypto.js +27 -0
- package/build/src/keys/keystore_manager.d.ts +43 -0
- package/build/src/keys/keystore_manager.js +104 -0
- package/build/src/keys/keystore_vault.d.ts +113 -0
- package/build/src/keys/keystore_vault.js +265 -0
- package/build/src/mixins/json_column.d.ts +33 -0
- package/build/src/mixins/json_column.js +38 -0
- package/build/src/mixins/with_audit_log.d.ts +19 -0
- package/build/src/mixins/with_audit_log.js +39 -0
- package/build/src/mixins/with_auth_user.d.ts +24 -0
- package/build/src/mixins/with_auth_user.js +46 -0
- package/build/src/mixins/with_credentials.d.ts +20 -0
- package/build/src/mixins/with_credentials.js +29 -0
- package/build/src/mixins/with_mfa.d.ts +35 -0
- package/build/src/mixins/with_mfa.js +21 -0
- package/build/src/mixins/with_personal_access_token.d.ts +19 -0
- package/build/src/mixins/with_personal_access_token.js +42 -0
- package/build/src/mixins/with_provider_identity.d.ts +20 -0
- package/build/src/mixins/with_provider_identity.js +32 -0
- package/build/src/mixins/with_webauthn_credential.d.ts +37 -0
- package/build/src/mixins/with_webauthn_credential.js +46 -0
- package/build/src/observability/diagnostics_bridge.d.ts +6 -0
- package/build/src/observability/diagnostics_bridge.js +27 -0
- package/build/src/observability/metrics_controller.d.ts +5 -0
- package/build/src/observability/metrics_controller.js +24 -0
- package/build/src/observability/metrics_service.d.ts +2 -0
- package/build/src/observability/metrics_service.js +7 -0
- package/build/src/observability/otel_recorder.d.ts +10 -0
- package/build/src/observability/otel_recorder.js +59 -0
- package/build/src/observability/telescope/data_providers.d.ts +24 -0
- package/build/src/observability/telescope/data_providers.js +235 -0
- package/build/src/observability/telescope/extension.d.ts +29 -0
- package/build/src/observability/telescope/extension.js +167 -0
- package/build/src/observability/telescope/index.d.ts +8 -0
- package/build/src/observability/telescope/index.js +8 -0
- package/build/src/observability/wire_provider_events.d.ts +12 -0
- package/build/src/observability/wire_provider_events.js +30 -0
- package/build/src/password/common_passwords.d.ts +31 -0
- package/build/src/password/common_passwords.js +73 -0
- package/build/src/password/password_manager.d.ts +163 -0
- package/build/src/password/password_manager.js +191 -0
- package/build/src/password/policy.d.ts +71 -0
- package/build/src/password/policy.js +55 -0
- package/build/src/password/pwned.d.ts +36 -0
- package/build/src/password/pwned.js +52 -0
- package/build/src/pat/lucid_pat_store.d.ts +6 -0
- package/build/src/pat/lucid_pat_store.js +62 -0
- package/build/src/pat/pat_store.d.ts +31 -0
- package/build/src/pat/pat_store.js +1 -0
- package/build/src/pat/pat_tokens.d.ts +4 -0
- package/build/src/pat/pat_tokens.js +9 -0
- package/build/src/provider/build_provider.d.ts +45 -0
- package/build/src/provider/build_provider.js +219 -0
- package/build/src/provider/device_sources.d.ts +6 -0
- package/build/src/provider/device_sources.js +65 -0
- package/build/src/provider/interaction_actions.d.ts +36 -0
- package/build/src/provider/interaction_actions.js +55 -0
- package/build/src/provider/key_rotation_scheduler.d.ts +28 -0
- package/build/src/provider/key_rotation_scheduler.js +40 -0
- package/build/src/provider/keystore_reload.d.ts +21 -0
- package/build/src/provider/keystore_reload.js +39 -0
- package/build/src/provider/logout_sources.d.ts +13 -0
- package/build/src/provider/logout_sources.js +64 -0
- package/build/src/provider/oidc_service.d.ts +81 -0
- package/build/src/provider/oidc_service.js +254 -0
- package/build/src/provider/single_flight_lock.d.ts +18 -0
- package/build/src/provider/single_flight_lock.js +31 -0
- package/build/src/provider/token_exchange.d.ts +21 -0
- package/build/src/provider/token_exchange.js +124 -0
- package/build/src/register_routes.d.ts +16 -0
- package/build/src/register_routes.js +21 -0
- package/build/src/schema/ensure.d.ts +41 -0
- package/build/src/schema/ensure.js +262 -0
- package/build/stubs/config/authkit.stub +20 -0
- package/build/stubs/config/authkit_react.stub +52 -0
- package/build/stubs/main.d.ts +1 -0
- package/build/stubs/main.js +2 -0
- package/build/stubs/models/auth_user.stub +22 -0
- package/build/stubs/ui/edge/views/consent.edge +13 -0
- package/build/stubs/ui/edge/views/login.edge +19 -0
- package/build/stubs/ui/react/components/auth_shell.tsx +67 -0
- package/build/stubs/ui/react/pages/account/login.tsx +56 -0
- package/build/stubs/ui/react/pages/account/mfa.tsx +132 -0
- package/build/stubs/ui/react/pages/account/tokens.tsx +88 -0
- package/build/stubs/ui/react/pages/consent.tsx +39 -0
- package/build/stubs/ui/react/pages/forgot.tsx +44 -0
- package/build/stubs/ui/react/pages/login.tsx +171 -0
- package/build/stubs/ui/react/pages/mfa-challenge.tsx +72 -0
- package/build/stubs/ui/react/pages/reset.tsx +58 -0
- package/build/stubs/ui/react/pages/signup.tsx +78 -0
- package/build/stubs/ui/react/pages/verify-email.tsx +24 -0
- package/build/types.d.ts +7 -0
- package/build/types.js +1 -0
- package/package.json +147 -0
- package/stubs/config/authkit.stub +20 -0
- package/stubs/config/authkit_react.stub +52 -0
- package/stubs/main.ts +2 -0
- package/stubs/models/auth_user.stub +22 -0
- package/stubs/ui/edge/views/consent.edge +13 -0
- package/stubs/ui/edge/views/login.edge +19 -0
- package/stubs/ui/react/components/auth_shell.tsx +67 -0
- package/stubs/ui/react/pages/account/login.tsx +56 -0
- package/stubs/ui/react/pages/account/mfa.tsx +132 -0
- package/stubs/ui/react/pages/account/tokens.tsx +88 -0
- package/stubs/ui/react/pages/consent.tsx +39 -0
- package/stubs/ui/react/pages/forgot.tsx +44 -0
- package/stubs/ui/react/pages/login.tsx +171 -0
- package/stubs/ui/react/pages/mfa-challenge.tsx +72 -0
- package/stubs/ui/react/pages/reset.tsx +58 -0
- package/stubs/ui/react/pages/signup.tsx +78 -0
- package/stubs/ui/react/pages/verify-email.tsx +24 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ApplicationService } from '@adonisjs/core/types';
|
|
2
|
+
import type { MetricsRecorder } from '@adonis-agora/authkit-core';
|
|
3
|
+
import { OidcService } from '../src/provider/oidc_service.js';
|
|
4
|
+
import type { AccountStore } from '../src/accounts/account_store.js';
|
|
5
|
+
import type { PatStore } from '../src/pat/pat_store.js';
|
|
6
|
+
declare module '@adonisjs/core/types' {
|
|
7
|
+
interface ContainerBindings {
|
|
8
|
+
'authkit.server': OidcService;
|
|
9
|
+
'authkit.metrics': MetricsRecorder;
|
|
10
|
+
'authkit.accountStore': AccountStore;
|
|
11
|
+
'authkit.patStore': PatStore;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default class AuthkitServerProvider {
|
|
15
|
+
#private;
|
|
16
|
+
protected app: ApplicationService;
|
|
17
|
+
constructor(app: ApplicationService);
|
|
18
|
+
boot(): Promise<void>;
|
|
19
|
+
register(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Gestão automática de schema: com `schema.autoManage` (default), garante
|
|
22
|
+
* as tabelas do authkit no start — cria as que faltam e adiciona colunas
|
|
23
|
+
* novas (aditivo). Falha de DB aqui não derruba o boot: loga warning e as
|
|
24
|
+
* features degradam como sempre degradaram (capability probing).
|
|
25
|
+
*/
|
|
26
|
+
start(): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { configProvider } from '@adonisjs/core';
|
|
4
|
+
import { RuntimeException } from '@adonisjs/core/exceptions';
|
|
5
|
+
import { OidcService } from '../src/provider/oidc_service.js';
|
|
6
|
+
import { KeystoreReloadPoller } from '../src/provider/keystore_reload.js';
|
|
7
|
+
import { KeyRotationScheduler } from '../src/provider/key_rotation_scheduler.js';
|
|
8
|
+
import { makeSingleFlightLock } from '../src/provider/single_flight_lock.js';
|
|
9
|
+
import { resolveEffectiveKeyRotation } from '../src/host/key_rotation.js';
|
|
10
|
+
import { RuntimeSettings } from '../src/host/runtime_settings.js';
|
|
11
|
+
import { defaultEncryptForStore } from '../src/define_config.js';
|
|
12
|
+
import { resolveKeystoreVault, KeystoreManager } from '../src/keys/keystore_manager.js';
|
|
13
|
+
import { KeystoreCodec } from '../src/keys/keystore_codec.js';
|
|
14
|
+
import { loadEncryptionService } from '../src/keys/keystore_crypto.js';
|
|
15
|
+
export default class AuthkitServerProvider {
|
|
16
|
+
app;
|
|
17
|
+
constructor(app) {
|
|
18
|
+
this.app = app;
|
|
19
|
+
}
|
|
20
|
+
async boot() {
|
|
21
|
+
// Config locks: trava as settings definidas explicitamente no defineConfig
|
|
22
|
+
// (config vence em runtime; a UI/Admin API não pode alterá-las). Fail-safe:
|
|
23
|
+
// qualquer erro → sem locks (comportamento legado).
|
|
24
|
+
try {
|
|
25
|
+
const value = this.app.config.get('authkit');
|
|
26
|
+
if (value) {
|
|
27
|
+
const config = (await configProvider.resolve(this.app, value));
|
|
28
|
+
if (config) {
|
|
29
|
+
if (config.lockedSettingKeys?.length) {
|
|
30
|
+
const { setLockedSettingKeys } = await import('../src/host/config_locks.js');
|
|
31
|
+
setLockedSettingKeys(config.lockedSettingKeys);
|
|
32
|
+
}
|
|
33
|
+
// Stash dos bits de routing p/ o registerAuthHost ler do config (dedup).
|
|
34
|
+
// boot() roda antes do preload start/routes.ts, então estará disponível lá.
|
|
35
|
+
const { setAuthHostConfig } = await import('../src/host/auth_host_config.js');
|
|
36
|
+
setAuthHostConfig({
|
|
37
|
+
mountPath: config.mountPath,
|
|
38
|
+
social: config.social,
|
|
39
|
+
rateLimit: config.rateLimit,
|
|
40
|
+
adminEnabled: config.admin.enabled,
|
|
41
|
+
adminApiEnabled: config.adminApi.enabled,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
/* sem locks / sem stash → registerAuthHost cai em opts/defaults */
|
|
48
|
+
}
|
|
49
|
+
// Registra o disco "authkit" no edge.js para que os templates sejam referenciados
|
|
50
|
+
// como `authkit::login`, `authkit::account/tokens`, etc.
|
|
51
|
+
// Resolve o diretório das views tanto em produção (provider compilado em
|
|
52
|
+
// `build/providers/`, views copiadas para `build/host/views`) quanto em dev
|
|
53
|
+
// (rodando de `providers/` via ts-exec; views em `build/host/views` após build
|
|
54
|
+
// ou em `src/host/views` sem build).
|
|
55
|
+
const candidates = [
|
|
56
|
+
new URL('../host/views', import.meta.url), // prod: build/providers → build/host/views
|
|
57
|
+
new URL('../build/host/views', import.meta.url), // dev: providers → build/host/views
|
|
58
|
+
new URL('../src/host/views', import.meta.url), // dev sem build: providers → src/host/views
|
|
59
|
+
];
|
|
60
|
+
const viewsUrl = candidates.find((u) => existsSync(fileURLToPath(u)));
|
|
61
|
+
if (!viewsUrl)
|
|
62
|
+
return; // nenhum dir de views resolvível
|
|
63
|
+
try {
|
|
64
|
+
const edge = await import('edge.js');
|
|
65
|
+
const edgeInstance = edge.default ?? edge;
|
|
66
|
+
edgeInstance.mount('authkit', viewsUrl);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// edge.js ausente (host headless/Inertia-only que não usa edgeRenderer) — ignora.
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
register() {
|
|
73
|
+
this.app.container.singleton('authkit.server', async () => {
|
|
74
|
+
const configProviderValue = this.app.config.get('authkit');
|
|
75
|
+
const config = (await configProvider.resolve(this.app, configProviderValue));
|
|
76
|
+
if (!config) {
|
|
77
|
+
throw new RuntimeException('Config inválido em "config/authkit.ts". Use o método defineConfig de @adonis-agora/authkit-server.');
|
|
78
|
+
}
|
|
79
|
+
// `app.appKey` pode ser uma string crua ou um `Secret` do AdonisJS (config/app.ts
|
|
80
|
+
// expõe `export const appKey = new Secret(env.get('APP_KEY'))`). O oidc-provider
|
|
81
|
+
// assina cookies via keygrip e exige uma string — então liberamos o Secret aqui.
|
|
82
|
+
// Sem isso, a chave chegaria como objeto/undefined e o fluxo de authorize quebraria
|
|
83
|
+
// (keygrip: "key argument must be of type string ...").
|
|
84
|
+
const rawAppKey = this.app.config.get('app.appKey');
|
|
85
|
+
const appKey = rawAppKey && typeof rawAppKey.release === 'function'
|
|
86
|
+
? rawAppKey.release()
|
|
87
|
+
: rawAppKey;
|
|
88
|
+
if (!appKey || typeof appKey !== 'string') {
|
|
89
|
+
throw new RuntimeException('APP_KEY ausente: defina `export const appKey = new Secret(env.get(\'APP_KEY\'))` em config/app.ts. ' +
|
|
90
|
+
'O @adonis-agora/authkit-server precisa dele para assinar os cookies do oidc-provider.');
|
|
91
|
+
}
|
|
92
|
+
const metrics = await this.app.container.make('authkit.metrics');
|
|
93
|
+
const jwksInput = config.jwksConfig;
|
|
94
|
+
let jwksLoader;
|
|
95
|
+
let keystoreHead;
|
|
96
|
+
let keystoreManager;
|
|
97
|
+
if (jwksInput?.source === 'managed' && jwksInput?.store) {
|
|
98
|
+
const appRef = this.app;
|
|
99
|
+
const buildManager = async () => {
|
|
100
|
+
const vault = resolveKeystoreVault(jwksInput.store, { makePath: (p) => appRef.makePath(p), container: appRef.container });
|
|
101
|
+
const encrypt = jwksInput.encrypt ?? defaultEncryptForStore(jwksInput.store);
|
|
102
|
+
// best-effort (≠ boot, que lança): se a encryption sumir em runtime, o reload
|
|
103
|
+
// degrada para "sem hot-reload" (o onError do poller engole) em vez de derrubar o processo.
|
|
104
|
+
const enc = encrypt ? await loadEncryptionService().catch(() => undefined) : undefined;
|
|
105
|
+
return new KeystoreManager(vault, new KeystoreCodec({ encrypt, enc }), jwksInput.algorithm ?? 'RS256');
|
|
106
|
+
};
|
|
107
|
+
jwksLoader = async () => {
|
|
108
|
+
const m = await buildManager();
|
|
109
|
+
const store = (await m.read()) ?? (await m.ensure());
|
|
110
|
+
return { keys: store.keys.map(({ iat: _iat, ...jwk }) => jwk) };
|
|
111
|
+
};
|
|
112
|
+
keystoreHead = async () => {
|
|
113
|
+
const m = await buildManager();
|
|
114
|
+
return m.head();
|
|
115
|
+
};
|
|
116
|
+
keystoreManager = async () => buildManager();
|
|
117
|
+
}
|
|
118
|
+
return new OidcService(config, appKey, metrics, { jwksLoader, keystoreHead, keystoreManager });
|
|
119
|
+
});
|
|
120
|
+
this.app.container.singleton('authkit.metrics', async () => {
|
|
121
|
+
const value = this.app.config.get('authkit');
|
|
122
|
+
const config = (await configProvider.resolve(this.app, value));
|
|
123
|
+
const { createMetricsRecorder } = await import('../src/observability/metrics_service.js');
|
|
124
|
+
return createMetricsRecorder(config?.observability ?? {}, 'authkit-server');
|
|
125
|
+
});
|
|
126
|
+
this.app.container.singleton('authkit.accountStore', async () => {
|
|
127
|
+
const value = this.app.config.get('authkit');
|
|
128
|
+
const config = (await configProvider.resolve(this.app, value));
|
|
129
|
+
if (!config?.accountStore) {
|
|
130
|
+
throw new RuntimeException('accountStore não configurado em "config/authkit.ts". Use defineConfig de @adonis-agora/authkit-server.');
|
|
131
|
+
}
|
|
132
|
+
return config.accountStore;
|
|
133
|
+
});
|
|
134
|
+
this.app.container.singleton('authkit.patStore', async () => {
|
|
135
|
+
const value = this.app.config.get('authkit');
|
|
136
|
+
const config = (await configProvider.resolve(this.app, value));
|
|
137
|
+
if (!config?.patStore) {
|
|
138
|
+
throw new RuntimeException('patStore não configurado em "config/authkit.ts" — necessário para fluxos de PAT.');
|
|
139
|
+
}
|
|
140
|
+
return config.patStore;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Gestão automática de schema: com `schema.autoManage` (default), garante
|
|
145
|
+
* as tabelas do authkit no start — cria as que faltam e adiciona colunas
|
|
146
|
+
* novas (aditivo). Falha de DB aqui não derruba o boot: loga warning e as
|
|
147
|
+
* features degradam como sempre degradaram (capability probing).
|
|
148
|
+
*/
|
|
149
|
+
async start() {
|
|
150
|
+
try {
|
|
151
|
+
const value = this.app.config.get('authkit');
|
|
152
|
+
if (!value)
|
|
153
|
+
return;
|
|
154
|
+
const config = (await configProvider.resolve(this.app, value));
|
|
155
|
+
if (!config?.schema?.autoManage)
|
|
156
|
+
return;
|
|
157
|
+
const db = await this.app.container.make('lucid.db').catch(() => null);
|
|
158
|
+
if (!db)
|
|
159
|
+
return; // host sem @adonisjs/lucid — nada a gerenciar
|
|
160
|
+
const { ensureAuthkitSchema } = await import('../src/schema/ensure.js');
|
|
161
|
+
const report = await ensureAuthkitSchema(db, { connection: config.schema.connection });
|
|
162
|
+
const logger = await this.app.container.make('logger').catch(() => null);
|
|
163
|
+
if (report.created.length > 0) {
|
|
164
|
+
logger?.info('authkit: created tables %s', report.created.join(', '));
|
|
165
|
+
}
|
|
166
|
+
for (const [table, columns] of Object.entries(report.altered)) {
|
|
167
|
+
logger?.info('authkit: added columns to %s: %s', table, columns.join(', '));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const logger = await this.app.container.make('logger').catch(() => null);
|
|
172
|
+
logger?.warn({ err: error }, 'authkit: schema auto-manage failed — features degrade gracefully; ' +
|
|
173
|
+
'run ensureAuthkitSchema() in a migration or fix DB connectivity');
|
|
174
|
+
}
|
|
175
|
+
await this.#startKeystoreReloadPoll();
|
|
176
|
+
await this.#startKeyRotationScheduler();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Inicia o poll de reload do keystore: a cada intervalo lê um `head` barato do
|
|
180
|
+
* cofre e dispara `reloadKeys()` quando ele muda, propagando rotações feitas
|
|
181
|
+
* por outro processo (`authkit:keys:rotate`) ou instância sem restart. Só roda
|
|
182
|
+
* no ambiente `web` (evita pollers em comandos ace/testes) e só quando o
|
|
183
|
+
* OidcService de fato tem um `keystoreHead` (managed + store). Fail-safe:
|
|
184
|
+
* qualquer erro vira no-op (logado como warning); `unref()` impede o timer de
|
|
185
|
+
* manter o processo vivo.
|
|
186
|
+
*/
|
|
187
|
+
async #startKeystoreReloadPoll() {
|
|
188
|
+
if (this.app.getEnvironment() !== 'web')
|
|
189
|
+
return;
|
|
190
|
+
const svc = await this.app.container.make('authkit.server').catch(() => null);
|
|
191
|
+
const headFn = svc?.keystoreHead;
|
|
192
|
+
if (!svc || !headFn)
|
|
193
|
+
return;
|
|
194
|
+
const logger = await this.app.container.make('logger').catch(() => null);
|
|
195
|
+
const poller = new KeystoreReloadPoller({
|
|
196
|
+
head: () => headFn(),
|
|
197
|
+
reload: () => svc.reloadKeys(),
|
|
198
|
+
intervalMs: 60_000,
|
|
199
|
+
onError: (err) => logger?.warn({ err }, 'authkit: keystore reload poll falhou (fail-safe)'),
|
|
200
|
+
});
|
|
201
|
+
poller.start();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Inicia o scheduler de rotação age-based (housekeeping). Só no ambiente `web` e
|
|
205
|
+
* só quando o OidcService tem keystore gerenciável (rotateKeys disponível). Lê a
|
|
206
|
+
* política via RuntimeSettings (construída a partir do lucid.db, sem request);
|
|
207
|
+
* single-flight via @adonisjs/lock (opt-in). Fail-safe.
|
|
208
|
+
*/
|
|
209
|
+
async #startKeyRotationScheduler() {
|
|
210
|
+
if (this.app.getEnvironment() !== 'web')
|
|
211
|
+
return;
|
|
212
|
+
const svc = await this.app.container.make('authkit.server').catch(() => null);
|
|
213
|
+
if (!svc || typeof svc.rotateKeys !== 'function' || typeof svc.keystoreAgeDays !== 'function')
|
|
214
|
+
return;
|
|
215
|
+
// só faz sentido com keystore gerenciável:
|
|
216
|
+
if ((await svc.keystoreAgeDays().catch(() => null)) === null)
|
|
217
|
+
return;
|
|
218
|
+
const db = await this.app.container.make('lucid.db').catch(() => null);
|
|
219
|
+
if (!db)
|
|
220
|
+
return; // sem Lucid → sem settings → política seria defaults(disabled); nada a agendar
|
|
221
|
+
const logger = await this.app.container.make('logger').catch(() => null);
|
|
222
|
+
// Resolve a connection do schema config para que RuntimeSettings use a mesma
|
|
223
|
+
// conexão que o resto do authkit (mesmo padrão do expire_scan_command).
|
|
224
|
+
const value = this.app.config.get('authkit');
|
|
225
|
+
const config = value
|
|
226
|
+
? (await configProvider.resolve(this.app, value).catch(() => null))
|
|
227
|
+
: null;
|
|
228
|
+
const connection = config?.schema?.connection;
|
|
229
|
+
// RuntimeSettings sem request (mesmo padrão de expire_scan_command / security_notice_service).
|
|
230
|
+
const settings = new RuntimeSettings(db, connection ? { connection } : {});
|
|
231
|
+
const withLock = makeSingleFlightLock({ key: 'authkit:keys:rotate', ttlMs: 5 * 60_000 });
|
|
232
|
+
const scheduler = new KeyRotationScheduler({
|
|
233
|
+
policy: () => resolveEffectiveKeyRotation(settings),
|
|
234
|
+
ageDays: () => svc.keystoreAgeDays(),
|
|
235
|
+
rotateKeys: (keep) => svc.rotateKeys(keep),
|
|
236
|
+
withLock,
|
|
237
|
+
intervalMs: 60 * 60_000, // 1h
|
|
238
|
+
onError: (err) => logger?.warn({ err }, 'authkit: key rotation scheduler falhou (fail-safe)'),
|
|
239
|
+
});
|
|
240
|
+
scheduler.start();
|
|
241
|
+
}
|
|
242
|
+
}
|