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,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module PasswordRecovery
|
|
5
|
+
module AuthorizationHelper
|
|
6
|
+
SCHEME = "Recovery"
|
|
7
|
+
HEADER = "Authorization"
|
|
8
|
+
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def extract_token(request)
|
|
12
|
+
raw = request.headers[HEADER].to_s.strip
|
|
13
|
+
return { error: :missing } if raw.blank?
|
|
14
|
+
|
|
15
|
+
match = raw.match(/\A#{SCHEME}\s+(.+)\z/i)
|
|
16
|
+
return { error: :invalid_format } unless match
|
|
17
|
+
|
|
18
|
+
token = match[1].to_s.strip
|
|
19
|
+
return { error: :missing } if token.blank?
|
|
20
|
+
|
|
21
|
+
{ token: token }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module PrincipalCapabilities
|
|
5
|
+
class Error < CommandTower::Error; end
|
|
6
|
+
|
|
7
|
+
class UnregisteredCapabilityError < Error; end
|
|
8
|
+
class DuplicateCapabilityError < Error; end
|
|
9
|
+
class HostOverrideError < Error; end
|
|
10
|
+
class InvalidCapabilityNameError < Error; end
|
|
11
|
+
class InvalidCapabilityDefinitionError < Error; end
|
|
12
|
+
class MissingRequiredEntityError < Error; end
|
|
13
|
+
class FrozenRegistryError < Error; end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "redis"
|
|
4
|
+
|
|
5
|
+
module CommandTower
|
|
6
|
+
module RedisConnection
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def current
|
|
10
|
+
@current ||= Redis.new(url: ENV.fetch("REDIS_URL"))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def with
|
|
14
|
+
yield current
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def reset!
|
|
18
|
+
@current = nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json_schematize/generator"
|
|
4
|
+
|
|
5
|
+
module CommandTower
|
|
6
|
+
module Schema
|
|
7
|
+
module Error
|
|
8
|
+
class EmailValidationRequired < JsonSchematize::Generator
|
|
9
|
+
add_field name: :status, type: String
|
|
10
|
+
add_field name: :message, type: String
|
|
11
|
+
add_field name: :meta, type: Hash
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module Schema
|
|
5
|
+
module Shared
|
|
6
|
+
class User < JsonSchematize::Generator
|
|
7
|
+
schema_default option: :dig_type, value: :string
|
|
8
|
+
|
|
9
|
+
def self.convert_user_object(user:)
|
|
10
|
+
attributes = CommandTower.config.user.default_attributes.map(&:to_s)
|
|
11
|
+
object = user.attributes.slice(*attributes)
|
|
12
|
+
|
|
13
|
+
new(object)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Gets assigned during configuration phase via
|
|
17
|
+
# lib/command_tower/configuration/user/config.rb
|
|
18
|
+
def self.assign!
|
|
19
|
+
attributes = CommandTower.config.user.default_attributes
|
|
20
|
+
|
|
21
|
+
attributes.each do |attribute|
|
|
22
|
+
if metadata = ::User.attribute_to_type_mapping[attribute]
|
|
23
|
+
type = metadata[:serialized_type] ? metadata[:serialized_type] : metadata[:base]
|
|
24
|
+
type = JsonSchematize::Boolean if type == "Boolean"
|
|
25
|
+
add_field(name: attribute, type:)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/command_tower/schema.rb
CHANGED
|
@@ -7,32 +7,9 @@ module CommandTower
|
|
|
7
7
|
|
|
8
8
|
## Generic Error Schemas
|
|
9
9
|
require "command_tower/schema/error/base"
|
|
10
|
+
require "command_tower/schema/error/email_validation_required"
|
|
10
11
|
require "command_tower/schema/error/invalid_argument_response"
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
require "command_tower/schema/plain_text/create_user_response"
|
|
14
|
-
require "command_tower/schema/plain_text/create_user_request"
|
|
15
|
-
|
|
16
|
-
require "command_tower/schema/plain_text/email_verify_request"
|
|
17
|
-
require "command_tower/schema/plain_text/email_verify_response"
|
|
18
|
-
|
|
19
|
-
require "command_tower/schema/plain_text/email_verify_send_response"
|
|
20
|
-
require "command_tower/schema/plain_text/email_verify_send_request"
|
|
21
|
-
|
|
22
|
-
require "command_tower/schema/plain_text/login_request"
|
|
23
|
-
require "command_tower/schema/plain_text/login_response"
|
|
24
|
-
|
|
25
|
-
require "command_tower/schema/admin/users"
|
|
26
|
-
|
|
27
|
-
require "command_tower/schema/user"
|
|
28
|
-
require "command_tower/schema/page"
|
|
29
|
-
|
|
30
|
-
require "command_tower/schema/inbox/metadata"
|
|
31
|
-
require "command_tower/schema/inbox/message_entity"
|
|
32
|
-
require "command_tower/schema/inbox/modified"
|
|
33
|
-
require "command_tower/schema/inbox/blast_response"
|
|
34
|
-
require "command_tower/schema/inbox/blast_request"
|
|
35
|
-
require "command_tower/schema/inbox/message_blast_entity"
|
|
36
|
-
require "command_tower/schema/inbox/message_blast_metadata"
|
|
13
|
+
require "command_tower/schema/shared/user"
|
|
37
14
|
end
|
|
38
15
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
module Signup
|
|
5
|
+
module AuthorizationHelper
|
|
6
|
+
SCHEME = "Signup"
|
|
7
|
+
HEADER = "Authorization"
|
|
8
|
+
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def extract_token(request)
|
|
12
|
+
raw = request.headers[HEADER].to_s.strip
|
|
13
|
+
return { error: :missing } if raw.blank?
|
|
14
|
+
|
|
15
|
+
match = raw.match(/\A#{SCHEME}\s+(.+)\z/i)
|
|
16
|
+
return { error: :invalid_format } unless match
|
|
17
|
+
|
|
18
|
+
token = match[1].to_s.strip
|
|
19
|
+
return { error: :missing } if token.blank?
|
|
20
|
+
|
|
21
|
+
{ token: token }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -8,12 +8,69 @@ module CommandTower
|
|
|
8
8
|
token = result.token
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
@request.headers[CommandTower::ApplicationController::AUTHENTICATION_HEADER] = "Bearer
|
|
11
|
+
@request.headers[CommandTower::ApplicationController::AUTHENTICATION_HEADER] = "Bearer #{token}"
|
|
12
12
|
@request.headers[CommandTower::ApplicationController::AUTHENTICATION_WITH_RESET] = "true" if with_reset
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def unset_jwt_token!
|
|
16
16
|
@request.headers[CommandTower::ApplicationController::AUTHENTICATION_HEADER] = nil
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
# Helper method to get login token and cookie value
|
|
20
|
+
# Uses the login service directly to avoid controller double render issues
|
|
21
|
+
# @param user [User] The user to login
|
|
22
|
+
# @param password [String] The user's password
|
|
23
|
+
# @return [Hash] Hash with :token, :cookie_value, and :cookie_header
|
|
24
|
+
def get_login_token_and_cookie(user:, password:)
|
|
25
|
+
# Authenticate user first
|
|
26
|
+
result = CommandTower::Services::Auth::PlainText::Login.(identifier: user.username, password:)
|
|
27
|
+
raise "Login failed: #{result.errors.map(&:code).join(", ")}" unless result.success?
|
|
28
|
+
|
|
29
|
+
token = result.data[:token]
|
|
30
|
+
expires_at = CommandTower.config.jwt.ttl.from_now.to_time.to_s
|
|
31
|
+
cookie_name = CommandTower.config.jwt.cookie.name
|
|
32
|
+
|
|
33
|
+
# Create a mock response to set cookie
|
|
34
|
+
mock_response = ActionDispatch::TestResponse.new
|
|
35
|
+
CommandTower::Jwt::AuthorizationHelper.set_token(mock_response, token, expires_at: expires_at)
|
|
36
|
+
cookie_header = mock_response.headers["Set-Cookie"]
|
|
37
|
+
cookie_value = cookie_header&.match(/#{cookie_name}=([^;]+)/)&.[](1)
|
|
38
|
+
|
|
39
|
+
{ token:, cookie_value:, cookie_header: }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Helper to set CSRF cookie in request
|
|
43
|
+
def set_csrf_cookie!(token)
|
|
44
|
+
csrf_cookie_name = CommandTower.config.jwt.cookie.csrf.cookie_name
|
|
45
|
+
@request.cookies[csrf_cookie_name] = token
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Helper to set CSRF header in request
|
|
49
|
+
def set_csrf_header!(token)
|
|
50
|
+
csrf_header_name = CommandTower.config.jwt.cookie.csrf.header_name
|
|
51
|
+
@request.headers[csrf_header_name] = token
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Helper to extract CSRF cookie from response
|
|
55
|
+
def extract_csrf_cookie(response)
|
|
56
|
+
csrf_cookie_name = CommandTower.config.jwt.cookie.csrf.cookie_name
|
|
57
|
+
set_cookie_header = response.headers["Set-Cookie"]
|
|
58
|
+
return nil unless set_cookie_header
|
|
59
|
+
|
|
60
|
+
# Handle both string and array (when multiple cookies are set)
|
|
61
|
+
cookie_headers = set_cookie_header.is_a?(Array) ? set_cookie_header : [set_cookie_header]
|
|
62
|
+
|
|
63
|
+
cookie_headers.each do |header|
|
|
64
|
+
match = header.match(/#{csrf_cookie_name}=([^;]+)/)
|
|
65
|
+
return match[1] if match
|
|
66
|
+
end
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Helper to get CSRF cookie value from request
|
|
71
|
+
def get_csrf_cookie_value
|
|
72
|
+
csrf_cookie_name = CommandTower.config.jwt.cookie.csrf.cookie_name
|
|
73
|
+
@request.cookies[csrf_cookie_name]
|
|
74
|
+
end
|
|
18
75
|
end
|
|
19
76
|
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CommandTower
|
|
4
|
+
# Explicit host/test entry for shared FactoryBot definitions and related
|
|
5
|
+
# testing bootstrap. Not loaded in production via Railtie.
|
|
6
|
+
module Testing
|
|
7
|
+
class << self
|
|
8
|
+
# Preferred host entry. Currently loads factories; reserved for future
|
|
9
|
+
# shared testing setup (helpers, config checks).
|
|
10
|
+
def install!
|
|
11
|
+
load_factories!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Load CommandTower FactoryBot definitions exactly once.
|
|
15
|
+
# Loads files under Engine.root/spec/factories explicitly (does not mutate
|
|
16
|
+
# global definition_file_paths / find_definitions).
|
|
17
|
+
def load_factories!
|
|
18
|
+
return if factories_loaded?
|
|
19
|
+
|
|
20
|
+
begin
|
|
21
|
+
require "factory_bot"
|
|
22
|
+
rescue LoadError
|
|
23
|
+
raise LoadError,
|
|
24
|
+
"CommandTower::Testing requires the factory_bot gem. " \
|
|
25
|
+
"Add `factory_bot` or `factory_bot_rails` to your host test group."
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
factory_files.each { |path| Kernel.load(path) }
|
|
29
|
+
@factories_loaded = true
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def factories_loaded?
|
|
34
|
+
@factories_loaded == true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Reset loader state (specs only). Does not undefine FactoryBot factories.
|
|
38
|
+
def reset_factories_loaded_flag!
|
|
39
|
+
@factories_loaded = false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Ensures COMMAND_TOWER_MESSAGING_ENDPOINT_SECRET for endpoint factories
|
|
43
|
+
# in non-production test environments when unset.
|
|
44
|
+
def ensure_endpoint_secret!
|
|
45
|
+
return unless ENV["COMMAND_TOWER_MESSAGING_ENDPOINT_SECRET"].to_s.empty?
|
|
46
|
+
|
|
47
|
+
ENV["COMMAND_TOWER_MESSAGING_ENDPOINT_SECRET"] =
|
|
48
|
+
"test-messaging-endpoint-secret-not-for-production"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def factories_path
|
|
52
|
+
CommandTower::Engine.root.join("spec/factories")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def factory_files
|
|
58
|
+
Dir[factories_path.join("**/*.rb").to_s].sort
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
data/lib/command_tower.rb
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
require "command_tower/error"
|
|
2
|
+
require "command_tower/current"
|
|
3
|
+
require "command_tower/execution"
|
|
4
|
+
require "command_tower/events"
|
|
5
|
+
require "command_tower/audit"
|
|
6
|
+
require "command_tower/impersonation/activity_declaration"
|
|
7
|
+
require "command_tower/impersonation/apply_overlay"
|
|
8
|
+
require "command_tower/impersonation/clear_overlay_for_audit"
|
|
9
|
+
require "command_tower/impersonation/establish_identity"
|
|
10
|
+
require "command_tower/admin_workspace"
|
|
11
|
+
require "command_tower/admin_scope"
|
|
12
|
+
require "command_tower/logging/lifecycle_declaration"
|
|
13
|
+
require "command_tower/logging/projection"
|
|
14
|
+
require "command_tower/logging/subscriber"
|
|
2
15
|
|
|
3
16
|
require "command_tower/version"
|
|
4
17
|
require "command_tower/engine"
|
|
5
18
|
require "command_tower/configuration/config"
|
|
19
|
+
require "command_tower/install/baseline"
|
|
20
|
+
require "command_tower/install/doctor"
|
|
21
|
+
require "command_tower/credential_resolution"
|
|
22
|
+
require "command_tower/jwt/authorization_helper"
|
|
23
|
+
require "command_tower/jwt/csrf_helper"
|
|
24
|
+
require "command_tower/password_recovery/authorization_helper"
|
|
25
|
+
require "command_tower/redis_connection"
|
|
26
|
+
require "command_tower/signup/authorization_helper"
|
|
6
27
|
|
|
7
28
|
module CommandTower
|
|
8
29
|
def self.config
|
|
@@ -11,6 +32,7 @@ module CommandTower
|
|
|
11
32
|
|
|
12
33
|
def self.configure
|
|
13
34
|
yield(config)
|
|
35
|
+
CredentialResolution::SmtpActionMailerBridge.apply!
|
|
14
36
|
end
|
|
15
37
|
|
|
16
38
|
def self.config=(configuration)
|
|
@@ -19,6 +41,16 @@ module CommandTower
|
|
|
19
41
|
@config = configuration
|
|
20
42
|
end
|
|
21
43
|
|
|
44
|
+
# Optional custom credential resolver (#resolve(provider) → typed credentials).
|
|
45
|
+
# Precedence: config.credentials.* → credential_resolver → ENV.
|
|
46
|
+
def self.credential_resolver
|
|
47
|
+
@credential_resolver
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.credential_resolver=(resolver)
|
|
51
|
+
@credential_resolver = resolver
|
|
52
|
+
end
|
|
53
|
+
|
|
22
54
|
def self.app_name
|
|
23
55
|
Proc === config.app.app_name ? config.app.app_name.() : config.app.app_name
|
|
24
56
|
end
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
Description:
|
|
2
|
-
Creates a default
|
|
2
|
+
Creates a default CommandTower initializer and optionally mounts the engine.
|
|
3
|
+
|
|
4
|
+
Prefer the productized install entry point for new hosts:
|
|
5
|
+
|
|
6
|
+
bin/rails command_tower:install
|
|
7
|
+
bin/rails db:migrate
|
|
8
|
+
|
|
9
|
+
This generator is still available for initializer/route scaffolding alone.
|
|
3
10
|
|
|
4
11
|
Example:
|
|
5
12
|
bin/rails generate command_tower:configure
|
|
13
|
+
bin/rails generate command_tower:configure --skip-routes
|
|
14
|
+
bin/rails generate command_tower:configure --force
|
|
6
15
|
|
|
7
|
-
This will create:
|
|
16
|
+
This will create (unless already present without --force):
|
|
8
17
|
config/initializers/command_tower.rb
|
|
18
|
+
|
|
19
|
+
And mount (unless --skip-routes or already mounted):
|
|
20
|
+
mount CommandTower::Engine => "/"
|
|
@@ -1,12 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class CommandTower::ConfigureGenerator < Rails::Generators::Base
|
|
2
4
|
source_root File.expand_path("templates", __dir__)
|
|
3
5
|
|
|
6
|
+
class_option :skip_routes,
|
|
7
|
+
type: :boolean,
|
|
8
|
+
default: false,
|
|
9
|
+
desc: "Do not mount CommandTower::Engine in config/routes.rb"
|
|
10
|
+
|
|
11
|
+
class_option :force,
|
|
12
|
+
type: :boolean,
|
|
13
|
+
default: false,
|
|
14
|
+
desc: "Overwrite an existing config/initializers/command_tower.rb"
|
|
15
|
+
|
|
4
16
|
def create_config_file
|
|
5
|
-
|
|
17
|
+
relative = "config/initializers/command_tower.rb"
|
|
18
|
+
path = File.join(destination_root, relative)
|
|
19
|
+
if File.exist?(path) && !options[:force]
|
|
20
|
+
say_status :skip, "#{relative} (already present; pass --force to overwrite)", :yellow
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_file relative,
|
|
6
25
|
CommandTower.config.class.composer_generate_config(wrapping: "CommandTower.configure", require_file: "command_tower")
|
|
7
26
|
end
|
|
8
27
|
|
|
9
28
|
def create_route
|
|
10
|
-
|
|
29
|
+
return if options[:skip_routes]
|
|
30
|
+
|
|
31
|
+
routes_path = File.join(destination_root, "config/routes.rb")
|
|
32
|
+
if File.exist?(routes_path) && File.read(routes_path).include?("CommandTower::Engine")
|
|
33
|
+
say_status :skip, "config/routes.rb (CommandTower::Engine already mounted)", :yellow
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
route 'mount CommandTower::Engine => "/"'
|
|
11
38
|
end
|
|
12
39
|
end
|
|
@@ -2,59 +2,27 @@
|
|
|
2
2
|
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
|
3
3
|
# NOTE: to have a dev-mode tool do its thing in production.
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'model_dir' => 'app/models',
|
|
26
|
-
'root_dir' => '',
|
|
27
|
-
'include_version' => 'false',
|
|
28
|
-
'require' => '',
|
|
29
|
-
'exclude_tests' => 'false',
|
|
30
|
-
'exclude_fixtures' => 'false',
|
|
31
|
-
'exclude_factories' => 'false',
|
|
32
|
-
'exclude_serializers' => 'false',
|
|
33
|
-
'exclude_scaffolds' => 'true',
|
|
34
|
-
'exclude_controllers' => 'true',
|
|
35
|
-
'exclude_helpers' => 'true',
|
|
36
|
-
'exclude_sti_subclasses' => 'false',
|
|
37
|
-
'ignore_model_sub_dir' => 'false',
|
|
38
|
-
'ignore_columns' => nil,
|
|
39
|
-
'ignore_routes' => nil,
|
|
40
|
-
'ignore_unknown_models' => 'false',
|
|
41
|
-
'hide_limit_column_types' => 'integer,bigint,boolean',
|
|
42
|
-
'hide_default_column_types' => 'json,jsonb,hstore',
|
|
43
|
-
'skip_on_db_migrate' => 'false',
|
|
44
|
-
'format_bare' => 'true',
|
|
45
|
-
'format_rdoc' => 'false',
|
|
46
|
-
'format_yard' => 'false',
|
|
47
|
-
'format_markdown' => 'false',
|
|
48
|
-
'sort' => 'false',
|
|
49
|
-
'force' => 'false',
|
|
50
|
-
'frozen' => 'false',
|
|
51
|
-
'classified_sort' => 'true',
|
|
52
|
-
'trace' => 'false',
|
|
53
|
-
'wrapper_open' => nil,
|
|
54
|
-
'wrapper_close' => nil,
|
|
55
|
-
'with_comment' => 'true'
|
|
56
|
-
)
|
|
57
|
-
end
|
|
5
|
+
# Engine rake layout exposes annotate as app:annotate_models; skip auto-hook on
|
|
6
|
+
# db:migrate so migrate does not fail looking for top-level annotate_models.
|
|
7
|
+
# Annotate is a CommandTower *development* dependency of the gem repo, not a
|
|
8
|
+
# runtime dependency for downstream hosts — guard the require.
|
|
9
|
+
if Rails.env.development?
|
|
10
|
+
begin
|
|
11
|
+
require "annotate"
|
|
12
|
+
rescue LoadError
|
|
13
|
+
# Host applications without the annotate gem skip model annotation hooks.
|
|
14
|
+
else
|
|
15
|
+
task :set_annotation_options do
|
|
16
|
+
Annotate.set_defaults(
|
|
17
|
+
"active_admin" => "false",
|
|
18
|
+
"models" => "true",
|
|
19
|
+
"model_dir" => "app/models",
|
|
20
|
+
"skip_on_db_migrate" => "true",
|
|
21
|
+
"show_foreign_keys" => "true",
|
|
22
|
+
"show_indexes" => "true"
|
|
23
|
+
)
|
|
24
|
+
end
|
|
58
25
|
|
|
59
|
-
|
|
60
|
-
|
|
26
|
+
Annotate.load_tasks
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "command_tower/install/doctor"
|
|
4
|
+
|
|
5
|
+
namespace :command_tower do
|
|
6
|
+
desc "Install CommandTower into the host (migrations + optional configure). Does not run db:migrate."
|
|
7
|
+
task install: :environment do
|
|
8
|
+
puts
|
|
9
|
+
puts "=== CommandTower install ==="
|
|
10
|
+
puts
|
|
11
|
+
|
|
12
|
+
puts "→ Installing engine migrations (Rails-native)…"
|
|
13
|
+
Rake::Task["command_tower:install:migrations"].reenable
|
|
14
|
+
Rake::Task["command_tower:install:migrations"].invoke
|
|
15
|
+
puts
|
|
16
|
+
|
|
17
|
+
skip_configure = %w[1 true yes].include?(ENV["SKIP_CONFIGURE"].to_s.downcase)
|
|
18
|
+
if skip_configure
|
|
19
|
+
puts "→ Skipping configure generator (SKIP_CONFIGURE=#{ENV['SKIP_CONFIGURE']})"
|
|
20
|
+
else
|
|
21
|
+
puts "→ Generating initializer / routes (command_tower:configure)…"
|
|
22
|
+
require "rails/generators"
|
|
23
|
+
generator_args = []
|
|
24
|
+
generator_args << "--skip-routes" if %w[1 true yes].include?(ENV["SKIP_MOUNT"].to_s.downcase)
|
|
25
|
+
generator_args << "--force" if %w[1 true yes].include?(ENV["FORCE"].to_s.downcase)
|
|
26
|
+
Rails::Generators.invoke("command_tower:configure", generator_args)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
puts
|
|
30
|
+
puts "=== Next steps ==="
|
|
31
|
+
puts " 1. Review config/initializers/command_tower.rb (required secrets, optional features)."
|
|
32
|
+
puts " 2. bin/rails db:migrate"
|
|
33
|
+
puts " 3. bin/rails command_tower:doctor"
|
|
34
|
+
puts " 4. Optionally: bin/rails command_tower:users:create"
|
|
35
|
+
puts
|
|
36
|
+
puts "Docs: see the CommandTower gem docs/initializing.md (packaged with the gem)."
|
|
37
|
+
puts "Upgrades: bump the gem, then bin/rails command_tower:install:migrations && bin/rails db:migrate"
|
|
38
|
+
puts " (or: SKIP_CONFIGURE=1 bin/rails command_tower:install)."
|
|
39
|
+
puts
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc "Validate CommandTower host setup (secrets, migrations, Rails version)"
|
|
43
|
+
task doctor: :environment do
|
|
44
|
+
require "command_tower/install/doctor"
|
|
45
|
+
|
|
46
|
+
puts
|
|
47
|
+
puts "=== CommandTower doctor ==="
|
|
48
|
+
puts
|
|
49
|
+
|
|
50
|
+
findings = CommandTower::Install::Doctor.new.run
|
|
51
|
+
failures = 0
|
|
52
|
+
warnings = 0
|
|
53
|
+
|
|
54
|
+
findings.each do |finding|
|
|
55
|
+
icon =
|
|
56
|
+
case finding.severity
|
|
57
|
+
when :pass then "[pass]"
|
|
58
|
+
when :warn then "[warn]"
|
|
59
|
+
when :fail then "[fail]"
|
|
60
|
+
else "[????]"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
failures += 1 if finding.severity == :fail
|
|
64
|
+
warnings += 1 if finding.severity == :warn
|
|
65
|
+
|
|
66
|
+
puts "#{icon} #{finding.message}"
|
|
67
|
+
puts " → #{finding.remediation}" if finding.remediation
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
puts
|
|
71
|
+
if failures.positive?
|
|
72
|
+
puts "Doctor found #{failures} failure(s) and #{warnings} warning(s)."
|
|
73
|
+
abort("CommandTower doctor failed")
|
|
74
|
+
elsif warnings.positive?
|
|
75
|
+
puts "Doctor passed with #{warnings} warning(s)."
|
|
76
|
+
else
|
|
77
|
+
puts "Doctor passed."
|
|
78
|
+
end
|
|
79
|
+
puts
|
|
80
|
+
end
|
|
81
|
+
end
|