command_tower 0.4.0 → 0.11.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.
- checksums.yaml +4 -4
- data/README.md +106 -29
- data/app/auth/command_tower/auth/auth_context.rb +42 -0
- data/app/auth/command_tower/auth/password_recovery_session_context.rb +11 -0
- data/app/auth/command_tower/auth/signup_session_context.rb +11 -0
- data/app/controllers/command_tower/admin/application_controller.rb +27 -0
- data/app/controllers/command_tower/admin/audit/events_controller.rb +61 -0
- data/app/controllers/command_tower/admin/messaging/announcements_controller.rb +27 -0
- data/app/controllers/command_tower/admin/users/identities_controller.rb +77 -0
- data/app/controllers/command_tower/admin/users/impersonation_sessions_controller.rb +33 -0
- data/app/controllers/command_tower/admin/users/roles_controller.rb +40 -0
- data/app/controllers/command_tower/admin/users_controller.rb +46 -0
- data/app/controllers/command_tower/admin/workspace_controller.rb +15 -0
- data/app/controllers/command_tower/application_controller.rb +97 -15
- data/app/controllers/command_tower/auth/email/availability_controller.rb +35 -0
- data/app/controllers/command_tower/auth/email_verification/send_controller.rb +24 -0
- data/app/controllers/command_tower/auth/email_verification/verify_controller.rb +41 -0
- data/app/controllers/command_tower/auth/identity_policy_controller.rb +14 -0
- data/app/controllers/command_tower/auth/impersonation_session_controller.rb +27 -0
- data/app/controllers/command_tower/auth/logout_controller.rb +16 -0
- data/app/controllers/command_tower/auth/password_recovery_session/create_controller.rb +17 -0
- data/app/controllers/command_tower/auth/password_reset/reset_controller.rb +35 -0
- data/app/controllers/command_tower/auth/password_reset/send_controller.rb +40 -0
- data/app/controllers/command_tower/auth/password_reset/validate_controller.rb +35 -0
- data/app/controllers/command_tower/auth/plain_text/login_controller.rb +22 -0
- data/app/controllers/command_tower/auth/principal_capabilities_controller.rb +19 -0
- data/app/controllers/command_tower/auth/register_controller.rb +33 -0
- data/app/controllers/command_tower/auth/session_controller.rb +21 -0
- data/app/controllers/command_tower/auth/signup_session/create_controller.rb +17 -0
- data/app/controllers/command_tower/auth/username/availability_controller.rb +35 -0
- data/app/controllers/command_tower/me/audit_events_controller.rb +59 -0
- data/app/controllers/command_tower/me/inbox_controller.rb +85 -0
- data/app/controllers/command_tower/me/name_controller.rb +37 -0
- data/app/controllers/command_tower/me/password_controller.rb +37 -0
- data/app/controllers/command_tower/me/phone_controller.rb +44 -0
- data/app/controllers/command_tower/me/phone_verification/verifications_controller.rb +23 -0
- data/app/controllers/command_tower/me/phone_verification/verify_controller.rb +34 -0
- data/app/controllers/command_tower/me/preferences_controller.rb +46 -0
- data/app/controllers/command_tower/me/pushover/verifications_controller.rb +23 -0
- data/app/controllers/command_tower/me/pushover_controller.rb +66 -0
- data/app/controllers/command_tower/me_controller.rb +19 -0
- data/app/controllers/command_tower/profile_controller.rb +19 -0
- data/app/controllers/concerns/command_tower/api/application_response_renderer.rb +87 -0
- data/app/controllers/concerns/command_tower/api/deserializer_failure_details.rb +22 -0
- data/app/controllers/concerns/command_tower/auth/authentication_boundary.rb +35 -0
- data/app/controllers/concerns/command_tower/auth/authorization_boundary.rb +26 -0
- data/app/controllers/concerns/command_tower/auth/invalid_credentials_deserializer_renderer.rb +23 -0
- data/app/controllers/concerns/command_tower/auth/password_recovery_session_boundary.rb +29 -0
- data/app/controllers/concerns/command_tower/auth/signup_session_boundary.rb +29 -0
- data/app/controllers/concerns/command_tower/execution/http_boundary.rb +65 -0
- data/app/deserializers/command_tower/deserializers/admin/messaging/create_announcement_deserializer.rb +106 -0
- data/app/deserializers/command_tower/deserializers/admin/scope_parameter.rb +49 -0
- data/app/deserializers/command_tower/deserializers/admin/users.rb +218 -0
- data/app/deserializers/command_tower/deserializers/application_deserializer.rb +148 -0
- data/app/deserializers/command_tower/deserializers/audit/events.rb +224 -0
- data/app/deserializers/command_tower/deserializers/auth/email_availability_deserializer.rb +19 -0
- data/app/deserializers/command_tower/deserializers/auth/email_verification/verify_deserializer.rb +21 -0
- data/app/deserializers/command_tower/deserializers/auth/password_reset/reset_deserializer.rb +31 -0
- data/app/deserializers/command_tower/deserializers/auth/password_reset/send_deserializer.rb +21 -0
- data/app/deserializers/command_tower/deserializers/auth/password_reset/validate_deserializer.rb +23 -0
- data/app/deserializers/command_tower/deserializers/auth/plain_text/login_deserializer.rb +24 -0
- data/app/deserializers/command_tower/deserializers/auth/register_deserializer.rb +42 -0
- data/app/deserializers/command_tower/deserializers/auth/username_availability_deserializer.rb +19 -0
- data/app/deserializers/command_tower/deserializers/clients/errors.rb +45 -0
- data/app/deserializers/command_tower/deserializers/clients/missing.rb +10 -0
- data/app/deserializers/command_tower/deserializers/clients/payload.rb +21 -0
- data/app/deserializers/command_tower/deserializers/clients/result.rb +122 -0
- data/app/deserializers/command_tower/deserializers/clients/types.rb +219 -0
- data/app/deserializers/command_tower/deserializers/coercion_result.rb +35 -0
- data/app/deserializers/command_tower/deserializers/failure.rb +14 -0
- data/app/deserializers/command_tower/deserializers/me/change_password_deserializer.rb +41 -0
- data/app/deserializers/command_tower/deserializers/me/phone_verification/verify_deserializer.rb +29 -0
- data/app/deserializers/command_tower/deserializers/me/pushover/credentials_deserializer.rb +31 -0
- data/app/deserializers/command_tower/deserializers/me/update_name_deserializer.rb +22 -0
- data/app/deserializers/command_tower/deserializers/me/update_phone_deserializer.rb +22 -0
- data/app/deserializers/command_tower/deserializers/messaging/inbox.rb +77 -0
- data/app/deserializers/command_tower/deserializers/messaging/preferences/show_deserializer.rb +17 -0
- data/app/deserializers/command_tower/deserializers/messaging/preferences/update_deserializer.rb +97 -0
- data/app/errors/command_tower/errors/account/phone_already_verified_error.rb +17 -0
- data/app/errors/command_tower/errors/account/phone_missing_error.rb +17 -0
- data/app/errors/command_tower/errors/account/phone_verification_code_invalid_error.rb +17 -0
- data/app/errors/command_tower/errors/account/phone_verification_expired_error.rb +17 -0
- data/app/errors/command_tower/errors/account/phone_verification_send_failed_error.rb +25 -0
- data/app/errors/command_tower/errors/account/phone_verification_stale_error.rb +17 -0
- data/app/errors/command_tower/errors/account/phone_verification_throttled_error.rb +24 -0
- data/app/errors/command_tower/errors/account/pushover_already_configured_error.rb +21 -0
- data/app/errors/command_tower/errors/account/pushover_capability_unavailable_error.rb +21 -0
- data/app/errors/command_tower/errors/account/pushover_not_configured_error.rb +21 -0
- data/app/errors/command_tower/errors/account/pushover_provider_unavailable_error.rb +21 -0
- data/app/errors/command_tower/errors/account/pushover_verification_failed_error.rb +27 -0
- data/app/errors/command_tower/errors/account/sms_capability_unavailable_error.rb +21 -0
- data/app/errors/command_tower/errors/application_error.rb +27 -0
- data/app/errors/command_tower/errors/auth/admin_unavailable_during_impersonation_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/csrf_mismatch_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/csrf_missing_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/default_membership_assignment_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/email_already_registered_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/email_verification_required_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/impersonation_session_expired_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/impersonation_session_missing_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/invalid_credentials_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/nested_impersonation_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/password_recovery_ip_rate_limit_error.rb +25 -0
- data/app/errors/command_tower/errors/auth/password_recovery_session_expired_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/password_recovery_session_invalid_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/password_recovery_session_missing_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/password_recovery_session_rate_limit_error.rb +25 -0
- data/app/errors/command_tower/errors/auth/password_reset_invalid_token_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/password_reset_unavailable_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/self_impersonation_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/signup_ip_rate_limit_error.rb +25 -0
- data/app/errors/command_tower/errors/auth/signup_session_expired_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/signup_session_invalid_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/signup_session_missing_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/signup_session_rate_limit_error.rb +25 -0
- data/app/errors/command_tower/errors/auth/verification_code_invalid_error.rb +17 -0
- data/app/errors/command_tower/errors/auth/verification_send_failed_error.rb +25 -0
- data/app/errors/command_tower/errors/continuation_exhausted_error.rb +25 -0
- data/app/errors/command_tower/errors/forbidden_error.rb +19 -0
- data/app/errors/command_tower/errors/internal_error.rb +19 -0
- data/app/errors/command_tower/errors/messaging/accept_rejected_error.rb +21 -0
- data/app/errors/command_tower/errors/messaging/idempotency_conflict_error.rb +21 -0
- data/app/errors/command_tower/errors/messaging/recipient_unresolved_error.rb +21 -0
- data/app/errors/command_tower/errors/not_found_error.rb +19 -0
- data/app/errors/command_tower/errors/unauthorized_error.rb +19 -0
- data/app/errors/command_tower/errors/validation_error.rb +15 -0
- data/app/jobs/command_tower/application_job.rb +7 -0
- data/app/jobs/command_tower/execution/job_boundary.rb +19 -0
- data/app/jobs/command_tower/messaging/channel_delivery_execution_job.rb +18 -0
- data/app/jobs/command_tower/messaging/communications/produce_recipient_job.rb +24 -0
- data/app/jobs/command_tower/messaging/execution_recovery_job.rb +13 -0
- data/app/jobs/command_tower/messaging/handoff_job.rb +15 -0
- data/app/jobs/command_tower/messaging/handoff_recovery_job.rb +13 -0
- data/app/mailers/command_tower/application_mailer.rb +11 -1
- data/app/mailers/command_tower/email_verification_mailer.rb +5 -3
- data/app/mailers/command_tower/messaging/channel_mailer.rb +24 -0
- data/app/mailers/command_tower/password_reset_mailer.rb +18 -0
- data/app/models/command_tower/audit/event.rb +36 -0
- data/app/models/command_tower/impersonation/session.rb +51 -0
- data/app/models/command_tower/messaging/channel_delivery.rb +45 -0
- data/app/models/command_tower/messaging/communication.rb +60 -0
- data/app/models/command_tower/messaging/delivery_attempt.rb +28 -0
- data/app/models/command_tower/messaging/destination_plan.rb +17 -0
- data/app/models/command_tower/messaging/endpoint.rb +98 -0
- data/app/models/command_tower/messaging/endpoint_pushover_credential.rb +18 -0
- data/app/models/command_tower/messaging/inbox_item.rb +52 -0
- data/app/models/command_tower/messaging/notification_preference.rb +21 -0
- data/app/models/user.rb +4 -1
- data/app/serializers/command_tower/serializers/admin/messaging/announcement_response_serializer.rb +41 -0
- data/app/serializers/command_tower/serializers/admin/users.rb +69 -0
- data/app/serializers/command_tower/serializers/admin/workspace/manifest_serializer.rb +58 -0
- data/app/serializers/command_tower/serializers/application/envelope_serializer.rb +25 -0
- data/app/serializers/command_tower/serializers/application/error_entry_serializer.rb +18 -0
- data/app/serializers/command_tower/serializers/application_serializer.rb +26 -0
- data/app/serializers/command_tower/serializers/audit/events/filter_options_serializer.rb +44 -0
- data/app/serializers/command_tower/serializers/audit/events.rb +42 -0
- data/app/serializers/command_tower/serializers/auth/email_availability_serializer.rb +17 -0
- data/app/serializers/command_tower/serializers/auth/email_verification/message_response_serializer.rb +15 -0
- data/app/serializers/command_tower/serializers/auth/identity_policy_serializer.rb +36 -0
- data/app/serializers/command_tower/serializers/auth/login_response_serializer.rb +17 -0
- data/app/serializers/command_tower/serializers/auth/logout_response_serializer.rb +13 -0
- data/app/serializers/command_tower/serializers/auth/password_recovery_session_response_serializer.rb +16 -0
- data/app/serializers/command_tower/serializers/auth/password_reset/message_response_serializer.rb +15 -0
- data/app/serializers/command_tower/serializers/auth/password_reset/validate_response_serializer.rb +22 -0
- data/app/serializers/command_tower/serializers/auth/principal_capabilities_serializer.rb +15 -0
- data/app/serializers/command_tower/serializers/auth/register_response_serializer.rb +16 -0
- data/app/serializers/command_tower/serializers/auth/session_response_serializer.rb +40 -0
- data/app/serializers/command_tower/serializers/auth/signup_session_response_serializer.rb +16 -0
- data/app/serializers/command_tower/serializers/auth/user_serializer.rb +21 -0
- data/app/serializers/command_tower/serializers/auth/username_availability_serializer.rb +17 -0
- data/app/serializers/command_tower/serializers/impersonation/session_serializer.rb +19 -0
- data/app/serializers/command_tower/serializers/me/account_serializer.rb +45 -0
- data/app/serializers/command_tower/serializers/me/change_password_response_serializer.rb +13 -0
- data/app/serializers/command_tower/serializers/me/pushover_serializer.rb +59 -0
- data/app/serializers/command_tower/serializers/messaging/inbox.rb +45 -0
- data/app/serializers/command_tower/serializers/messaging/preferences/catalog_serializer.rb +17 -0
- data/app/serializers/command_tower/serializers/messaging/preferences/category_serializer.rb +23 -0
- data/app/serializers/command_tower/serializers/messaging/preferences/notification_serializer.rb +30 -0
- data/app/serializers/command_tower/serializers/profile/profile_serializer.rb +13 -0
- data/app/services/command_tower/README.md +24 -14
- data/app/services/command_tower/auth/request_context.rb +21 -0
- data/app/services/command_tower/authorize/validate.rb +58 -19
- data/app/services/command_tower/clients/client_base.rb +183 -0
- data/app/services/command_tower/clients/client_result.rb +45 -0
- data/app/services/command_tower/clients/const_resolution.rb +32 -0
- data/app/services/command_tower/clients/decoded_response.rb +16 -0
- data/app/services/command_tower/clients/endpoint_base.rb +242 -0
- data/app/services/command_tower/clients/endpoint_input.rb +18 -0
- data/app/services/command_tower/clients/errors/authentication_error.rb +26 -0
- data/app/services/command_tower/clients/errors/configuration_error.rb +10 -0
- data/app/services/command_tower/clients/errors/deserialization_error.rb +26 -0
- data/app/services/command_tower/clients/errors/discovery_error.rb +10 -0
- data/app/services/command_tower/clients/errors/upstream_error.rb +26 -0
- data/app/services/command_tower/clients/invocation.rb +61 -0
- data/app/services/command_tower/clients/namespace_proxy.rb +75 -0
- data/app/services/command_tower/clients/scoped_client.rb +88 -0
- data/app/services/command_tower/clients/serialized_request.rb +17 -0
- data/app/services/command_tower/clients/transport/error.rb +18 -0
- data/app/services/command_tower/clients/transport/faraday_adapter.rb +129 -0
- data/app/services/command_tower/clients/transport/faraday_config.rb +45 -0
- data/app/services/command_tower/clients/transport/request.rb +50 -0
- data/app/services/command_tower/clients/transport/response.rb +22 -0
- data/app/services/command_tower/clients/url.rb +56 -0
- data/app/services/command_tower/identity/phone/normalizer.rb +41 -0
- data/app/services/command_tower/identity/phone_verification/sms_configuration.rb +58 -0
- data/app/services/command_tower/identity/phone_verification/sms_transport/adapters/fake_adapter.rb +35 -0
- data/app/services/command_tower/identity/phone_verification/sms_transport/adapters/log_adapter.rb +34 -0
- data/app/services/command_tower/identity/phone_verification/sms_transport/adapters/twilio_adapter.rb +60 -0
- data/app/services/command_tower/identity/phone_verification/sms_transport.rb +42 -0
- data/app/services/command_tower/jwt/authenticate_user.rb +67 -34
- data/app/services/command_tower/jwt/authentication_outcome.rb +37 -0
- data/app/services/command_tower/jwt/decode.rb +27 -8
- data/app/services/command_tower/jwt/encode.rb +4 -6
- data/app/services/command_tower/jwt/login_create.rb +10 -8
- data/app/services/command_tower/login_strategy/plain_text/email_verification/required.rb +11 -9
- data/app/services/command_tower/messaging/accept/channel_delivery_result.rb +13 -0
- data/app/services/command_tower/messaging/accept/coordinator.rb +166 -0
- data/app/services/command_tower/messaging/accept/error.rb +9 -0
- data/app/services/command_tower/messaging/accept/excluded_destination.rb +24 -0
- data/app/services/command_tower/messaging/accept/handoff_scheduler.rb +40 -0
- data/app/services/command_tower/messaging/accept/idempotency_conflict_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/illegal_override_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/impossible_mandatory_plan_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/invalid_preference_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/invariant_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/operation_logger.rb +97 -0
- data/app/services/command_tower/messaging/accept/persistence_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/persister.rb +90 -0
- data/app/services/command_tower/messaging/accept/request_normalizer.rb +100 -0
- data/app/services/command_tower/messaging/accept/result.rb +99 -0
- data/app/services/command_tower/messaging/accept/unknown_type_error.rb +9 -0
- data/app/services/command_tower/messaging/accept/validation_error.rb +9 -0
- data/app/services/command_tower/messaging/channel_detectors.rb +52 -0
- data/app/services/command_tower/messaging/channels/definition.rb +24 -0
- data/app/services/command_tower/messaging/channels/error.rb +9 -0
- data/app/services/command_tower/messaging/channels/unknown_channel_error.rb +9 -0
- data/app/services/command_tower/messaging/channels.rb +85 -0
- data/app/services/command_tower/messaging/contract/communications.rb +29 -0
- data/app/services/command_tower/messaging/contract/error.rb +9 -0
- data/app/services/command_tower/messaging/contract/internal/finder.rb +43 -0
- data/app/services/command_tower/messaging/contract/invariant_error.rb +9 -0
- data/app/services/command_tower/messaging/contract/mappers/channel_delivery_mapper.rb +53 -0
- data/app/services/command_tower/messaging/contract/mappers/communication_mapper.rb +61 -0
- data/app/services/command_tower/messaging/contract/mappers/delivery_attempt_mapper.rb +27 -0
- data/app/services/command_tower/messaging/contract/mappers/destination_plan_mapper.rb +17 -0
- data/app/services/command_tower/messaging/contract/mappers/inbox_item_mapper.rb +17 -0
- data/app/services/command_tower/messaging/contract/not_found_error.rb +9 -0
- data/app/services/command_tower/messaging/contract/observability/correlation.rb +19 -0
- data/app/services/command_tower/messaging/contract/observability/operation_logger.rb +101 -0
- data/app/services/command_tower/messaging/contract/observability/publisher.rb +44 -0
- data/app/services/command_tower/messaging/contract/requests/find_communication.rb +21 -0
- data/app/services/command_tower/messaging/contract/results/channel_delivery_result.rb +25 -0
- data/app/services/command_tower/messaging/contract/results/communication_result.rb +22 -0
- data/app/services/command_tower/messaging/contract/results/delivery_attempt_result.rb +21 -0
- data/app/services/command_tower/messaging/contract/results/destination_plan_result.rb +11 -0
- data/app/services/command_tower/messaging/contract/results/inbox_item_result.rb +11 -0
- data/app/services/command_tower/messaging/contract/validation_error.rb +9 -0
- data/app/services/command_tower/messaging/delivery_retry_policy.rb +30 -0
- data/app/services/command_tower/messaging/endpoints/begin_verification.rb +13 -0
- data/app/services/command_tower/messaging/endpoints/channel_gate.rb +39 -0
- data/app/services/command_tower/messaging/endpoints/conflict_error.rb +9 -0
- data/app/services/command_tower/messaging/endpoints/create.rb +181 -0
- data/app/services/command_tower/messaging/endpoints/error.rb +9 -0
- data/app/services/command_tower/messaging/endpoints/fingerprinter.rb +50 -0
- data/app/services/command_tower/messaging/endpoints/invalid_transition_error.rb +9 -0
- data/app/services/command_tower/messaging/endpoints/lifecycle.rb +37 -0
- data/app/services/command_tower/messaging/endpoints/mark_invalid.rb +32 -0
- data/app/services/command_tower/messaging/endpoints/mark_verification_failed.rb +13 -0
- data/app/services/command_tower/messaging/endpoints/mark_verified.rb +13 -0
- data/app/services/command_tower/messaging/endpoints/not_found_error.rb +9 -0
- data/app/services/command_tower/messaging/endpoints/persistence.rb +91 -0
- data/app/services/command_tower/messaging/endpoints/pushover/verify.rb +101 -0
- data/app/services/command_tower/messaging/endpoints/query.rb +28 -0
- data/app/services/command_tower/messaging/endpoints/replace.rb +181 -0
- data/app/services/command_tower/messaging/endpoints/reset_verification.rb +13 -0
- data/app/services/command_tower/messaging/endpoints/revoke.rb +40 -0
- data/app/services/command_tower/messaging/endpoints/safe_view.rb +50 -0
- data/app/services/command_tower/messaging/endpoints/secret_box.rb +86 -0
- data/app/services/command_tower/messaging/endpoints/secret_reader.rb +72 -0
- data/app/services/command_tower/messaging/endpoints/validation_error.rb +9 -0
- data/app/services/command_tower/messaging/endpoints/validators/push.rb +24 -0
- data/app/services/command_tower/messaging/endpoints/validators/pushover.rb +68 -0
- data/app/services/command_tower/messaging/endpoints/validators.rb +36 -0
- data/app/services/command_tower/messaging/endpoints/verification.rb +39 -0
- data/app/services/command_tower/messaging/endpoints/verification_failed_error.rb +18 -0
- data/app/services/command_tower/messaging/endpoints/verification_transition.rb +20 -0
- data/app/services/command_tower/messaging/endpoints.rb +55 -0
- data/app/services/command_tower/messaging/execution/adapter_request.rb +45 -0
- data/app/services/command_tower/messaging/execution/adapter_result.rb +81 -0
- data/app/services/command_tower/messaging/execution/adapters/email/adapter.rb +78 -0
- data/app/services/command_tower/messaging/execution/adapters/email/configuration.rb +55 -0
- data/app/services/command_tower/messaging/execution/adapters/fake_adapter.rb +34 -0
- data/app/services/command_tower/messaging/execution/adapters/pushover/adapter.rb +107 -0
- data/app/services/command_tower/messaging/execution/adapters/pushover/configuration.rb +30 -0
- data/app/services/command_tower/messaging/execution/adapters/sms/adapter.rb +90 -0
- data/app/services/command_tower/messaging/execution/adapters/sms/configuration.rb +58 -0
- data/app/services/command_tower/messaging/execution/adapters/sms/log_adapter.rb +34 -0
- data/app/services/command_tower/messaging/execution/adapters/sms/twilio_http_client.rb +70 -0
- data/app/services/command_tower/messaging/execution/adapters/unconfigured_adapter.rb +20 -0
- data/app/services/command_tower/messaging/execution/attempt_ledger.rb +146 -0
- data/app/services/command_tower/messaging/execution/claim.rb +35 -0
- data/app/services/command_tower/messaging/execution/invalid_adapter_contract_error.rb +9 -0
- data/app/services/command_tower/messaging/execution/operation_logger.rb +237 -0
- data/app/services/command_tower/messaging/execution/readiness_terminal_mapping.rb +37 -0
- data/app/services/command_tower/messaging/execution/recovery.rb +78 -0
- data/app/services/command_tower/messaging/execution/resolve_recipient_address.rb +58 -0
- data/app/services/command_tower/messaging/execution/revalidate_readiness.rb +73 -0
- data/app/services/command_tower/messaging/execution/scheduler.rb +38 -0
- data/app/services/command_tower/messaging/execution/select_adapter.rb +63 -0
- data/app/services/command_tower/messaging/handoff/advance_communication.rb +39 -0
- data/app/services/command_tower/messaging/handoff/operation_logger.rb +78 -0
- data/app/services/command_tower/messaging/handoff/recovery.rb +26 -0
- data/app/services/command_tower/messaging/inbox/bulk_result.rb +19 -0
- data/app/services/command_tower/messaging/inbox/error.rb +9 -0
- data/app/services/command_tower/messaging/inbox/invalid_bulk_items_error.rb +19 -0
- data/app/services/command_tower/messaging/inbox/invariant_error.rb +9 -0
- data/app/services/command_tower/messaging/inbox/item_result.rb +64 -0
- data/app/services/command_tower/messaging/inbox/list_result.rb +18 -0
- data/app/services/command_tower/messaging/inbox/mutator.rb +252 -0
- data/app/services/command_tower/messaging/inbox/not_found_error.rb +9 -0
- data/app/services/command_tower/messaging/inbox/operation_logger.rb +37 -0
- data/app/services/command_tower/messaging/inbox/reader.rb +117 -0
- data/app/services/command_tower/messaging/inbox/scope.rb +24 -0
- data/app/services/command_tower/messaging/inbox/unread_count_result.rb +16 -0
- data/app/services/command_tower/messaging/inbox/validation_error.rb +9 -0
- data/app/services/command_tower/messaging/inbox.rb +61 -0
- data/app/services/command_tower/messaging/notification_types/catalog_category.rb +19 -0
- data/app/services/command_tower/messaging/notification_types/declaration.rb +96 -0
- data/app/services/command_tower/messaging/notification_types/declaration_validator.rb +152 -0
- data/app/services/command_tower/messaging/notification_types/duplicate_type_error.rb +9 -0
- data/app/services/command_tower/messaging/notification_types/error.rb +9 -0
- data/app/services/command_tower/messaging/notification_types/invalid_declaration_error.rb +9 -0
- data/app/services/command_tower/messaging/notification_types/not_found_error.rb +9 -0
- data/app/services/command_tower/messaging/notification_types/registry.rb +103 -0
- data/app/services/command_tower/messaging/notification_types/sealed_registry_error.rb +9 -0
- data/app/services/command_tower/messaging/notification_types.rb +37 -0
- data/app/services/command_tower/messaging/planner/destination_plan.rb +41 -0
- data/app/services/command_tower/messaging/planner/error.rb +9 -0
- data/app/services/command_tower/messaging/planner/excluded_destination.rb +28 -0
- data/app/services/command_tower/messaging/planner/illegal_override_error.rb +9 -0
- data/app/services/command_tower/messaging/planner/impossible_mandatory_plan_error.rb +9 -0
- data/app/services/command_tower/messaging/planner/invalid_evaluation_error.rb +9 -0
- data/app/services/command_tower/messaging/planner/message_overrides.rb +33 -0
- data/app/services/command_tower/messaging/planner/operation_logger.rb +28 -0
- data/app/services/command_tower/messaging/planner/planner.rb +261 -0
- data/app/services/command_tower/messaging/planner/unknown_type_error.rb +9 -0
- data/app/services/command_tower/messaging/planner.rb +25 -0
- data/app/services/command_tower/messaging/preferences/catalog.rb +96 -0
- data/app/services/command_tower/messaging/preferences/catalog_category_result.rb +19 -0
- data/app/services/command_tower/messaging/preferences/catalog_notification_result.rb +55 -0
- data/app/services/command_tower/messaging/preferences/catalog_result.rb +13 -0
- data/app/services/command_tower/messaging/preferences/error.rb +9 -0
- data/app/services/command_tower/messaging/preferences/evaluation_result.rb +61 -0
- data/app/services/command_tower/messaging/preferences/evaluator.rb +194 -0
- data/app/services/command_tower/messaging/preferences/invalid_preference_state_error.rb +9 -0
- data/app/services/command_tower/messaging/preferences/invalid_preference_write_error.rb +10 -0
- data/app/services/command_tower/messaging/preferences/not_settings_visible_error.rb +10 -0
- data/app/services/command_tower/messaging/preferences/preference_state.rb +61 -0
- data/app/services/command_tower/messaging/preferences/reason_classes.rb +17 -0
- data/app/services/command_tower/messaging/preferences/resolve.rb +50 -0
- data/app/services/command_tower/messaging/preferences/store.rb +126 -0
- data/app/services/command_tower/messaging/preferences/store_error.rb +10 -0
- data/app/services/command_tower/messaging/preferences/suppressed_destination.rb +24 -0
- data/app/services/command_tower/messaging/preferences/unknown_type_error.rb +9 -0
- data/app/services/command_tower/messaging/preferences/update.rb +248 -0
- data/app/services/command_tower/messaging/preferences.rb +68 -0
- data/app/services/command_tower/messaging/pushover/adapters/disabled_adapter.rb +33 -0
- data/app/services/command_tower/messaging/pushover/adapters/fake_adapter.rb +90 -0
- data/app/services/command_tower/messaging/pushover/adapters/http_adapter.rb +145 -0
- data/app/services/command_tower/messaging/pushover/adapters/log_adapter.rb +52 -0
- data/app/services/command_tower/messaging/pushover/result.rb +34 -0
- data/app/services/command_tower/messaging/pushover/transport.rb +64 -0
- data/app/services/command_tower/messaging/recipient_readiness/channel_result.rb +55 -0
- data/app/services/command_tower/messaging/recipient_readiness/error.rb +9 -0
- data/app/services/command_tower/messaging/recipient_readiness/evaluate.rb +319 -0
- data/app/services/command_tower/messaging/recipient_readiness/identity_facts.rb +54 -0
- data/app/services/command_tower/messaging/recipient_readiness/reason_codes.rb +33 -0
- data/app/services/command_tower/messaging/recipient_readiness/recipient_not_found_error.rb +9 -0
- data/app/services/command_tower/messaging/recipient_readiness/recipient_result.rb +38 -0
- data/app/services/command_tower/messaging/recipient_readiness/unknown_channel_error.rb +9 -0
- data/app/services/command_tower/messaging/recipient_readiness.rb +26 -0
- data/app/services/command_tower/messaging/rendering/channel_renderer.rb +127 -0
- data/app/services/command_tower/messaging/rendering/render_error.rb +24 -0
- data/app/services/command_tower/messaging/rendering/rendered_payload.rb +44 -0
- data/app/services/command_tower/messaging/rendering/rendered_pushover_payload.rb +43 -0
- data/app/services/command_tower/messaging/rendering/rendered_sms_payload.rb +40 -0
- data/app/services/command_tower/messaging.rb +35 -0
- data/app/services/command_tower/secrets/cleanse.rb +19 -5
- data/app/services/command_tower/secrets/generate.rb +62 -27
- data/app/services/command_tower/secrets/verify.rb +46 -12
- data/app/services/command_tower/secrets.rb +2 -0
- data/app/services/command_tower/service_base.rb +30 -43
- data/app/services/command_tower/service_logging.rb +2 -36
- data/app/services/command_tower/services/account/clear_phone.rb +33 -0
- data/app/services/command_tower/services/account/phone_verification/send.rb +114 -0
- data/app/services/command_tower/services/account/phone_verification/verify.rb +89 -0
- data/app/services/command_tower/services/account/pushover/create.rb +28 -0
- data/app/services/command_tower/services/account/pushover/ct_support.rb +70 -0
- data/app/services/command_tower/services/account/pushover/destroy.rb +30 -0
- data/app/services/command_tower/services/account/pushover/replace.rb +28 -0
- data/app/services/command_tower/services/account/pushover/show.rb +19 -0
- data/app/services/command_tower/services/account/pushover/verify.rb +30 -0
- data/app/services/command_tower/services/account/update_phone.rb +58 -0
- data/app/services/command_tower/services/admin/users.rb +377 -0
- data/app/services/command_tower/services/admin/workspace/manifest.rb +49 -0
- data/app/services/command_tower/services/application_service.rb +58 -0
- data/app/services/command_tower/services/audit/events/filter_options.rb +75 -0
- data/app/services/command_tower/services/audit/events.rb +199 -0
- data/app/services/command_tower/services/auth/assign_default_membership_role.rb +44 -0
- data/app/services/command_tower/services/auth/authenticate_session.rb +132 -0
- data/app/services/command_tower/services/auth/authorize_request.rb +34 -0
- data/app/services/command_tower/services/auth/client_ip_resolver.rb +13 -0
- data/app/services/command_tower/services/auth/email_availability.rb +42 -0
- data/app/services/command_tower/services/auth/email_verification/send.rb +65 -0
- data/app/services/command_tower/services/auth/email_verification/verify.rb +53 -0
- data/app/services/command_tower/services/auth/identity_policy.rb +60 -0
- data/app/services/command_tower/services/auth/password_recovery/rate_limits/check_send.rb +48 -0
- data/app/services/command_tower/services/auth/password_recovery/rate_limits/check_token_issue.rb +35 -0
- data/app/services/command_tower/services/auth/password_recovery/rate_limits/enforcement.rb +53 -0
- data/app/services/command_tower/services/auth/password_recovery_session/create.rb +26 -0
- data/app/services/command_tower/services/auth/password_recovery_session/decode.rb +29 -0
- data/app/services/command_tower/services/auth/password_recovery_session/encode.rb +31 -0
- data/app/services/command_tower/services/auth/password_recovery_session/validate.rb +58 -0
- data/app/services/command_tower/services/auth/password_reset/reset.rb +75 -0
- data/app/services/command_tower/services/auth/password_reset/send.rb +77 -0
- data/app/services/command_tower/services/auth/password_reset/token_verification.rb +68 -0
- data/app/services/command_tower/services/auth/password_reset/validate.rb +29 -0
- data/app/services/command_tower/services/auth/plain_text/login.rb +52 -0
- data/app/services/command_tower/services/auth/principal_capabilities/project.rb +48 -0
- data/app/services/command_tower/services/auth/register.rb +77 -0
- data/app/services/command_tower/services/auth/signup_rate_limits/check_availability.rb +52 -0
- data/app/services/command_tower/services/auth/signup_rate_limits/check_register.rb +24 -0
- data/app/services/command_tower/services/auth/signup_rate_limits/check_token_issue.rb +33 -0
- data/app/services/command_tower/services/auth/signup_rate_limits/enforcement.rb +50 -0
- data/app/services/command_tower/services/auth/signup_session/create.rb +26 -0
- data/app/services/command_tower/services/auth/signup_session/decode.rb +29 -0
- data/app/services/command_tower/services/auth/signup_session/encode.rb +31 -0
- data/app/services/command_tower/services/auth/signup_session/validate.rb +58 -0
- data/app/services/command_tower/services/auth/username_availability.rb +28 -0
- data/app/services/command_tower/services/impersonation/create.rb +29 -0
- data/app/services/command_tower/services/impersonation/end.rb +28 -0
- data/app/services/command_tower/services/impersonation/record_activity.rb +30 -0
- data/app/services/command_tower/services/impersonation/terminate_open_sessions.rb +51 -0
- data/app/services/command_tower/services/me/capabilities.rb +43 -0
- data/app/services/command_tower/services/me/change_password.rb +96 -0
- data/app/services/command_tower/services/me/pushover_product_gate.rb +18 -0
- data/app/services/command_tower/services/me/sms_product_gate.rb +19 -0
- data/app/services/command_tower/services/me/update_name.rb +58 -0
- data/app/services/command_tower/services/messaging/communications/produce.rb +68 -0
- data/app/services/command_tower/services/messaging/communications/produce_many.rb +154 -0
- data/app/services/command_tower/services/messaging/inbox.rb +129 -0
- data/app/services/command_tower/services/messaging/preferences/platform_enabled_channels.rb +20 -0
- data/app/services/command_tower/services/messaging/preferences/show.rb +36 -0
- data/app/services/command_tower/services/messaging/preferences/update.rb +43 -0
- data/app/services/command_tower/services/messaging/recipients.rb +20 -0
- data/app/services/command_tower/services/rate_limits/check.rb +31 -0
- data/app/services/command_tower/services/service_result.rb +73 -0
- data/app/services/command_tower/user_attributes/mutate.rb +154 -0
- data/app/services/command_tower/username/available.rb +24 -11
- data/app/shared_sequences/command_tower/shared_sequences/admin/users/resolve_scoped_user.rb +42 -0
- data/app/views/command_tower/email_verification_mailer/verify_email.html.erb +70 -22
- data/app/views/command_tower/messaging/rendering/email.html.erb +28 -0
- data/app/views/command_tower/messaging/rendering/email.text.erb +7 -0
- data/app/views/command_tower/messaging/rendering/pushover.text.erb +1 -0
- data/app/views/command_tower/messaging/rendering/sms.text.erb +1 -0
- data/app/views/command_tower/password_reset_mailer/reset_password.html.erb +107 -0
- data/app/views/layouts/mailer.html.erb +13 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/workflows/command_tower/transactional.rb +65 -0
- data/app/workflows/command_tower/workflows/admin/messaging/create_announcement_workflow.rb +73 -0
- data/app/workflows/command_tower/workflows/admin/scope_resolution.rb +17 -0
- data/app/workflows/command_tower/workflows/admin/users/error_mapping.rb +26 -0
- data/app/workflows/command_tower/workflows/admin/users/identity_mutation.rb +30 -0
- data/app/workflows/command_tower/workflows/admin/users/list_assignable_roles_workflow.rb +30 -0
- data/app/workflows/command_tower/workflows/admin/users/list_workflow.rb +54 -0
- data/app/workflows/command_tower/workflows/admin/users/set_email_validated_workflow.rb +45 -0
- data/app/workflows/command_tower/workflows/admin/users/show_workflow.rb +49 -0
- data/app/workflows/command_tower/workflows/admin/users/update_email_workflow.rb +45 -0
- data/app/workflows/command_tower/workflows/admin/users/update_name_workflow.rb +49 -0
- data/app/workflows/command_tower/workflows/admin/users/update_roles_workflow.rb +61 -0
- data/app/workflows/command_tower/workflows/admin/users/update_username_workflow.rb +45 -0
- data/app/workflows/command_tower/workflows/admin/workspace/manifest_workflow.rb +25 -0
- data/app/workflows/command_tower/workflows/application_workflow.rb +207 -0
- data/app/workflows/command_tower/workflows/audit/error_mapping.rb +24 -0
- data/app/workflows/command_tower/workflows/audit/events/filter_options_for_admin_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/audit/events/filter_options_for_user_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/audit/events/list_for_admin_workflow.rb +74 -0
- data/app/workflows/command_tower/workflows/audit/events/list_for_user_workflow.rb +45 -0
- data/app/workflows/command_tower/workflows/audit/events/show_for_admin_workflow.rb +54 -0
- data/app/workflows/command_tower/workflows/audit/events/show_for_user_workflow.rb +42 -0
- data/app/workflows/command_tower/workflows/auth/authenticate_request_workflow.rb +41 -0
- data/app/workflows/command_tower/workflows/auth/authentication_response_effects.rb +25 -0
- data/app/workflows/command_tower/workflows/auth/authorize_request_workflow.rb +28 -0
- data/app/workflows/command_tower/workflows/auth/email_availability_workflow.rb +39 -0
- data/app/workflows/command_tower/workflows/auth/email_verification/send_workflow.rb +32 -0
- data/app/workflows/command_tower/workflows/auth/email_verification/verify_workflow.rb +35 -0
- data/app/workflows/command_tower/workflows/auth/identity_error_status.rb +36 -0
- data/app/workflows/command_tower/workflows/auth/identity_policy_workflow.rb +26 -0
- data/app/workflows/command_tower/workflows/auth/logout_workflow.rb +59 -0
- data/app/workflows/command_tower/workflows/auth/password_recovery_session/authenticate_workflow.rb +49 -0
- data/app/workflows/command_tower/workflows/auth/password_recovery_session/create_workflow.rb +39 -0
- data/app/workflows/command_tower/workflows/auth/password_reset/reset_workflow.rb +40 -0
- data/app/workflows/command_tower/workflows/auth/password_reset/send_workflow.rb +45 -0
- data/app/workflows/command_tower/workflows/auth/password_reset/validate_workflow.rb +40 -0
- data/app/workflows/command_tower/workflows/auth/plain_text/login_workflow.rb +48 -0
- data/app/workflows/command_tower/workflows/auth/principal_capabilities/show_workflow.rb +27 -0
- data/app/workflows/command_tower/workflows/auth/register_workflow.rb +115 -0
- data/app/workflows/command_tower/workflows/auth/session/show_workflow.rb +58 -0
- data/app/workflows/command_tower/workflows/auth/session_error_status.rb +31 -0
- data/app/workflows/command_tower/workflows/auth/signup_error_status.rb +31 -0
- data/app/workflows/command_tower/workflows/auth/signup_session/authenticate_workflow.rb +49 -0
- data/app/workflows/command_tower/workflows/auth/signup_session/create_workflow.rb +37 -0
- data/app/workflows/command_tower/workflows/auth/username_availability_workflow.rb +39 -0
- data/app/workflows/command_tower/workflows/impersonation/error_mapping.rb +27 -0
- data/app/workflows/command_tower/workflows/impersonation/start_workflow.rb +97 -0
- data/app/workflows/command_tower/workflows/impersonation/stop_workflow.rb +66 -0
- data/app/workflows/command_tower/workflows/me/change_password_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/me/clear_phone_workflow.rb +52 -0
- data/app/workflows/command_tower/workflows/me/error_mapping.rb +46 -0
- data/app/workflows/command_tower/workflows/me/error_status.rb +28 -0
- data/app/workflows/command_tower/workflows/me/phone_verification/send_workflow.rb +65 -0
- data/app/workflows/command_tower/workflows/me/phone_verification/verify_workflow.rb +57 -0
- data/app/workflows/command_tower/workflows/me/pushover/create_workflow.rb +38 -0
- data/app/workflows/command_tower/workflows/me/pushover/destroy_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/me/pushover/replace_workflow.rb +38 -0
- data/app/workflows/command_tower/workflows/me/pushover/show_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/me/pushover/verify_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/me/pushover/workflow_support.rb +31 -0
- data/app/workflows/command_tower/workflows/me/show_workflow.rb +33 -0
- data/app/workflows/command_tower/workflows/me/update_name_workflow.rb +49 -0
- data/app/workflows/command_tower/workflows/me/update_phone_workflow.rb +55 -0
- data/app/workflows/command_tower/workflows/messaging/communications/produce_recipient_workflow.rb +60 -0
- data/app/workflows/command_tower/workflows/messaging/error_mapping.rb +26 -0
- data/app/workflows/command_tower/workflows/messaging/execution/deliver_workflow.rb +234 -0
- data/app/workflows/command_tower/workflows/messaging/handoff/process_workflow.rb +90 -0
- data/app/workflows/command_tower/workflows/messaging/inbox.rb +97 -0
- data/app/workflows/command_tower/workflows/messaging/preferences/show_workflow.rb +31 -0
- data/app/workflows/command_tower/workflows/messaging/preferences/update_workflow.rb +37 -0
- data/app/workflows/command_tower/workflows/profile/show_workflow.rb +28 -0
- data/app/workflows/command_tower/workflows/workflow_result.rb +58 -0
- data/config/routes.rb +105 -37
- data/db/migrate/{20241117043720_create_command_tower_users.rb → 20260805000001_create_command_tower_users.rb} +7 -9
- data/db/migrate/{20241204065708_create_command_tower_user_secrets.rb → 20260805000002_create_command_tower_user_secrets.rb} +3 -0
- data/db/migrate/20260805000003_create_command_tower_messaging_core.rb +90 -0
- data/db/migrate/20260805000004_create_messaging_notification_preferences.rb +17 -0
- data/db/migrate/20260805000005_create_messaging_endpoints_and_pushover_credentials.rb +72 -0
- data/db/migrate/20260816000001_create_command_tower_audit_events.rb +45 -0
- data/db/migrate/20260817000001_add_scope_columns_to_command_tower_audit_events.rb +34 -0
- data/db/migrate/20260817000003_create_command_tower_impersonation_sessions.rb +26 -0
- data/docs/admin_workspace.md +158 -0
- data/docs/api_reference.md +599 -0
- data/docs/architecture.md +35 -0
- data/docs/audit.md +195 -0
- data/docs/authentication.md +51 -0
- data/docs/authentication_authorization_guide.md +154 -0
- data/docs/authorization.md +55 -0
- data/docs/change_password_workflow.md +67 -0
- data/docs/controllers.md +41 -0
- data/docs/cookie_authentication_guide.md +167 -0
- data/docs/email_verification_workflow.md +58 -0
- data/docs/eventing.md +179 -0
- data/docs/extending.md +136 -0
- data/docs/host_integration_guide.md +249 -0
- data/docs/initializing.md +169 -0
- data/docs/messaging_integration_guide.md +87 -0
- data/docs/models.md +55 -0
- data/docs/pagination.md +47 -0
- data/docs/password_reset_workflow.md +82 -0
- data/docs/principal_capabilities.md +89 -0
- data/docs/sensitive_routes.md +47 -0
- data/docs/testing.md +74 -0
- data/docs/upgrades/0.10.0.md +58 -0
- data/docs/upgrades/0.11.0.md +92 -0
- data/docs/upgrades/README.md +10 -0
- data/lib/command_tower/admin_scope/apply_audit_scoping.rb +45 -0
- data/lib/command_tower/admin_scope/apply_users_narrowing.rb +21 -0
- data/lib/command_tower/admin_scope/manifest_projection.rb +102 -0
- data/lib/command_tower/admin_scope/resolve.rb +31 -0
- data/lib/command_tower/admin_scope/scope_context.rb +7 -0
- data/lib/command_tower/admin_scope/scope_option.rb +7 -0
- data/lib/command_tower/admin_scope.rb +20 -0
- data/lib/command_tower/admin_workspace.rb +16 -0
- data/lib/command_tower/audit/attribution.rb +90 -0
- data/lib/command_tower/audit/emit.rb +113 -0
- data/lib/command_tower/audit/masking.rb +41 -0
- data/lib/command_tower/audit/payload.rb +128 -0
- data/lib/command_tower/audit/persistence/subscriber.rb +85 -0
- data/lib/command_tower/audit.rb +27 -0
- data/lib/command_tower/authorization/assignable_roles.rb +36 -0
- data/lib/command_tower/authorization/default.yml +101 -35
- data/lib/command_tower/authorization/effective_entity_grants.rb +55 -0
- data/lib/command_tower/authorization/entity.rb +15 -5
- data/lib/command_tower/authorization/role.rb +5 -4
- data/lib/command_tower/authorization.rb +71 -10
- data/lib/command_tower/configuration/admin_scope/config.rb +104 -0
- data/lib/command_tower/configuration/admin_scope/tool_registration.rb +28 -0
- data/lib/command_tower/configuration/application/config.rb +2 -2
- data/lib/command_tower/configuration/authorization/config.rb +6 -0
- data/lib/command_tower/configuration/base.rb +0 -1
- data/lib/command_tower/configuration/config.rb +51 -1
- data/lib/command_tower/configuration/credentials/config.rb +33 -0
- data/lib/command_tower/configuration/credentials/smtp.rb +33 -0
- data/lib/command_tower/configuration/credentials/twilio.rb +33 -0
- data/lib/command_tower/configuration/email/config.rb +1 -18
- data/lib/command_tower/configuration/identity/config.rb +19 -0
- data/lib/command_tower/configuration/identity/phone_verification.rb +54 -0
- data/lib/command_tower/configuration/impersonation/config.rb +38 -0
- data/lib/command_tower/configuration/jwt/config.rb +7 -0
- data/lib/command_tower/configuration/jwt/cookie/config.rb +64 -0
- data/lib/command_tower/configuration/jwt/cookie/csrf/config.rb +72 -0
- data/lib/command_tower/configuration/login/strategy/plain_text/config.rb +6 -0
- data/lib/command_tower/configuration/login/strategy/plain_text/email_verify.rb +5 -0
- data/lib/command_tower/configuration/login/strategy/plain_text/password_reset.rb +49 -0
- data/lib/command_tower/configuration/messaging/config.rb +60 -0
- data/lib/command_tower/configuration/messaging/pushover.rb +42 -0
- data/lib/command_tower/configuration/messaging/sms.rb +32 -0
- data/lib/command_tower/configuration/password_recovery_session/config.rb +61 -0
- data/lib/command_tower/configuration/password_recovery_session/rate_limits.rb +33 -0
- data/lib/command_tower/configuration/registry/admin_workspace/config.rb +199 -0
- data/lib/command_tower/configuration/registry/admin_workspace/tool_definition.rb +150 -0
- data/lib/command_tower/configuration/registry/audit/config.rb +403 -0
- data/lib/command_tower/configuration/registry/audit/event_definition.rb +155 -0
- data/lib/command_tower/configuration/registry/config.rb +34 -0
- data/lib/command_tower/configuration/registry/principal_capabilities/capability_definition.rb +43 -0
- data/lib/command_tower/configuration/registry/principal_capabilities/config.rb +136 -0
- data/lib/command_tower/configuration/signup_session/config.rb +67 -0
- data/lib/command_tower/configuration/signup_session/email_availability.rb +18 -0
- data/lib/command_tower/configuration/signup_session/rate_limits.rb +48 -0
- data/lib/command_tower/configuration/user/config.rb +6 -5
- data/lib/command_tower/credential_resolution/env_backend.rb +25 -0
- data/lib/command_tower/credential_resolution/smtp_action_mailer_bridge.rb +24 -0
- data/lib/command_tower/credential_resolution/smtp_credentials.rb +26 -0
- data/lib/command_tower/credential_resolution/twilio_credentials.rb +26 -0
- data/lib/command_tower/credential_resolution.rb +78 -0
- data/lib/command_tower/current.rb +19 -0
- data/lib/command_tower/engine.rb +23 -5
- data/lib/command_tower/events.rb +184 -0
- data/lib/command_tower/execution.rb +111 -0
- data/lib/command_tower/impersonation/activity_declaration.rb +23 -0
- data/lib/command_tower/impersonation/apply_overlay.rb +88 -0
- data/lib/command_tower/impersonation/clear_overlay_for_audit.rb +23 -0
- data/lib/command_tower/impersonation/establish_identity.rb +44 -0
- data/lib/command_tower/install/baseline.rb +34 -0
- data/lib/command_tower/install/doctor.rb +227 -0
- data/lib/command_tower/jwt/authorization_helper.rb +136 -0
- data/lib/command_tower/jwt/csrf_helper.rb +138 -0
- data/lib/command_tower/logging/lifecycle_declaration.rb +27 -0
- data/lib/command_tower/logging/projection.rb +67 -0
- data/lib/command_tower/logging/subscriber.rb +103 -0
- data/lib/command_tower/password_recovery/authorization_helper.rb +25 -0
- data/lib/command_tower/principal_capabilities.rb +15 -0
- data/lib/command_tower/redis_connection.rb +21 -0
- data/lib/command_tower/schema/error/email_validation_required.rb +15 -0
- data/lib/command_tower/schema/shared/user.rb +32 -0
- data/lib/command_tower/schema.rb +2 -25
- data/lib/command_tower/signup/authorization_helper.rb +25 -0
- data/lib/command_tower/spec_helper.rb +58 -1
- data/lib/command_tower/testing.rb +62 -0
- data/lib/command_tower/version.rb +1 -1
- data/lib/command_tower.rb +32 -0
- data/lib/generators/command_tower/configure/USAGE +14 -2
- data/lib/generators/command_tower/configure/configure_generator.rb +29 -2
- data/lib/tasks/auto_annotate_models.rake +23 -55
- data/lib/tasks/install.rake +81 -0
- data/lib/tasks/users.rake +119 -0
- data/spec/factories/entity.rb +37 -0
- data/spec/factories/impersonation_session.rb +17 -0
- data/spec/factories/messaging.rb +156 -0
- data/spec/factories/role.rb +29 -0
- data/spec/factories/user.rb +69 -0
- data/spec/factories/user_secret.rb +12 -0
- metadata +686 -55
- data/app/controllers/command_tower/admin_controller.rb +0 -110
- data/app/controllers/command_tower/auth/plain_text_controller.rb +0 -133
- data/app/controllers/command_tower/inbox/message_blast_controller.rb +0 -89
- data/app/controllers/command_tower/inbox/message_controller.rb +0 -81
- data/app/controllers/command_tower/user_controller.rb +0 -49
- data/app/controllers/command_tower/username_controller.rb +0 -26
- data/app/helpers/command_tower/pagination_helper.rb +0 -40
- data/app/helpers/command_tower/schema_helper.rb +0 -29
- data/app/models/message.rb +0 -30
- data/app/models/message_blast.rb +0 -27
- data/app/services/command_tower/admin_service/users.rb +0 -27
- data/app/services/command_tower/inbox_service/blast/delete.rb +0 -23
- data/app/services/command_tower/inbox_service/blast/metadata.rb +0 -26
- data/app/services/command_tower/inbox_service/blast/new_user_blaster.rb +0 -24
- data/app/services/command_tower/inbox_service/blast/retrieve.rb +0 -30
- data/app/services/command_tower/inbox_service/blast/upsert.rb +0 -67
- data/app/services/command_tower/inbox_service/message/metadata.rb +0 -41
- data/app/services/command_tower/inbox_service/message/modify.rb +0 -44
- data/app/services/command_tower/inbox_service/message/retrieve.rb +0 -36
- data/app/services/command_tower/inbox_service/message/send.rb +0 -33
- data/app/services/command_tower/jwt/time_delay_token.rb +0 -17
- data/app/services/command_tower/login_strategy/plain_text/create.rb +0 -43
- data/app/services/command_tower/login_strategy/plain_text/email_verification/generate.rb +0 -29
- data/app/services/command_tower/login_strategy/plain_text/email_verification/send.rb +0 -23
- data/app/services/command_tower/login_strategy/plain_text/email_verification/verify.rb +0 -24
- data/app/services/command_tower/login_strategy/plain_text/login.rb +0 -50
- data/app/services/command_tower/pagination_service_helper.rb +0 -88
- data/app/services/command_tower/user_attributes/modify.rb +0 -68
- data/app/services/command_tower/user_attributes/roles.rb +0 -27
- data/db/migrate/20250223023306_create_command_tower_messages.rb +0 -12
- data/db/migrate/20250223023313_create_command_tower_message_blasts.rb +0 -14
- data/lib/command_tower/schema/admin/users.rb +0 -16
- data/lib/command_tower/schema/inbox/blast_request.rb +0 -15
- data/lib/command_tower/schema/inbox/blast_response.rb +0 -16
- data/lib/command_tower/schema/inbox/message_blast_entity.rb +0 -16
- data/lib/command_tower/schema/inbox/message_blast_metadata.rb +0 -16
- data/lib/command_tower/schema/inbox/message_entity.rb +0 -14
- data/lib/command_tower/schema/inbox/metadata.rb +0 -18
- data/lib/command_tower/schema/inbox/modified.rb +0 -13
- data/lib/command_tower/schema/page.rb +0 -11
- data/lib/command_tower/schema/pagination.rb +0 -16
- data/lib/command_tower/schema/plain_text/create_user_request.rb +0 -18
- data/lib/command_tower/schema/plain_text/create_user_response.rb +0 -17
- data/lib/command_tower/schema/plain_text/email_verify_request.rb +0 -11
- data/lib/command_tower/schema/plain_text/email_verify_response.rb +0 -11
- data/lib/command_tower/schema/plain_text/email_verify_send_request.rb +0 -9
- data/lib/command_tower/schema/plain_text/email_verify_send_response.rb +0 -11
- data/lib/command_tower/schema/plain_text/login_request.rb +0 -15
- data/lib/command_tower/schema/plain_text/login_response.rb +0 -16
- data/lib/command_tower/schema/user.rb +0 -28
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module Workflows
|
|
5
|
+
module Messaging
|
|
6
|
+
module Preferences
|
|
7
|
+
class UpdateWorkflow < CommandTower::Workflows::ApplicationWorkflow
|
|
8
|
+
retry_strategy :none
|
|
9
|
+
|
|
10
|
+
def call(user:, notification_type_key:, preference_state:)
|
|
11
|
+
result = CommandTower::Services::Messaging::Preferences::Update.call(
|
|
12
|
+
user:,
|
|
13
|
+
notification_type_key:,
|
|
14
|
+
preference_state:,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
unless result.success?
|
|
18
|
+
error = result.errors.first
|
|
19
|
+
return failure(
|
|
20
|
+
errors: result.errors,
|
|
21
|
+
http_status: CommandTower::Workflows::Messaging::ErrorMapping.http_status_for(error)
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
payload = {
|
|
26
|
+
notification: CommandTower::Serializers::Messaging::Preferences::NotificationSerializer.serialize(
|
|
27
|
+
result.data[:notification],
|
|
28
|
+
),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
success(payload:, http_status: :ok)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module Workflows
|
|
5
|
+
module Profile
|
|
6
|
+
class ShowWorkflow < CommandTower::Workflows::ApplicationWorkflow
|
|
7
|
+
retry_strategy :none
|
|
8
|
+
impersonation_activity!
|
|
9
|
+
|
|
10
|
+
def call(current_user:, auth_context: nil)
|
|
11
|
+
success(
|
|
12
|
+
payload: CommandTower::Serializers::Profile::ProfileSerializer.serialize(current_user),
|
|
13
|
+
http_status: :ok,
|
|
14
|
+
response_effects: expire_header_effects(auth_context)
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def expire_header_effects(auth_context)
|
|
21
|
+
return if auth_context.nil?
|
|
22
|
+
|
|
23
|
+
{ set_expire_header: auth_context.token_expires_at }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module Workflows
|
|
5
|
+
class WorkflowResult
|
|
6
|
+
STATUSES = %i[success deferred failure].freeze
|
|
7
|
+
|
|
8
|
+
attr_reader :payload, :errors, :http_status, :response_effects, :meta, :reason, :retry_after
|
|
9
|
+
|
|
10
|
+
def initialize(status:, payload:, errors:, http_status:, response_effects: nil, meta: {},
|
|
11
|
+
reason: nil, retry_after: nil)
|
|
12
|
+
@status = status.to_sym
|
|
13
|
+
raise ArgumentError, "invalid WorkflowResult status #{@status}" unless STATUSES.include?(@status)
|
|
14
|
+
|
|
15
|
+
@payload = payload
|
|
16
|
+
@errors = errors
|
|
17
|
+
@http_status = http_status
|
|
18
|
+
@response_effects = response_effects
|
|
19
|
+
@meta = meta
|
|
20
|
+
@reason = reason
|
|
21
|
+
@retry_after = retry_after
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def success?
|
|
25
|
+
@status == :success
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def deferred?
|
|
29
|
+
@status == :deferred
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def failure?
|
|
33
|
+
@status == :failure
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.success(payload:, http_status: :ok, response_effects: nil, meta: {})
|
|
37
|
+
new(status: :success, payload:, errors: [], http_status:, response_effects:, meta:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.failure(errors:, http_status:, response_effects: nil, meta: {})
|
|
41
|
+
new(status: :failure, payload: nil, errors:, http_status:, response_effects:, meta:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.deferred(reason:, retry_after:, payload: {}, http_status: :accepted, response_effects: nil, meta: {})
|
|
45
|
+
new(
|
|
46
|
+
status: :deferred,
|
|
47
|
+
payload:,
|
|
48
|
+
errors: [],
|
|
49
|
+
http_status:,
|
|
50
|
+
response_effects:,
|
|
51
|
+
meta:,
|
|
52
|
+
reason: reason.to_sym,
|
|
53
|
+
retry_after: Integer(retry_after)
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/config/routes.rb
CHANGED
|
@@ -1,55 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
append_to_ass = "command_tower"
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
# Modern platform HTTP only — intended for host mount (e.g. DFM `/api`).
|
|
4
|
+
CommandTower::Engine.routes.draw do
|
|
5
|
+
# Test-only auth harness for ApplicationController cookie/CSRF specs.
|
|
6
|
+
if Rails.env.test?
|
|
7
|
+
get "show", to: "protected_fixture#show"
|
|
8
|
+
post "modify", to: "protected_fixture#modify"
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
namespace :auth do
|
|
12
|
+
post "logout", to: "logout#create"
|
|
13
|
+
get "session", to: "session#show"
|
|
14
|
+
get "principal-capabilities", to: "principal_capabilities#show"
|
|
15
|
+
delete "impersonation-session", to: "impersonation_session#destroy"
|
|
16
|
+
|
|
11
17
|
constraints(->(_req) { CommandTower.config.login.plain_text.enable? }) do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constraints(->(_req) { CommandTower.config.login.plain_text.email_verify? }) do
|
|
16
|
-
scope "email" do
|
|
17
|
-
post "/verify", to: "command_tower/auth/plain_text#email_verify_post", as: :"#{append_to_ass}_auth_email_verification"
|
|
18
|
-
post "/send", to: "command_tower/auth/plain_text#email_verify_resend_post", as: :"#{append_to_ass}_auth_email_verification_send"
|
|
19
|
-
end
|
|
18
|
+
scope path: "plain-text", module: "plain_text" do
|
|
19
|
+
post "login", to: "login#create"
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
end
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
23
|
+
post "register", to: "register#create"
|
|
24
|
+
post "signup-session", to: "signup_session/create#create"
|
|
25
|
+
get "identity-policy", to: "identity_policy#show"
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
constraints(->(_req) { CommandTower.config.signup_session.email_availability? }) do
|
|
28
|
+
namespace :email do
|
|
29
|
+
get "availability", to: "availability#show"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Parity with legacy SchemaHelper GET /username/available/:username gate.
|
|
34
|
+
constraints(->(_req) { CommandTower.config.username.realtime_username_check? }) do
|
|
35
|
+
namespace :username do
|
|
36
|
+
get "availability", to: "availability#show"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
constraints(->(_req) { CommandTower.config.login.plain_text.email_verify? }) do
|
|
41
|
+
namespace :email_verification, path: "email-verification", module: "email_verification" do
|
|
42
|
+
post "send", to: "send#create"
|
|
43
|
+
post "verify", to: "verify#create"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
delete "/:id", to: "command_tower/inbox/message#delete", as: :"#{append_to_ass}_inbox_message_del"
|
|
47
|
+
post "password-recovery-session", to: "password_recovery_session/create#create"
|
|
35
48
|
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
constraints(->(_req) { CommandTower.config.login.plain_text.password_reset? }) do
|
|
50
|
+
namespace :password_reset, path: "password-reset", module: "password_reset" do
|
|
51
|
+
post "send", to: "send#create"
|
|
52
|
+
post "validate", to: "validate#create"
|
|
53
|
+
post "reset", to: "reset#create"
|
|
54
|
+
end
|
|
38
55
|
end
|
|
56
|
+
end
|
|
39
57
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
get "me", to: "me#show"
|
|
59
|
+
get "profile", to: "profile#show"
|
|
60
|
+
namespace :me do
|
|
61
|
+
patch "name", to: "name#update"
|
|
62
|
+
patch "password", to: "password#update"
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
resources :inbox, only: [:index, :show, :destroy], controller: "inbox" do
|
|
65
|
+
collection do
|
|
66
|
+
get :unread_count, path: "unread-count"
|
|
67
|
+
post "bulk/read", action: :bulk_read
|
|
68
|
+
post "bulk/unread", action: :bulk_unread
|
|
69
|
+
post "bulk/archive", action: :bulk_archive
|
|
70
|
+
post "bulk/restore", action: :bulk_restore
|
|
71
|
+
post "bulk/delete", action: :bulk_delete
|
|
72
|
+
end
|
|
73
|
+
member do
|
|
74
|
+
post :open
|
|
75
|
+
patch :archive
|
|
76
|
+
end
|
|
47
77
|
end
|
|
78
|
+
|
|
79
|
+
get "audit-events/filter-options", to: "audit_events#filter_options"
|
|
80
|
+
get "audit-events", to: "audit_events#index"
|
|
81
|
+
get "audit-events/:id", to: "audit_events#show"
|
|
82
|
+
|
|
83
|
+
resource :preferences, only: [:show], controller: "preferences"
|
|
84
|
+
patch "preferences/:notification_type_key", to: "preferences#update"
|
|
85
|
+
|
|
86
|
+
# Phone lifecycle always drawn (no SMS/Pushover route constraints).
|
|
87
|
+
# Product SMS readiness is workflow-gated as 503 sms_capability_unavailable.
|
|
88
|
+
patch "phone", to: "phone#update"
|
|
89
|
+
delete "phone", to: "phone#destroy"
|
|
90
|
+
post "phone/verification", to: "phone_verification/verifications#create"
|
|
91
|
+
post "phone/verification/verify", to: "phone_verification/verify#create"
|
|
92
|
+
|
|
93
|
+
# Pushover lifecycle always drawn (no route constraints).
|
|
94
|
+
# Product readiness is workflow-gated as 503 pushover_capability_unavailable.
|
|
95
|
+
# Explicit put + patch both → #update (frontend uses PUT for replace).
|
|
96
|
+
get "pushover", to: "pushover#show"
|
|
97
|
+
post "pushover", to: "pushover#create"
|
|
98
|
+
patch "pushover", to: "pushover#update"
|
|
99
|
+
put "pushover", to: "pushover#update"
|
|
100
|
+
delete "pushover", to: "pushover#destroy"
|
|
101
|
+
post "pushover/verification", to: "pushover/verifications#create"
|
|
48
102
|
end
|
|
49
103
|
|
|
50
|
-
|
|
51
|
-
get "/", to: "
|
|
52
|
-
|
|
53
|
-
|
|
104
|
+
namespace :admin do
|
|
105
|
+
get "audit-events/filter-options", to: "audit/events#filter_options"
|
|
106
|
+
get "audit-events", to: "audit/events#index"
|
|
107
|
+
get "audit-events/:id", to: "audit/events#show"
|
|
108
|
+
get "users", to: "users#index"
|
|
109
|
+
get "users/assignable-roles", to: "users/roles#index"
|
|
110
|
+
get "users/:id", to: "users#show"
|
|
111
|
+
patch "users/:id/name", to: "users/identities#update_name"
|
|
112
|
+
patch "users/:id/username", to: "users/identities#update_username"
|
|
113
|
+
patch "users/:id/email", to: "users/identities#update_email"
|
|
114
|
+
patch "users/:id/email-validation", to: "users/identities#update_email_validation"
|
|
115
|
+
patch "users/:id/roles", to: "users/roles#update"
|
|
116
|
+
post "users/:id/impersonation-sessions", to: "users/impersonation_sessions#create"
|
|
117
|
+
get "workspace", to: "workspace#show"
|
|
118
|
+
|
|
119
|
+
namespace :messaging do
|
|
120
|
+
post "announcements", to: "announcements#create"
|
|
121
|
+
end
|
|
54
122
|
end
|
|
55
123
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class CreateCommandTowerUsers < ActiveRecord::Migration[7.2]
|
|
2
4
|
def change
|
|
3
5
|
create_table :users do |t|
|
|
@@ -14,9 +16,7 @@ class CreateCommandTowerUsers < ActiveRecord::Migration[7.2]
|
|
|
14
16
|
|
|
15
17
|
t.string :roles, default: ""
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
# Database token to verify JWT
|
|
19
|
-
# Token will allow JWT values to expire/reset all devices
|
|
19
|
+
# Database token to verify JWT — allows JWT values to expire/reset all devices
|
|
20
20
|
t.string :verifier_token
|
|
21
21
|
t.datetime :verifier_token_last_reset
|
|
22
22
|
|
|
@@ -27,16 +27,14 @@ class CreateCommandTowerUsers < ActiveRecord::Migration[7.2]
|
|
|
27
27
|
t.string :password_digest, null: false, default: ""
|
|
28
28
|
t.string :recovery_password_digest, null: false, default: ""
|
|
29
29
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# t.integer :otp_consumed_timestep
|
|
34
|
-
# t.boolean :otp_enabled, default: false
|
|
35
|
-
# t.text :otp_backup_codes
|
|
30
|
+
# Identity phone
|
|
31
|
+
t.string :phone_number
|
|
32
|
+
t.boolean :phone_number_validated, null: false, default: false
|
|
36
33
|
|
|
37
34
|
t.timestamps
|
|
38
35
|
end
|
|
39
36
|
|
|
40
37
|
add_index :users, :username, unique: true
|
|
38
|
+
add_index :users, :phone_number, unique: true
|
|
41
39
|
end
|
|
42
40
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class CreateCommandTowerUserSecrets < ActiveRecord::Migration[7.2]
|
|
2
4
|
def change
|
|
3
5
|
create_table :user_secrets do |t|
|
|
@@ -11,6 +13,7 @@ class CreateCommandTowerUserSecrets < ActiveRecord::Migration[7.2]
|
|
|
11
13
|
|
|
12
14
|
t.timestamps
|
|
13
15
|
end
|
|
16
|
+
|
|
14
17
|
add_index :user_secrets, :secret, unique: true
|
|
15
18
|
end
|
|
16
19
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateCommandTowerMessagingCore < ActiveRecord::Migration[7.2]
|
|
4
|
+
def change
|
|
5
|
+
create_table :messaging_communications do |t|
|
|
6
|
+
t.timestamps
|
|
7
|
+
t.references :user, null: false, foreign_key: true
|
|
8
|
+
t.string :notification_type_key, null: false
|
|
9
|
+
t.string :title, null: false
|
|
10
|
+
t.text :body, null: false
|
|
11
|
+
t.text :metadata
|
|
12
|
+
t.string :host_event_identity
|
|
13
|
+
t.string :accept_request_fingerprint
|
|
14
|
+
t.string :status
|
|
15
|
+
t.string :execution_handoff_status, null: false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
add_index :messaging_communications,
|
|
19
|
+
%i[user_id notification_type_key host_event_identity],
|
|
20
|
+
unique: true,
|
|
21
|
+
name: "index_messaging_communications_on_idempotency_namespace"
|
|
22
|
+
add_index :messaging_communications,
|
|
23
|
+
%i[status execution_handoff_status updated_at],
|
|
24
|
+
name: "index_messaging_communications_on_handoff_recovery"
|
|
25
|
+
|
|
26
|
+
create_table :messaging_destination_plans do |t|
|
|
27
|
+
t.timestamps
|
|
28
|
+
t.references :communication,
|
|
29
|
+
null: false,
|
|
30
|
+
foreign_key: { to_table: :messaging_communications, on_delete: :cascade },
|
|
31
|
+
index: { unique: true }
|
|
32
|
+
t.text :decision
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
create_table :messaging_inbox_items do |t|
|
|
36
|
+
t.timestamps
|
|
37
|
+
t.references :communication,
|
|
38
|
+
null: false,
|
|
39
|
+
foreign_key: { to_table: :messaging_communications, on_delete: :cascade },
|
|
40
|
+
index: { unique: true }
|
|
41
|
+
t.string :status
|
|
42
|
+
t.datetime :viewed_at
|
|
43
|
+
t.datetime :archived_at
|
|
44
|
+
t.datetime :deleted_at
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
add_index :messaging_inbox_items,
|
|
48
|
+
%i[deleted_at archived_at viewed_at],
|
|
49
|
+
name: "index_messaging_inbox_items_on_lifecycle"
|
|
50
|
+
|
|
51
|
+
create_table :messaging_channel_deliveries do |t|
|
|
52
|
+
t.timestamps
|
|
53
|
+
t.references :communication,
|
|
54
|
+
null: false,
|
|
55
|
+
foreign_key: { to_table: :messaging_communications, on_delete: :cascade },
|
|
56
|
+
index: true
|
|
57
|
+
t.string :channel_key, null: false
|
|
58
|
+
t.string :status
|
|
59
|
+
t.datetime :execution_claimed_at
|
|
60
|
+
t.integer :execution_attempt_count, null: false, default: 0
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
add_index :messaging_channel_deliveries,
|
|
64
|
+
%i[communication_id channel_key],
|
|
65
|
+
unique: true,
|
|
66
|
+
name: "index_messaging_channel_deliveries_on_comm_and_channel"
|
|
67
|
+
add_index :messaging_channel_deliveries,
|
|
68
|
+
%i[status execution_claimed_at updated_at],
|
|
69
|
+
name: "index_messaging_channel_deliveries_on_execution_recovery"
|
|
70
|
+
|
|
71
|
+
create_table :messaging_delivery_attempts do |t|
|
|
72
|
+
t.timestamps
|
|
73
|
+
t.references :channel_delivery,
|
|
74
|
+
null: false,
|
|
75
|
+
foreign_key: { to_table: :messaging_channel_deliveries, on_delete: :cascade },
|
|
76
|
+
index: true
|
|
77
|
+
t.string :status, null: false
|
|
78
|
+
t.datetime :started_at, null: false
|
|
79
|
+
t.datetime :finished_at
|
|
80
|
+
t.string :error_class
|
|
81
|
+
t.string :error_code
|
|
82
|
+
t.string :provider_message_id
|
|
83
|
+
t.string :normalized_provider_status
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
add_index :messaging_delivery_attempts,
|
|
87
|
+
%i[channel_delivery_id status],
|
|
88
|
+
name: "index_messaging_delivery_attempts_on_delivery_and_status"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateMessagingNotificationPreferences < ActiveRecord::Migration[7.2]
|
|
4
|
+
def change
|
|
5
|
+
create_table :messaging_notification_preferences do |t|
|
|
6
|
+
t.timestamps
|
|
7
|
+
t.references :user, null: false, foreign_key: true
|
|
8
|
+
t.string :notification_type_key, null: false
|
|
9
|
+
t.text :state, null: false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
add_index :messaging_notification_preferences,
|
|
13
|
+
%i[user_id notification_type_key],
|
|
14
|
+
unique: true,
|
|
15
|
+
name: "index_messaging_notification_preferences_unique"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateMessagingEndpointsAndPushoverCredentials < ActiveRecord::Migration[7.2]
|
|
4
|
+
def change
|
|
5
|
+
create_table :messaging_endpoints do |t|
|
|
6
|
+
t.timestamps
|
|
7
|
+
t.references :user, null: false, foreign_key: true
|
|
8
|
+
t.string :channel_key, null: false
|
|
9
|
+
t.string :lifecycle_state, null: false
|
|
10
|
+
t.string :verification_state, null: false
|
|
11
|
+
t.string :address_fingerprint, null: false
|
|
12
|
+
t.string :masked_display_value, null: false
|
|
13
|
+
t.text :address_ciphertext # nullable for typed credential channels (e.g. Pushover)
|
|
14
|
+
t.integer :encryption_key_version, null: false, default: 1
|
|
15
|
+
t.integer :lock_version, null: false, default: 0
|
|
16
|
+
t.datetime :verified_at
|
|
17
|
+
t.datetime :revoked_at
|
|
18
|
+
t.datetime :last_successful_use_at
|
|
19
|
+
t.string :active_fingerprint
|
|
20
|
+
t.string :single_active_slot
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
add_index :messaging_endpoints,
|
|
24
|
+
%i[user_id channel_key active_fingerprint],
|
|
25
|
+
unique: true,
|
|
26
|
+
name: "index_messaging_endpoints_active_fingerprint"
|
|
27
|
+
add_index :messaging_endpoints,
|
|
28
|
+
%i[single_active_slot],
|
|
29
|
+
unique: true,
|
|
30
|
+
name: "index_messaging_endpoints_single_active_slot"
|
|
31
|
+
add_index :messaging_endpoints,
|
|
32
|
+
%i[user_id channel_key],
|
|
33
|
+
name: "index_messaging_endpoints_owner_channel"
|
|
34
|
+
|
|
35
|
+
reversible do |dir|
|
|
36
|
+
dir.up do
|
|
37
|
+
execute <<~SQL.squish
|
|
38
|
+
ALTER TABLE messaging_endpoints
|
|
39
|
+
ADD CONSTRAINT chk_messaging_endpoints_lifecycle
|
|
40
|
+
CHECK (lifecycle_state IN ('active', 'revoked', 'invalid', 'retired'))
|
|
41
|
+
SQL
|
|
42
|
+
execute <<~SQL.squish
|
|
43
|
+
ALTER TABLE messaging_endpoints
|
|
44
|
+
ADD CONSTRAINT chk_messaging_endpoints_verification
|
|
45
|
+
CHECK (verification_state IN ('unverified', 'pending', 'verified', 'failed'))
|
|
46
|
+
SQL
|
|
47
|
+
end
|
|
48
|
+
dir.down do
|
|
49
|
+
execute "ALTER TABLE messaging_endpoints DROP CHECK chk_messaging_endpoints_lifecycle"
|
|
50
|
+
execute "ALTER TABLE messaging_endpoints DROP CHECK chk_messaging_endpoints_verification"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
create_table :messaging_endpoint_pushover_credentials do |t|
|
|
55
|
+
t.timestamps
|
|
56
|
+
t.bigint :messaging_endpoint_id, null: false
|
|
57
|
+
t.text :user_key_ciphertext, null: false
|
|
58
|
+
t.text :application_token_ciphertext, null: false
|
|
59
|
+
t.integer :encryption_key_version, null: false, default: 1
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
add_index :messaging_endpoint_pushover_credentials,
|
|
63
|
+
:messaging_endpoint_id,
|
|
64
|
+
unique: true,
|
|
65
|
+
name: "index_messaging_pushover_credentials_on_endpoint_id"
|
|
66
|
+
|
|
67
|
+
add_foreign_key :messaging_endpoint_pushover_credentials,
|
|
68
|
+
:messaging_endpoints,
|
|
69
|
+
column: :messaging_endpoint_id,
|
|
70
|
+
on_delete: :cascade
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateCommandTowerAuditEvents < ActiveRecord::Migration[7.2]
|
|
4
|
+
def change
|
|
5
|
+
create_table :command_tower_audit_events, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci" do |t|
|
|
6
|
+
t.string :event_uuid, null: false
|
|
7
|
+
t.string :action, null: false
|
|
8
|
+
t.datetime :occurred_at, null: false
|
|
9
|
+
|
|
10
|
+
t.string :execution_uuid
|
|
11
|
+
t.string :correlation_id
|
|
12
|
+
t.string :request_id
|
|
13
|
+
t.string :causation_id
|
|
14
|
+
t.string :source
|
|
15
|
+
|
|
16
|
+
t.bigint :actor_user_id
|
|
17
|
+
t.bigint :affected_user_id
|
|
18
|
+
t.bigint :effective_user_id
|
|
19
|
+
t.bigint :originating_administrator_id
|
|
20
|
+
t.boolean :impersonation_active, null: false, default: false
|
|
21
|
+
t.string :attribution_mode, null: false
|
|
22
|
+
|
|
23
|
+
t.string :subject_type
|
|
24
|
+
t.bigint :subject_id
|
|
25
|
+
t.string :subject_label
|
|
26
|
+
|
|
27
|
+
t.json :change_set, null: false
|
|
28
|
+
t.json :metadata, null: false
|
|
29
|
+
|
|
30
|
+
t.boolean :user_history, null: false
|
|
31
|
+
t.json :sensitive_fields, null: false
|
|
32
|
+
t.string :retention, null: false
|
|
33
|
+
|
|
34
|
+
t.timestamps
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
add_index :command_tower_audit_events, :event_uuid, unique: true, name: "index_ct_audit_events_on_event_uuid"
|
|
38
|
+
add_index :command_tower_audit_events, %i[affected_user_id occurred_at], name: "index_ct_audit_events_on_affected_occurred"
|
|
39
|
+
add_index :command_tower_audit_events, %i[actor_user_id occurred_at], name: "index_ct_audit_events_on_actor_occurred"
|
|
40
|
+
add_index :command_tower_audit_events, %i[action occurred_at], name: "index_ct_audit_events_on_action_occurred"
|
|
41
|
+
add_index :command_tower_audit_events, :execution_uuid, name: "index_ct_audit_events_on_execution_uuid"
|
|
42
|
+
add_index :command_tower_audit_events, :correlation_id, name: "index_ct_audit_events_on_correlation_id"
|
|
43
|
+
add_index :command_tower_audit_events, %i[originating_administrator_id occurred_at], name: "index_ct_audit_events_on_originating_admin_occurred"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddScopeColumnsToCommandTowerAuditEvents < ActiveRecord::Migration[7.2]
|
|
4
|
+
def up
|
|
5
|
+
change_table :command_tower_audit_events, bulk: true do |t|
|
|
6
|
+
t.string :scope_class, null: false, default: "legacy"
|
|
7
|
+
t.string :host_context_type
|
|
8
|
+
t.string :host_context_identifier
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
execute <<~SQL.squish
|
|
12
|
+
UPDATE command_tower_audit_events
|
|
13
|
+
SET scope_class = 'legacy'
|
|
14
|
+
WHERE scope_class IS NULL OR scope_class = 'legacy'
|
|
15
|
+
SQL
|
|
16
|
+
|
|
17
|
+
add_index :command_tower_audit_events,
|
|
18
|
+
%i[host_context_type host_context_identifier occurred_at],
|
|
19
|
+
name: "index_ct_audit_events_on_host_context_occurred"
|
|
20
|
+
add_index :command_tower_audit_events,
|
|
21
|
+
%i[scope_class occurred_at],
|
|
22
|
+
name: "index_ct_audit_events_on_scope_class_occurred"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def down
|
|
26
|
+
change_table :command_tower_audit_events, bulk: true do |t|
|
|
27
|
+
t.remove_index name: "index_ct_audit_events_on_host_context_occurred"
|
|
28
|
+
t.remove_index name: "index_ct_audit_events_on_scope_class_occurred"
|
|
29
|
+
t.remove :scope_class
|
|
30
|
+
t.remove :host_context_type
|
|
31
|
+
t.remove :host_context_identifier
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateCommandTowerImpersonationSessions < ActiveRecord::Migration[7.2]
|
|
4
|
+
def change
|
|
5
|
+
create_table :command_tower_impersonation_sessions, id: { type: :string, limit: 36 } do |t|
|
|
6
|
+
t.bigint :actor_user_id, null: false
|
|
7
|
+
t.bigint :target_user_id, null: false
|
|
8
|
+
t.datetime :started_at, null: false
|
|
9
|
+
t.datetime :last_activity_at, null: false
|
|
10
|
+
t.datetime :absolute_expires_at, null: false
|
|
11
|
+
t.datetime :idle_expires_at, null: false
|
|
12
|
+
t.datetime :ended_at
|
|
13
|
+
t.string :end_reason, limit: 32
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
add_index :command_tower_impersonation_sessions, :actor_user_id
|
|
18
|
+
add_index :command_tower_impersonation_sessions, :target_user_id
|
|
19
|
+
add_index :command_tower_impersonation_sessions,
|
|
20
|
+
%i[actor_user_id ended_at],
|
|
21
|
+
name: "index_ct_impersonation_sessions_on_actor_ended"
|
|
22
|
+
|
|
23
|
+
add_foreign_key :command_tower_impersonation_sessions, :users, column: :actor_user_id
|
|
24
|
+
add_foreign_key :command_tower_impersonation_sessions, :users, column: :target_user_id
|
|
25
|
+
end
|
|
26
|
+
end
|