command_tower 0.24.0 → 0.25.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/app/auth/command_tower/auth/auth_context.rb +17 -4
- data/app/controllers/command_tower/admin/users/impersonation_sessions_controller.rb +2 -1
- data/app/controllers/command_tower/application_controller.rb +18 -1
- data/app/controllers/command_tower/auth/email/availability_controller.rb +1 -0
- data/app/controllers/command_tower/auth/impersonation_session_controller.rb +2 -1
- data/app/controllers/command_tower/auth/password_check_controller.rb +31 -0
- data/app/controllers/command_tower/auth/password_recovery_session/create_controller.rb +3 -0
- data/app/controllers/command_tower/auth/password_reset/reset_controller.rb +4 -1
- data/app/controllers/command_tower/auth/password_reset/send_controller.rb +6 -2
- data/app/controllers/command_tower/auth/password_reset/validate_controller.rb +4 -1
- data/app/controllers/command_tower/auth/plain_text/login_controller.rb +2 -1
- data/app/controllers/command_tower/auth/register_controller.rb +9 -0
- data/app/controllers/command_tower/auth/signup_session/create_controller.rb +3 -0
- data/app/controllers/command_tower/auth/username/availability_controller.rb +1 -0
- data/app/controllers/command_tower/me/username_availability_controller.rb +37 -0
- data/app/controllers/command_tower/me/username_controller.rb +38 -0
- data/app/controllers/concerns/command_tower/api/application_response_renderer.rb +30 -6
- data/app/controllers/concerns/command_tower/auth/legacy_contract_boundary.rb +24 -0
- data/app/controllers/concerns/command_tower/auth/password_recovery_session_boundary.rb +2 -0
- data/app/controllers/concerns/command_tower/auth/signup_session_boundary.rb +2 -0
- data/app/controllers/concerns/command_tower/execution/http_boundary.rb +22 -1
- data/app/deserializers/command_tower/deserializers/auth/password_check_deserializer.rb +21 -0
- data/app/deserializers/command_tower/deserializers/auth/password_reset/reset_deserializer.rb +3 -2
- data/app/deserializers/command_tower/deserializers/auth/register_deserializer.rb +10 -12
- data/app/deserializers/command_tower/deserializers/me/change_password_deserializer.rb +6 -4
- data/app/deserializers/command_tower/deserializers/me/update_username_deserializer.rb +21 -0
- data/app/errors/command_tower/errors/account/username_change_not_allowed_error.rb +17 -0
- data/app/errors/command_tower/errors/account/username_taken_error.rb +21 -0
- data/app/errors/command_tower/errors/auth/auth_rate_limited_error.rb +25 -0
- data/app/errors/command_tower/errors/auth/session_expired_error.rb +18 -0
- data/app/errors/command_tower/errors/auth/session_revoked_error.rb +18 -0
- data/app/errors/command_tower/errors/insecure_jwt_secret_error.rb +22 -0
- data/app/jobs/command_tower/auth/device_sessions/purge_ended_job.rb +16 -0
- data/app/jobs/command_tower/auth/email_verification/issue_job.rb +23 -0
- data/app/jobs/command_tower/auth/password_reset/issue_job.rb +23 -0
- data/app/models/command_tower/auth/device_session.rb +32 -0
- data/app/models/user.rb +10 -1
- data/app/models/user_secret.rb +17 -4
- data/app/serializers/command_tower/serializers/auth/email_verification/message_response_serializer.rb +5 -2
- data/app/serializers/command_tower/serializers/auth/identity_policy_serializer.rb +16 -3
- data/app/serializers/command_tower/serializers/auth/login_response_serializer.rb +6 -6
- data/app/serializers/command_tower/serializers/auth/password_check_serializer.rb +17 -0
- data/app/serializers/command_tower/serializers/auth/register_response_serializer.rb +11 -2
- data/app/services/command_tower/jwt/authenticate_user.rb +140 -19
- data/app/services/command_tower/jwt/authentication_outcome.rb +30 -6
- data/app/services/command_tower/jwt/login_create.rb +4 -3
- data/app/services/command_tower/secrets/generate.rb +8 -5
- data/app/services/command_tower/secrets/verify.rb +6 -5
- data/app/services/command_tower/services/account/phone_verification/verify.rb +1 -1
- data/app/services/command_tower/services/auth/authenticate_session.rb +15 -1
- data/app/services/command_tower/services/auth/device_sessions/revoke_all.rb +27 -0
- data/app/services/command_tower/services/auth/device_sessions/start.rb +52 -0
- data/app/services/command_tower/services/auth/device_sessions/upgrade_legacy.rb +44 -0
- data/app/services/command_tower/services/auth/email_verification/send.rb +23 -29
- data/app/services/command_tower/services/auth/email_verification/verify.rb +6 -0
- data/app/services/command_tower/services/auth/identity_policy.rb +63 -17
- data/app/services/command_tower/services/auth/identity_rate_limits/check_reset_attempt.rb +40 -0
- data/app/services/command_tower/services/auth/identity_rate_limits/check_verification_send.rb +61 -0
- data/app/services/command_tower/services/auth/identity_rate_limits/check_verify_attempt.rb +39 -0
- data/app/services/command_tower/services/auth/issue_session.rb +62 -0
- data/app/services/command_tower/services/auth/login_rate_limits/check_ip.rb +38 -0
- data/app/services/command_tower/services/auth/login_rate_limits/enforcement.rb +33 -0
- data/app/services/command_tower/services/auth/login_rate_limits/fail_open.rb +50 -0
- data/app/services/command_tower/services/auth/login_rate_limits/lockout.rb +131 -0
- data/app/services/command_tower/services/auth/omit_body_token.rb +30 -0
- data/app/services/command_tower/services/auth/password_policy/check.rb +45 -0
- data/app/services/command_tower/services/auth/password_policy/check_rate_limit.rb +38 -0
- data/app/services/command_tower/services/auth/password_recovery/rate_limits/check_send.rb +16 -13
- data/app/services/command_tower/services/auth/password_reset/reset.rb +21 -14
- data/app/services/command_tower/services/auth/password_reset/send.rb +9 -42
- data/app/services/command_tower/services/auth/password_reset/token_verification.rb +9 -1
- data/app/services/command_tower/services/auth/password_reset/validate.rb +3 -0
- data/app/services/command_tower/services/auth/plain_text/login.rb +68 -11
- data/app/services/command_tower/services/auth/record_legacy_contract_use.rb +28 -0
- data/app/services/command_tower/services/auth/register.rb +19 -13
- data/app/services/command_tower/services/auth/signup_rate_limits/check_register_email.rb +39 -0
- data/app/services/command_tower/services/auth/tombstone_user.rb +1 -0
- data/app/services/command_tower/services/me/capabilities.rb +1 -1
- data/app/services/command_tower/services/me/change_password.rb +10 -8
- data/app/services/command_tower/services/me/set_username.rb +100 -0
- data/app/services/command_tower/services/me/username_change_eligibility.rb +34 -0
- data/app/services/command_tower/services/rate_limits/check.rb +1 -1
- data/app/services/command_tower/services/rate_limits/clear.rb +18 -0
- data/app/services/command_tower/services/rate_limits/peek.rb +23 -0
- data/app/services/command_tower/user_attributes/mutate.rb +1 -0
- data/app/services/command_tower/username/available.rb +1 -1
- data/app/workflows/command_tower/workflows/auth/authentication_response_effects.rb +11 -0
- data/app/workflows/command_tower/workflows/auth/device_sessions/purge_ended_workflow.rb +44 -0
- data/app/workflows/command_tower/workflows/auth/email_verification/issue_workflow.rb +64 -0
- data/app/workflows/command_tower/workflows/auth/email_verification/send_workflow.rb +4 -2
- data/app/workflows/command_tower/workflows/auth/identity_error_status.rb +2 -1
- data/app/workflows/command_tower/workflows/auth/logout_workflow.rb +12 -0
- data/app/workflows/command_tower/workflows/auth/password_check_workflow.rb +34 -0
- data/app/workflows/command_tower/workflows/auth/password_reset/issue_workflow.rb +62 -0
- data/app/workflows/command_tower/workflows/auth/password_reset/reset_workflow.rb +3 -2
- data/app/workflows/command_tower/workflows/auth/password_reset/send_workflow.rb +3 -2
- data/app/workflows/command_tower/workflows/auth/password_reset/validate_workflow.rb +3 -2
- data/app/workflows/command_tower/workflows/auth/plain_text/login_workflow.rb +27 -8
- data/app/workflows/command_tower/workflows/auth/register_session_response.rb +54 -0
- data/app/workflows/command_tower/workflows/auth/register_workflow.rb +64 -56
- data/app/workflows/command_tower/workflows/auth/session/show_workflow.rb +54 -5
- data/app/workflows/command_tower/workflows/auth/session_error_status.rb +4 -0
- data/app/workflows/command_tower/workflows/auth/signup_error_status.rb +2 -1
- data/app/workflows/command_tower/workflows/impersonation/start_workflow.rb +5 -2
- data/app/workflows/command_tower/workflows/impersonation/stop_workflow.rb +4 -2
- data/app/workflows/command_tower/workflows/me/error_status.rb +2 -0
- data/app/workflows/command_tower/workflows/me/username_availability_workflow.rb +77 -0
- data/app/workflows/command_tower/workflows/me/username_workflow.rb +47 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20261124000002_add_secret_digest_to_user_secrets.rb +8 -0
- data/db/migrate/20261124000003_create_command_tower_device_sessions.rb +43 -0
- data/docs/api_reference.md +74 -15
- data/docs/audit.md +1 -0
- data/docs/authentication.md +103 -0
- data/docs/bootstrap/08-initializer.md +12 -0
- data/docs/bootstrap/09-rbac.md +2 -0
- data/docs/bootstrap/11-auth-client-path.md +3 -1
- data/docs/change_password_workflow.md +6 -4
- data/docs/cookie_authentication_guide.md +17 -1
- data/docs/email_verification_workflow.md +6 -0
- data/docs/password_reset_workflow.md +10 -2
- data/docs/upgrades/0.25.0.md +50 -0
- data/docs/upgrades/README.md +2 -0
- data/lib/command_tower/authorization/default.yml +6 -0
- data/lib/command_tower/configuration/config.rb +6 -0
- data/lib/command_tower/configuration/jwt/config.rb +23 -1
- data/lib/command_tower/configuration/login/config.rb +14 -0
- data/lib/command_tower/configuration/login/rate_limits.rb +125 -0
- data/lib/command_tower/configuration/login/strategy/plain_text/config.rb +12 -6
- data/lib/command_tower/configuration/login/strategy/plain_text/lockable.rb +14 -2
- data/lib/command_tower/configuration/registry/audit/config.rb +14 -0
- data/lib/command_tower/configuration/registry/client_compatibility/config.rb +5 -3
- data/lib/command_tower/configuration/session/config.rb +61 -0
- data/lib/command_tower/configuration/username/config.rb +17 -0
- data/lib/command_tower/current.rb +4 -0
- data/lib/command_tower/data/NOTICE +8 -0
- data/lib/command_tower/data/password-blocklist-100k.txt.gz +0 -0
- data/lib/command_tower/engine.rb +1 -0
- data/lib/command_tower/execution.rb +5 -1
- data/lib/command_tower/install/baseline.rb +2 -0
- data/lib/command_tower/jwt/authorization_helper.rb +14 -6
- data/lib/command_tower/password_policy/blocklist.rb +53 -0
- data/lib/command_tower/version.rb +1 -1
- data/lib/command_tower.rb +1 -0
- data/lib/tasks/user_secrets.rake +21 -0
- data/lib/tasks/users.rake +71 -0
- data/spec/factories/device_session.rb +14 -0
- data/spec/factories/user_secret.rb +5 -1
- metadata +55 -1
|
@@ -43,6 +43,12 @@ No body typically required (uses `current_user`). Returns a message payload on s
|
|
|
43
43
|
|
|
44
44
|
On success, marks the user’s email validated.
|
|
45
45
|
|
|
46
|
+
## Delivery and code storage
|
|
47
|
+
|
|
48
|
+
- With `config.login.mail_delivery = :later` (default) `send` enqueues `CommandTower::Auth::EmailVerification::IssueJob`, which takes only the `user_id`; the code is generated and mailed inside the job and never travels through the queue or logs. `:inline` runs the job in the request, and a delivery failure then surfaces as `VerificationSendFailedError`. See [bootstrap 08](bootstrap/08-initializer.md).
|
|
49
|
+
- Already-verified users get the "already verified" message and no job is enqueued.
|
|
50
|
+
- Codes are stored as an HMAC digest (`user_secrets.secret_digest`) and looked up by digest; no plaintext is written. Legacy plaintext rows are cleared with `command_tower:user_secrets:clear_plaintext`.
|
|
51
|
+
|
|
46
52
|
## Errors
|
|
47
53
|
|
|
48
54
|
Standard application envelope. Invalid codes and validation failures map through Auth identity error status helpers. See [API reference](api_reference.md) for envelope shape.
|
|
@@ -30,7 +30,7 @@ All listed workflows inherit `ApplicationWorkflow` with `retry_strategy :none`.
|
|
|
30
30
|
|
|
31
31
|
`POST /auth/password-recovery-session`
|
|
32
32
|
|
|
33
|
-
Establishes the recovery session used by subsequent reset calls. See request specs under `spec/requests/` for exact payload/envelope.
|
|
33
|
+
**Deprecated:** each call emits `auth.legacy_contract_used` (see the [0.25.0 upgrade guide](upgrades/0.25.0.md)). Establishes the recovery session used by subsequent reset calls. See request specs under `spec/requests/` for exact payload/envelope.
|
|
34
34
|
|
|
35
35
|
### 2. Send reset email
|
|
36
36
|
|
|
@@ -58,12 +58,20 @@ Establishes the recovery session used by subsequent reset calls. See request spe
|
|
|
58
58
|
|
|
59
59
|
**Auth:** Public (reset token in body)
|
|
60
60
|
|
|
61
|
-
**Body (typical):** token +
|
|
61
|
+
**Body (typical):** `token` + `password`. `passwordConfirmation` / `password_confirmation` is optional; when sent it must match `password`, otherwise the request fails with `422`.
|
|
62
62
|
|
|
63
63
|
**Workflow:** `ResetWorkflow`
|
|
64
64
|
|
|
65
|
+
On success the reset also revokes all of the user's device sessions (`RevokeAll`, reason `password_reset`), so every signed-in device must sign in again. See [Authentication](authentication.md#session-lifecycle).
|
|
66
|
+
|
|
65
67
|
Success behavior and verifier rotation differ from authenticated [change password](change_password_workflow.md) — treat recovery success per product policy (often force Sign In).
|
|
66
68
|
|
|
69
|
+
## Delivery and token storage
|
|
70
|
+
|
|
71
|
+
- **Neutral response:** `send` always enqueues exactly one `CommandTower::Auth::PasswordReset::IssueJob` for a well-formed email, known account or not, and returns the same 200 message. Request-side work does not vary with account existence.
|
|
72
|
+
- **Off the request path:** with `config.login.mail_delivery = :later` (default) the job runs on ActiveJob; `:inline` performs it in the request (see [bootstrap 08](bootstrap/08-initializer.md)). The job's only argument is the normalized email (`log_arguments = false`); the token is generated inside `Workflows::Auth::PasswordReset::IssueWorkflow` and never travels through the queue or logs. Unknown accounts and delivery failures are logged by identifier and swallowed.
|
|
73
|
+
- **Hashed tokens:** reset tokens are stored as an HMAC digest (`user_secrets.secret_digest`) and looked up by digest; no plaintext is written. Rows created before this change keep working and are cleared with `command_tower:user_secrets:clear_plaintext` (idempotent, batched).
|
|
74
|
+
|
|
67
75
|
## Errors
|
|
68
76
|
|
|
69
77
|
Failures return the standard application envelope via `render_application_result`. Status mapping uses Auth identity/password-reset error helpers. Validation failures from deserializers typically surface as `422 Unprocessable Entity`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Upgrade: CommandTower 0.25.0 (draft)
|
|
2
|
+
|
|
3
|
+
**From:** `0.24.0`
|
|
4
|
+
**To:** `0.25.0`
|
|
5
|
+
|
|
6
|
+
Draft. Logins now start a device session; tokens carry a `sid` and the session row decides expiry. See [authentication](../authentication.md#device-sessions).
|
|
7
|
+
|
|
8
|
+
## Host-visible changes
|
|
9
|
+
|
|
10
|
+
| Change | Host impact |
|
|
11
|
+
|--------|-------------|
|
|
12
|
+
| Migration `CreateCommandTowerDeviceSessions` | New table `command_tower_device_sessions` with a foreign key to `users`. Additive and reversible. |
|
|
13
|
+
| `config.session.*` | `idle_timeout` (30 days), `absolute_timeout` (90 days), `last_seen_write_interval` (5 minutes), `enforce` (ENV `COMMAND_TOWER_SESSION_ENFORCE`), `upgrade_legacy_tokens` (ENV `COMMAND_TOWER_SESSION_UPGRADE_LEGACY_TOKENS`, not yet acted on). |
|
|
14
|
+
| New 401 codes | `session_expired` and `session_revoked` use the envelope `{ "data": null, "errors": [{ "code", "message" }] }`. Other 401 bodies are unchanged. |
|
|
15
|
+
| Session tokens outlive `jwt.ttl` | A token with `sid` is valid until the session's idle or absolute limit, not 7 days. Sid-less tokens keep the old rule. |
|
|
16
|
+
| Refresh header | `X-Authorization-With-Reset` is emitted only for bearer-sourced requests, at most once. Cookie-sourced refreshes set the cookie only. |
|
|
17
|
+
| Inclusive length bounds | `password_length_min/max` and `email_length_min/max` are now inclusive. Defaults change to password 8–64 and email 3–254 (email was 8–64 exclusive, so 9–63). A host that set explicit values should re-check them; `GET /auth/identity-policy` now serves the configured values unadjusted. |
|
|
18
|
+
| Common-password blocklist | Register, password reset and `PATCH /me/password` reject passwords in the bundled top-100k list. Override with `config.login.plain_text.password_blocklist_paths`. |
|
|
19
|
+
| Email rules | `User` normalizes `email` (strip, downcase) and validates format and length on change. |
|
|
20
|
+
| Identity policy v2 | `GET /auth/identity-policy` adds `maxBytes`, `passwordRules`, `rules` (`{ id, label, check }`) and username `selfService` / `selfChange` / `prompt` (`config.username.self_service`, `self_change`, `prompt`). Existing keys are unchanged. |
|
|
21
|
+
| `POST /auth/password-check` | New public route, 60 per minute per IP. See [api_reference](../api_reference.md#post-authpassword-check). |
|
|
22
|
+
| `POST /auth/register` | Needs only `email` and `password`; optional `start_session: true` returns a login-shaped session (`tokenExpiresAt`, `token` unless the cookie-mode web rule omits it). The six-field body still works. Policy failures add `passwordRulesFailed`; an existing email answers with a friendly message; a per-email bucket (`config.login.rate_limits.register_attempts_per_email`, default 5 per hour, `0` disables) and `retry_after_seconds` on `signup_ip_rate_limited` are new. |
|
|
23
|
+
| Optional password confirmation | `POST /auth/password-reset/reset` and `PATCH /me/password` accept a request without `passwordConfirmation`; when sent it must still match. |
|
|
24
|
+
| Deprecated endpoints | `signup-session`, `password-recovery-session`, `email/availability`, `username/availability`, the `Signup` / `Recovery` authorization schemes, the old register shape and valid sid-less tokens each emit `command_tower.auth.legacy_contract_used` (payload: `endpoint`, `app_version`, `platform`; observation only, responses unchanged). Use it to decide when old clients are gone. |
|
|
25
|
+
| Client compatibility contract | `auth.device_session` is seeded in the client-compatibility registry (observe mode, inert until the host binds per-platform minimums). |
|
|
26
|
+
| Email rake tasks | `command_tower:users:email_duplicates` (read-only report, includes blank emails), `command_tower:users:add_email_unique_index` (skips with a warning and an `email_unique_index_skipped` event when duplicates exist) and `command_tower:users:normalize_emails` (`DRY_RUN=1` to only report; skips collisions). No migration ships; run these on the host database. |
|
|
27
|
+
| One extra read per request | Authenticating a `sid` token reads one `command_tower_device_sessions` row, plus at most one `last_seen_at` write per interval. |
|
|
28
|
+
|
|
29
|
+
## Host seams
|
|
30
|
+
|
|
31
|
+
- `CommandTower::Jwt::LoginCreate.call(user:, impersonation_session_id: nil, device_session: nil)`: the optional `device_session:` adds the `sid` claim. Hosts that call or wrap it to mint tokens should use `Services::Auth::IssueSession` so a session exists.
|
|
32
|
+
- `CommandTower::Jwt::AuthenticateUser` returns an `AuthenticationOutcome` with new `code` and `device_session` readers. `AuthContext` gains `device_session` and `legacy_token`.
|
|
33
|
+
- Plain-text login now issues its token through `IssueSession`.
|
|
34
|
+
|
|
35
|
+
## Host actions
|
|
36
|
+
|
|
37
|
+
1. Bump the gem and run `db:migrate` before the new code serves traffic.
|
|
38
|
+
2. Check host clients and proxies that treat any 401 the same: two new 401 codes now exist.
|
|
39
|
+
3. If the host reads `X-Authorization-With-Reset` on cookie requests, switch to the cookie.
|
|
40
|
+
4. Kill switch: set `COMMAND_TOWER_SESSION_ENFORCE=false` to skip revoked and idle checks without a deploy.
|
|
41
|
+
5. Set `config.session.omit_body_token_min_app_version` for the host (or `COMMAND_TOWER_SESSION_OMIT_BODY_TOKEN=false`) **before** upgrading. The gem default is `"0.4.0"` and is compared with the host app's `X-App-Version`, not the frontend package version. A host app above `0.4.0` (DoubleFloor Me is `1.0.0`) otherwise gets the body token omitted for every web client on upgrade. Set it to the first app version whose web client works from the cookie alone. See [authentication](../authentication.md#body-token-omission-host-obligation).
|
|
42
|
+
|
|
43
|
+
## Rolling deploy
|
|
44
|
+
|
|
45
|
+
Migrate first, then roll. Old nodes mint sid-less tokens, which new nodes accept under the old rule. New-node tokens carry `sid`; an old node ignores that claim and applies `jwt.ttl`.
|
|
46
|
+
|
|
47
|
+
## Not in this release
|
|
48
|
+
|
|
49
|
+
- Logout, revoke-all and purge of ended sessions.
|
|
50
|
+
- Installation-id capture and legacy token upgrade.
|
data/docs/upgrades/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Host-facing upgrade / change summaries for CommandTower releases.
|
|
|
4
4
|
|
|
5
5
|
| Version | Summary |
|
|
6
6
|
|---------|---------|
|
|
7
|
+
| [0.25.0](0.25.0.md) (draft) | Device sessions: `command_tower_device_sessions` migration, `config.session.*`, `sid` token claim, `session_expired` / `session_revoked` 401 codes |
|
|
8
|
+
| [0.24.0](0.24.0.md) | Home Notices: `Campaign` / `Delivery` notices (blocking or dismissible), `command_tower_home_notices` and `command_tower_home_notice_controls` migrations, `config.home_notices`, `me_home_notices` / `admin_home_notices_kill` RBAC |
|
|
7
9
|
| [0.23.0](0.23.0.md) | Message definitions: `MessageDefinition` / `AnnouncementDefinition`, composer-built email with compliance footer and one-click unsubscribe, shared email token file, first-view inbox audit, `X-Time-Zone` writer, admin message gallery and test send; `no-store` on inbox reads; one additive migration |
|
|
8
10
|
| [0.22.0](0.22.0.md) | Server-driven UI document library (`CommandTower::UI`), legacy mapping, email renderer; `X-UI-Catalog` header read into `Current.ui_catalog` (no behavior change) |
|
|
9
11
|
| [0.21.0](0.21.0.md) | Notification preference reads: channel catalog, destinations, settings rows; PATCH merges onto stored member state |
|
|
@@ -22,6 +22,12 @@ entities:
|
|
|
22
22
|
- name: me_name
|
|
23
23
|
controller: CommandTower::Me::NameController
|
|
24
24
|
only: update
|
|
25
|
+
- name: me_username
|
|
26
|
+
controller: CommandTower::Me::UsernameController
|
|
27
|
+
only: update
|
|
28
|
+
- name: me_username_availability
|
|
29
|
+
controller: CommandTower::Me::UsernameAvailabilityController
|
|
30
|
+
only: show
|
|
25
31
|
- name: me_password
|
|
26
32
|
controller: CommandTower::Me::PasswordController
|
|
27
33
|
only: update
|
|
@@ -22,6 +22,7 @@ require "command_tower/configuration/otp/config"
|
|
|
22
22
|
require "command_tower/configuration/pagination/config"
|
|
23
23
|
require "command_tower/configuration/password_recovery_session/config"
|
|
24
24
|
require "command_tower/configuration/registry/config"
|
|
25
|
+
require "command_tower/configuration/session/config"
|
|
25
26
|
require "command_tower/configuration/signup_session/config"
|
|
26
27
|
require "command_tower/configuration/ui/config"
|
|
27
28
|
require "command_tower/configuration/user/config"
|
|
@@ -42,6 +43,11 @@ module CommandTower
|
|
|
42
43
|
allowed: Configuration::Jwt::Config,
|
|
43
44
|
default: Configuration::Jwt::Config.new
|
|
44
45
|
|
|
46
|
+
add_composer :session,
|
|
47
|
+
desc: "Device session timeouts, last-seen write throttle, and kill switches",
|
|
48
|
+
allowed: Configuration::Session::Config,
|
|
49
|
+
default: Configuration::Session::Config.new
|
|
50
|
+
|
|
45
51
|
add_composer :login,
|
|
46
52
|
desc: "Definition of Login Strategies.",
|
|
47
53
|
allowed: Configuration::Login::Config,
|
|
@@ -8,6 +8,9 @@ module CommandTower
|
|
|
8
8
|
class Config < ::CommandTower::Configuration::Base
|
|
9
9
|
include ClassComposer::Generator
|
|
10
10
|
|
|
11
|
+
DEFAULT_HMAC_SECRET = "Thi$IsASeccretIwi::CH&ang3"
|
|
12
|
+
ALLOW_INSECURE_ENV = "COMMAND_TOWER_ALLOW_INSECURE_JWT_SECRET"
|
|
13
|
+
|
|
11
14
|
add_composer :ttl,
|
|
12
15
|
desc: "Default TTL on how long the token is valid for",
|
|
13
16
|
allowed: ActiveSupport::Duration,
|
|
@@ -16,9 +19,28 @@ module CommandTower
|
|
|
16
19
|
add_composer :hmac_secret,
|
|
17
20
|
desc: "HMAC is the only algorithm supported. This is the secret key to encrypt he JWT token",
|
|
18
21
|
allowed: String,
|
|
19
|
-
default: ENV.fetch("SECRET_KEY_BASE",
|
|
22
|
+
default: ENV.fetch("SECRET_KEY_BASE", DEFAULT_HMAC_SECRET),
|
|
20
23
|
default_shown: "ENV.fetch(\"SECRET_KEY_BASE\",\"Thi$IsASeccretIwi::CH&ang3\")"
|
|
21
24
|
|
|
25
|
+
add_composer :allow_insecure_default_secret,
|
|
26
|
+
desc: "Escape hatch: allow non-local boot with a blank or default hmac_secret. Temporary use only",
|
|
27
|
+
allowed: [TrueClass, FalseClass],
|
|
28
|
+
default: ENV.fetch(ALLOW_INSECURE_ENV, "false") == "true",
|
|
29
|
+
default_shown: "ENV.fetch(\"#{ALLOW_INSECURE_ENV}\", \"false\") == \"true\""
|
|
30
|
+
|
|
31
|
+
def insecure_hmac_secret?
|
|
32
|
+
secret = hmac_secret.to_s
|
|
33
|
+
secret.strip.empty? || secret == DEFAULT_HMAC_SECRET
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Raises outside local environments when the secret is blank or the published default.
|
|
37
|
+
def validate_secret!(local: Rails.env.local?)
|
|
38
|
+
return if local || allow_insecure_default_secret
|
|
39
|
+
return unless insecure_hmac_secret?
|
|
40
|
+
|
|
41
|
+
raise CommandTower::Errors::InsecureJwtSecretError
|
|
42
|
+
end
|
|
43
|
+
|
|
22
44
|
add_composer_blocking :cookie,
|
|
23
45
|
desc: "HttpOnly cookie configuration for JWT token persistence",
|
|
24
46
|
composer_class: Cookie::Config,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "command_tower/configuration/login/rate_limits"
|
|
3
4
|
require "command_tower/configuration/login/strategy/plain_text/config"
|
|
4
5
|
|
|
5
6
|
module CommandTower
|
|
@@ -8,6 +9,19 @@ module CommandTower
|
|
|
8
9
|
class Config < ::CommandTower::Configuration::Base
|
|
9
10
|
include ClassComposer::Generator
|
|
10
11
|
|
|
12
|
+
add_composer :mail_delivery,
|
|
13
|
+
desc: "How auth emails (password reset) are delivered. :later enqueues an ActiveJob so the request " \
|
|
14
|
+
"never waits on mail; :inline performs the job in the request. Defaults to :later",
|
|
15
|
+
allowed: Symbol,
|
|
16
|
+
default: :later,
|
|
17
|
+
validator: ->(val) { %i[later inline].include?(val) },
|
|
18
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be :later or :inline" }
|
|
19
|
+
|
|
20
|
+
add_composer :rate_limits,
|
|
21
|
+
desc: "Login rate limit ceilings: per-account soft lockout and per client IP",
|
|
22
|
+
allowed: RateLimits,
|
|
23
|
+
default: RateLimits.new
|
|
24
|
+
|
|
11
25
|
add_composer_blocking :plain_text,
|
|
12
26
|
desc: "Login strategy for plain text authentication via User/Password combination",
|
|
13
27
|
composer_class: Strategy::PlainText::Config,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "class_composer"
|
|
4
|
+
|
|
5
|
+
module CommandTower
|
|
6
|
+
module Configuration
|
|
7
|
+
module Login
|
|
8
|
+
# Ceilings for POST /auth/plain-text/login. A value of 0 disables that bucket.
|
|
9
|
+
class RateLimits < ::CommandTower::Configuration::Base
|
|
10
|
+
include ClassComposer::Generator
|
|
11
|
+
|
|
12
|
+
LOCKOUT_KEY_PURPOSE = "command_tower.login_lockout"
|
|
13
|
+
|
|
14
|
+
add_composer :account_failures,
|
|
15
|
+
desc: "Failed logins per account (or unknown identifier) within account_window_seconds " \
|
|
16
|
+
"before a soft lock. 0 disables the lockout",
|
|
17
|
+
allowed: Integer,
|
|
18
|
+
default: 10,
|
|
19
|
+
validator: ->(val) { val >= 0 },
|
|
20
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
21
|
+
|
|
22
|
+
add_composer :account_window_seconds,
|
|
23
|
+
desc: "Window in which account_failures are counted",
|
|
24
|
+
allowed: Integer,
|
|
25
|
+
default: 15 * 60,
|
|
26
|
+
validator: ->(val) { val.positive? },
|
|
27
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
28
|
+
|
|
29
|
+
add_composer :lock_base_seconds,
|
|
30
|
+
desc: "Length of the first soft lock. Doubles each time a lock trips again " \
|
|
31
|
+
"within lock_level_window_seconds",
|
|
32
|
+
allowed: Integer,
|
|
33
|
+
default: 15 * 60,
|
|
34
|
+
validator: ->(val) { val.positive? },
|
|
35
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
36
|
+
|
|
37
|
+
add_composer :lock_max_seconds,
|
|
38
|
+
desc: "Upper bound for a soft lock. Every lock expires",
|
|
39
|
+
allowed: Integer,
|
|
40
|
+
default: 60 * 60,
|
|
41
|
+
validator: ->(val) { val.positive? },
|
|
42
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
43
|
+
|
|
44
|
+
add_composer :lock_level_window_seconds,
|
|
45
|
+
desc: "How long repeat locks are remembered when choosing the next lock length",
|
|
46
|
+
allowed: Integer,
|
|
47
|
+
default: 24 * 60 * 60,
|
|
48
|
+
validator: ->(val) { val.positive? },
|
|
49
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
50
|
+
|
|
51
|
+
add_composer :ip_attempts,
|
|
52
|
+
desc: "Login attempts per client IP within ip_window_seconds. 0 disables the bucket",
|
|
53
|
+
allowed: Integer,
|
|
54
|
+
default: 100,
|
|
55
|
+
validator: ->(val) { val >= 0 },
|
|
56
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
57
|
+
|
|
58
|
+
add_composer :ip_window_seconds,
|
|
59
|
+
desc: "Window for ip_attempts",
|
|
60
|
+
allowed: Integer,
|
|
61
|
+
default: 15 * 60,
|
|
62
|
+
validator: ->(val) { val.positive? },
|
|
63
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
64
|
+
|
|
65
|
+
add_composer :reset_attempts_per_ip,
|
|
66
|
+
desc: "Password reset token validate and redeem attempts per client IP within " \
|
|
67
|
+
"reset_window_seconds. 0 disables the bucket",
|
|
68
|
+
allowed: Integer,
|
|
69
|
+
default: 30,
|
|
70
|
+
validator: ->(val) { val >= 0 },
|
|
71
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
72
|
+
|
|
73
|
+
add_composer :reset_window_seconds,
|
|
74
|
+
desc: "Window for reset_attempts_per_ip",
|
|
75
|
+
allowed: Integer,
|
|
76
|
+
default: 15 * 60,
|
|
77
|
+
validator: ->(val) { val.positive? },
|
|
78
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
79
|
+
|
|
80
|
+
add_composer :register_attempts_per_email,
|
|
81
|
+
desc: "POST /auth/register attempts per normalized email per hour. 0 disables the bucket",
|
|
82
|
+
allowed: Integer,
|
|
83
|
+
default: 5,
|
|
84
|
+
validator: ->(val) { val >= 0 },
|
|
85
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
86
|
+
|
|
87
|
+
add_composer :verify_attempts,
|
|
88
|
+
desc: "Email verification code attempts per user within verify_window_seconds. " \
|
|
89
|
+
"0 disables the bucket",
|
|
90
|
+
allowed: Integer,
|
|
91
|
+
default: 10,
|
|
92
|
+
validator: ->(val) { val >= 0 },
|
|
93
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
94
|
+
|
|
95
|
+
add_composer :verify_window_seconds,
|
|
96
|
+
desc: "Window for verify_attempts",
|
|
97
|
+
allowed: Integer,
|
|
98
|
+
default: 15 * 60,
|
|
99
|
+
validator: ->(val) { val.positive? },
|
|
100
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be > 0" }
|
|
101
|
+
|
|
102
|
+
add_composer :verify_send_quiet_seconds,
|
|
103
|
+
desc: "A second verification code request inside this window sends nothing and " \
|
|
104
|
+
"answers 200 with resendAvailableAt. 0 disables the quiet window",
|
|
105
|
+
allowed: Integer,
|
|
106
|
+
default: 60,
|
|
107
|
+
validator: ->(val) { val >= 0 },
|
|
108
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
109
|
+
|
|
110
|
+
add_composer :verify_send_per_hour,
|
|
111
|
+
desc: "Verification codes sent per user per hour. 0 disables the cap",
|
|
112
|
+
allowed: Integer,
|
|
113
|
+
default: 20,
|
|
114
|
+
validator: ->(val) { val >= 0 },
|
|
115
|
+
invalid_message: ->(val) { "Provided #{val.inspect}. Value must be >= 0" }
|
|
116
|
+
|
|
117
|
+
# Key for HMAC'ing lockout subjects so no email or username sits in Redis in
|
|
118
|
+
# plaintext. Derived once and memoized: a fresh KeyGenerator runs PBKDF2 per call.
|
|
119
|
+
def lockout_hmac_key
|
|
120
|
+
@lockout_hmac_key ||= Rails.application.key_generator.generate_key(LOCKOUT_KEY_PURPOSE, 32)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "command_tower/password_policy/blocklist"
|
|
3
4
|
require "command_tower/configuration/login/strategy/plain_text/lockable"
|
|
4
5
|
require "command_tower/configuration/login/strategy/plain_text/email_verify"
|
|
5
6
|
require "command_tower/configuration/login/strategy/plain_text/password_reset"
|
|
@@ -33,24 +34,29 @@ module CommandTower
|
|
|
33
34
|
enable_attr: :enabled
|
|
34
35
|
|
|
35
36
|
add_composer :password_length_max,
|
|
36
|
-
desc: "Max Length for Password",
|
|
37
|
+
desc: "Max Length for Password (inclusive)",
|
|
37
38
|
allowed: Integer,
|
|
38
39
|
default: 64
|
|
39
40
|
|
|
40
41
|
add_composer :password_length_min,
|
|
41
|
-
desc: "Min Length for Password",
|
|
42
|
+
desc: "Min Length for Password (inclusive)",
|
|
42
43
|
allowed: Integer,
|
|
43
44
|
default: 8
|
|
44
45
|
|
|
45
46
|
add_composer :email_length_max,
|
|
46
|
-
desc: "Max Length for Email",
|
|
47
|
+
desc: "Max Length for Email (inclusive)",
|
|
47
48
|
allowed: Integer,
|
|
48
|
-
default:
|
|
49
|
+
default: 254
|
|
49
50
|
|
|
50
51
|
add_composer :email_length_min,
|
|
51
|
-
desc: "Min Length for Email",
|
|
52
|
+
desc: "Min Length for Email (inclusive)",
|
|
52
53
|
allowed: Integer,
|
|
53
|
-
default:
|
|
54
|
+
default: 3
|
|
55
|
+
|
|
56
|
+
add_composer :password_blocklist_paths,
|
|
57
|
+
desc: "Files of common passwords to reject (.gz is gunzipped). Defaults to bundled top-100k.",
|
|
58
|
+
allowed: Array,
|
|
59
|
+
default: [CommandTower::PasswordPolicy::Blocklist::DEFAULT_PATH]
|
|
54
60
|
|
|
55
61
|
def enable?
|
|
56
62
|
enable
|
|
@@ -5,13 +5,25 @@ module CommandTower
|
|
|
5
5
|
module Login
|
|
6
6
|
module Strategy
|
|
7
7
|
module PlainText
|
|
8
|
+
# DEPRECATED no-op. Nothing reads these settings: password login is protected
|
|
9
|
+
# by `login.rate_limits` (per-IP ceiling and soft per-account lockout, always
|
|
10
|
+
# on unless a limit is set to 0). Setting `enable` to true logs a deprecation.
|
|
8
11
|
class Locakable < ::CommandTower::Configuration::Base
|
|
9
12
|
include ClassComposer::Generator
|
|
10
13
|
|
|
14
|
+
DEPRECATION_MESSAGE = "[DEPRECATION] login.plain_text.lockable is a no-op and will be removed; use login.rate_limits instead."
|
|
15
|
+
|
|
16
|
+
def self.warn_deprecated
|
|
17
|
+
logger = defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : nil
|
|
18
|
+
logger ? logger.warn(DEPRECATION_MESSAGE) : Kernel.warn(DEPRECATION_MESSAGE)
|
|
19
|
+
end
|
|
20
|
+
|
|
11
21
|
add_composer :enable,
|
|
12
|
-
desc: "
|
|
22
|
+
desc: "DEPRECATED no-op. Use login.rate_limits. Previously enabled extra brute force protection.",
|
|
13
23
|
allowed: [FalseClass, TrueClass],
|
|
14
|
-
default: false
|
|
24
|
+
default: false,
|
|
25
|
+
validator: ->(val) { !val || warn_deprecated || true },
|
|
26
|
+
invalid_message: ->(val) { "Invalid lockable enable: #{val}" }
|
|
15
27
|
|
|
16
28
|
add_composer :password_attempts,
|
|
17
29
|
desc: "Max failed password attempts before additional verification on account is required.",
|
|
@@ -120,6 +120,20 @@ module CommandTower
|
|
|
120
120
|
affected_user_required: true,
|
|
121
121
|
global_visible_in_host_scope: true
|
|
122
122
|
},
|
|
123
|
+
username_set: {
|
|
124
|
+
label: "Username set",
|
|
125
|
+
tags: %w[identity username profile],
|
|
126
|
+
enabled: true,
|
|
127
|
+
enablement_configurable: false,
|
|
128
|
+
user_history: true,
|
|
129
|
+
sensitive_fields: [],
|
|
130
|
+
allowed_changes: %i[username],
|
|
131
|
+
retention: :permanent,
|
|
132
|
+
subject_required: true,
|
|
133
|
+
subject_type: "User",
|
|
134
|
+
affected_user_required: true,
|
|
135
|
+
global_visible_in_host_scope: true
|
|
136
|
+
},
|
|
123
137
|
admin_user_email_changed: {
|
|
124
138
|
label: "Admin user email changed",
|
|
125
139
|
tags: %w[identity admin users email],
|
|
@@ -24,9 +24,11 @@ module CommandTower
|
|
|
24
24
|
MODES = %i[observe enforce].freeze
|
|
25
25
|
CONTRACT_ID = /\A[a-z][a-z0-9_]*(\.[a-z0-9][a-z0-9_]*)*\z/
|
|
26
26
|
|
|
27
|
-
# CommandTower-owned seed catalog.
|
|
28
|
-
#
|
|
29
|
-
|
|
27
|
+
# CommandTower-owned seed catalog. `auth.device_session` is the contract
|
|
28
|
+
# for clients that understand device sessions (`sid`). It is observe-only
|
|
29
|
+
# and inert until a host binds per-platform minimums. Do not seed
|
|
30
|
+
# placeholder/fictional contracts here.
|
|
31
|
+
PLATFORM_CONTRACTS = %w[auth.device_session].freeze
|
|
30
32
|
PLATFORM_ENTITY_REQUIREMENTS = {}.freeze
|
|
31
33
|
|
|
32
34
|
attr_reader :mode
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "class_composer"
|
|
4
|
+
|
|
5
|
+
module CommandTower
|
|
6
|
+
module Configuration
|
|
7
|
+
module Session
|
|
8
|
+
# Device session (signed-in device) timeouts and switches.
|
|
9
|
+
class Config < ::CommandTower::Configuration::Base
|
|
10
|
+
include ClassComposer::Generator
|
|
11
|
+
|
|
12
|
+
ENFORCE_ENV = "COMMAND_TOWER_SESSION_ENFORCE"
|
|
13
|
+
UPGRADE_LEGACY_ENV = "COMMAND_TOWER_SESSION_UPGRADE_LEGACY_TOKENS"
|
|
14
|
+
OMIT_BODY_TOKEN_ENV = "COMMAND_TOWER_SESSION_OMIT_BODY_TOKEN"
|
|
15
|
+
OMIT_BODY_TOKEN_MIN_VERSION_ENV = "COMMAND_TOWER_SESSION_OMIT_BODY_TOKEN_MIN_APP_VERSION"
|
|
16
|
+
|
|
17
|
+
add_composer :idle_timeout,
|
|
18
|
+
desc: "A device session with no authenticated request for this long is expired",
|
|
19
|
+
allowed: ActiveSupport::Duration,
|
|
20
|
+
default: 30.days
|
|
21
|
+
|
|
22
|
+
add_composer :absolute_timeout,
|
|
23
|
+
desc: "Maximum lifetime of a device session from creation, regardless of activity",
|
|
24
|
+
allowed: ActiveSupport::Duration,
|
|
25
|
+
default: 90.days
|
|
26
|
+
|
|
27
|
+
add_composer :last_seen_write_interval,
|
|
28
|
+
desc: "last_seen_at is written at most once per this interval per session",
|
|
29
|
+
allowed: ActiveSupport::Duration,
|
|
30
|
+
default: 5.minutes
|
|
31
|
+
|
|
32
|
+
add_composer :enforce,
|
|
33
|
+
desc: "Kill switch. When false the revoked and idle checks are skipped. Read from ENV",
|
|
34
|
+
allowed: [TrueClass, FalseClass],
|
|
35
|
+
default: ENV.fetch(ENFORCE_ENV, "true") != "false",
|
|
36
|
+
default_shown: "ENV.fetch(\"#{ENFORCE_ENV}\", \"true\") != \"false\""
|
|
37
|
+
|
|
38
|
+
add_composer :upgrade_legacy_tokens,
|
|
39
|
+
desc: "Upgrade sid-less legacy tokens to a device session on GET /auth/session",
|
|
40
|
+
allowed: [TrueClass, FalseClass],
|
|
41
|
+
default: ENV.fetch(UPGRADE_LEGACY_ENV, "true") != "false",
|
|
42
|
+
default_shown: "ENV.fetch(\"#{UPGRADE_LEGACY_ENV}\", \"true\") != \"false\""
|
|
43
|
+
|
|
44
|
+
add_composer :omit_body_token,
|
|
45
|
+
desc: "In cookie mode, omit `token` from the login response body for the new web client " \
|
|
46
|
+
"only (X-Client-Platform: web, X-App-Version at or above " \
|
|
47
|
+
"omit_body_token_min_app_version). Read from ENV",
|
|
48
|
+
allowed: [TrueClass, FalseClass],
|
|
49
|
+
default: ENV.fetch(OMIT_BODY_TOKEN_ENV, "true") != "false",
|
|
50
|
+
default_shown: "ENV.fetch(\"#{OMIT_BODY_TOKEN_ENV}\", \"true\") != \"false\""
|
|
51
|
+
|
|
52
|
+
add_composer :omit_body_token_min_app_version,
|
|
53
|
+
desc: "First web X-App-Version (MAJOR.MINOR.PATCH) that no longer reads the body token. " \
|
|
54
|
+
"Read from ENV",
|
|
55
|
+
allowed: String,
|
|
56
|
+
default: ENV.fetch(OMIT_BODY_TOKEN_MIN_VERSION_ENV, "0.4.0"),
|
|
57
|
+
default_shown: "ENV.fetch(\"#{OMIT_BODY_TOKEN_MIN_VERSION_ENV}\", \"0.4.0\")"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -10,6 +10,8 @@ module CommandTower::Configuration
|
|
|
10
10
|
|
|
11
11
|
DEFAULT_MAX_LENGTH = 32
|
|
12
12
|
DEFAULT_MIN_LENGTH = 4
|
|
13
|
+
PROMPT_AFTER_SIGNUP = "after_signup"
|
|
14
|
+
PROMPT_OFF = "off"
|
|
13
15
|
|
|
14
16
|
add_composer_blocking :realtime_username_check,
|
|
15
17
|
desc: "Adds components to check if the username is available in real time",
|
|
@@ -36,6 +38,21 @@ module CommandTower::Configuration
|
|
|
36
38
|
desc: "Max Length for Username",
|
|
37
39
|
allowed: String,
|
|
38
40
|
default: "Username length must be between #{DEFAULT_MIN_LENGTH} and #{DEFAULT_MAX_LENGTH}. Must contain only letters and/or numbers"
|
|
41
|
+
|
|
42
|
+
add_composer :self_service,
|
|
43
|
+
desc: "Host flag: users may set their own username. Served by the identity policy as username.selfService",
|
|
44
|
+
allowed: [FalseClass, TrueClass],
|
|
45
|
+
default: false
|
|
46
|
+
|
|
47
|
+
add_composer :self_change,
|
|
48
|
+
desc: "Allow a user who already has a username to change it. Served as username.selfChange",
|
|
49
|
+
allowed: [FalseClass, TrueClass],
|
|
50
|
+
default: false
|
|
51
|
+
|
|
52
|
+
add_composer :prompt,
|
|
53
|
+
desc: "Post-signup username step: `after_signup` or `off`. Served as username.prompt",
|
|
54
|
+
allowed: String,
|
|
55
|
+
default: PROMPT_AFTER_SIGNUP
|
|
39
56
|
end
|
|
40
57
|
end
|
|
41
58
|
end
|
|
@@ -18,5 +18,9 @@ module CommandTower
|
|
|
18
18
|
attribute :client_compatibility_recommendation
|
|
19
19
|
attribute :ui_catalog, default: 1
|
|
20
20
|
attribute :client_time_zone
|
|
21
|
+
attribute :installation_id
|
|
22
|
+
attribute :installation_id_source
|
|
23
|
+
attribute :client_platform
|
|
24
|
+
attribute :client_app_version
|
|
21
25
|
end
|
|
22
26
|
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
password-blocklist-100k.txt.gz
|
|
2
|
+
|
|
3
|
+
Source: SecLists, Passwords/Common-Credentials/xato-net-10-million-passwords-100000.txt
|
|
4
|
+
https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/xato-net-10-million-passwords-100000.txt
|
|
5
|
+
(upstream renamed it from 10-million-password-list-top-100000.txt)
|
|
6
|
+
Licence: MIT, Copyright (c) Daniel Miessler
|
|
7
|
+
https://github.com/danielmiessler/SecLists/blob/master/LICENSE
|
|
8
|
+
Modification: gzip-compressed only.
|
|
Binary file
|
data/lib/command_tower/engine.rb
CHANGED
|
@@ -30,6 +30,7 @@ module CommandTower
|
|
|
30
30
|
CommandTower::CredentialResolution::SmtpActionMailerBridge.apply!
|
|
31
31
|
CommandTower.config.registry.client_compatibility.apply_env_overlay!
|
|
32
32
|
CommandTower::EmailTheme::TokenFile.validate_host_file!
|
|
33
|
+
CommandTower.config.jwt.validate_secret!
|
|
33
34
|
|
|
34
35
|
unless Rails.env.test?
|
|
35
36
|
CommandTower.config.impersonation.validate!
|
|
@@ -93,7 +93,11 @@ module CommandTower
|
|
|
93
93
|
remote_ip: attrs[:remote_ip],
|
|
94
94
|
user_agent: attrs[:user_agent],
|
|
95
95
|
ui_catalog: attrs.fetch(:ui_catalog, 1),
|
|
96
|
-
client_time_zone: attrs[:client_time_zone]
|
|
96
|
+
client_time_zone: attrs[:client_time_zone],
|
|
97
|
+
installation_id: attrs[:installation_id],
|
|
98
|
+
installation_id_source: attrs[:installation_id_source],
|
|
99
|
+
client_platform: attrs[:client_platform],
|
|
100
|
+
client_app_version: attrs[:client_app_version]
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
run = -> { Current.set(assigned, &block) }
|
|
@@ -21,6 +21,8 @@ module CommandTower
|
|
|
21
21
|
20261012000001_add_provider_metadata_to_messaging_delivery_attempts.rb
|
|
22
22
|
20261012000002_add_finished_at_index_to_messaging_delivery_attempts.rb
|
|
23
23
|
20261124000001_add_message_definition_columns_to_messaging_communications.rb
|
|
24
|
+
20261124000002_add_secret_digest_to_user_secrets.rb
|
|
25
|
+
20261124000003_create_command_tower_device_sessions.rb
|
|
24
26
|
20261124200001_create_command_tower_home_notices.rb
|
|
25
27
|
20261124200002_create_command_tower_home_notice_controls.rb
|
|
26
28
|
].freeze
|
|
@@ -47,13 +47,20 @@ module CommandTower
|
|
|
47
47
|
# @param response [ActionDispatch::Response] The response object
|
|
48
48
|
# @param token [String] The JWT token to set
|
|
49
49
|
# @param expires_at [String, nil] Optional expiration time string
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
# @param header [Boolean] Emit the token header. Pass false for cookie-sourced
|
|
51
|
+
# requests: the token travels only in the cookie. The header is written at
|
|
52
|
+
# most once per response.
|
|
53
|
+
# @param cookie_expires_at [Time, nil] Absolute cookie expiry (a device session's
|
|
54
|
+
# absolute_expires_at). Defaults to `jwt.cookie.ttl` from now when nil. The
|
|
55
|
+
# X-Authorization-Expire header stays the sliding (idle) signal.
|
|
56
|
+
def set_token(response, token, expires_at: nil, header: true, cookie_expires_at: nil)
|
|
57
|
+
if header && response.get_header(AUTHENTICATION_WITH_RESET).nil?
|
|
58
|
+
response.set_header(AUTHENTICATION_WITH_RESET, token)
|
|
59
|
+
end
|
|
53
60
|
response.set_header(AUTHENTICATION_EXPIRE_HEADER, expires_at) if expires_at && !expires_at.to_s.strip.empty?
|
|
54
61
|
|
|
55
62
|
# Set cookie if enabled
|
|
56
|
-
set_cookie(response, token) if cookie_enabled?
|
|
63
|
+
set_cookie(response, token, expires_at: cookie_expires_at) if cookie_enabled?
|
|
57
64
|
end
|
|
58
65
|
|
|
59
66
|
# Clears token from response (cookie only, headers are response-only)
|
|
@@ -94,11 +101,12 @@ module CommandTower
|
|
|
94
101
|
# Sets cookie with configured options
|
|
95
102
|
# @param response [ActionDispatch::Response] The response object
|
|
96
103
|
# @param token [String] The JWT token to set
|
|
97
|
-
|
|
104
|
+
# @param expires_at [Time, nil] Absolute expiry; defaults to `jwt.cookie.ttl` from now
|
|
105
|
+
def set_cookie(response, token, expires_at: nil)
|
|
98
106
|
return unless cookie_enabled?
|
|
99
107
|
|
|
100
108
|
config = CommandTower.config.jwt.cookie
|
|
101
|
-
options = cookie_options(expires_at: config.ttl.from_now)
|
|
109
|
+
options = cookie_options(expires_at: expires_at || config.ttl.from_now)
|
|
102
110
|
options[:value] = token
|
|
103
111
|
|
|
104
112
|
response.set_cookie(config.name, options)
|