Skip to content

feat: add SSH settings for device and namespace#6148

Open
henrybarreto wants to merge 1 commit intomasterfrom
feat/allow-block-password-logins
Open

feat: add SSH settings for device and namespace#6148
henrybarreto wants to merge 1 commit intomasterfrom
feat/allow-block-password-logins

Conversation

@henrybarreto
Copy link
Copy Markdown
Collaborator

@henrybarreto henrybarreto commented Apr 8, 2026

Add allow-based SSH settings for both namespace and device configuration, update the backend migrations and auth flow, and wire the React console to edit the new settings consistently.

Closes #6136


Namespace's settings:

Screenshot 2026-04-11 at 09-04-26 ShellHub

Device's settings:
Screenshot 2026-04-11 at 09-05-02 ShellHub

@henrybarreto henrybarreto self-assigned this Apr 8, 2026
@henrybarreto henrybarreto requested review from a team as code owners April 8, 2026 23:03
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

Claude finished @henrybarreto's task in 7m 11s —— View job


Code Review Complete

Reviewed 28 files. 6 inline issues posted (2 critical, 2 high, 2 medium).

Critical: Cloud compilation breakage (non-inlinable)

DeviceIsOnline and DeviceOnlineThreshold were removed from api/store/pg/device.go, but cloud/pkg/store/pg/session.go still references both symbols via the shpg import alias (lines 220, 258, 262). This will cause a compilation failure in the cloud repo. These removals appear unrelated to the disable password/public key feature — either restore them or submit a companion cloud PR first.

Additional notes

  • This PR includes several unrelated changes mixed into the same commit: removal of DeviceIsOnline/DeviceOnlineThreshold, removal of fromLt filter, session online check removals, CLI refactoring, and UUID mock changes. Consider splitting these into separate commits or PRs.
  • Missing migration test: migration_121_test.go does not exist, while virtually every other migration (1–120) has one. Consider adding it following the existing pattern.

If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread pkg/models/namespace.go Outdated
Comment thread api/services/namespace.go Outdated
Comment thread ui/src/components/Terminal/TerminalLoginForm.vue Outdated
Comment thread openapi/spec/components/schemas/namespaceSettings.yaml Outdated
Comment thread ssh/session/auther_test.go
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch 5 times, most recently from 2f24e04 to a34b829 Compare April 10, 2026 10:53
@gustavosbarreto
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

Claude finished @gustavosbarreto's task in 7m 6s —— View job


Code Review Complete

Reviewed 32 files. 2 inline issues posted (1 critical, 1 high).

Critical: Auth method restriction bypass via SSH fallback

The DisablePassword/DisablePublicKey checks in Evaluate() are only called when the session state is StateEvaluated (session.go:650). When an SSH client's first auth method passes Evaluate() and register() but fails at connect(), the state is already saved as StateRegistered. On fallback to a second auth method, Auth() enters the StateRegistered case directly, skipping Evaluate() entirely. This allows bypassing disable_password by first attempting (and failing) public key auth, then falling back to password — the DisablePassword check never runs. See inline comment for details and fix.

Additional notes

  • Cloud admin NamespaceUpdate silently drops new settings: cloud/internal/admin/services/namespace.go:68-71 copies settings fields individually (SessionRecord, ConnectionAnnouncement) but does not copy the new DisablePassword/DisablePublicKey fields. When an admin updates a namespace through the cloud admin service, these settings will be silently reset to false. A companion cloud change is needed.

  • Previous review findings still open: The critical bson:"omitempty" bug on boolean fields (pkg/models/namespace.go:54-55) and the disable_public_key not being handled in the terminal login form (ui/src/components/Terminal/TerminalLoginForm.vue) from the prior review remain unaddressed.


If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread api/services/namespace_test.go Outdated
Comment thread api/services/namespace_test.go Outdated
Comment thread ssh/session/auther.go
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch from a34b829 to 486eeca Compare April 11, 2026 12:05
@henrybarreto henrybarreto changed the title feat: add disable password and disapble public key on namespace config feat: add SSH settings for device and namespace Apr 11, 2026
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch 3 times, most recently from f422ac4 to b2afb9b Compare April 11, 2026 12:55
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

Claude encountered an error —— View job


Code Review Complete

Reviewed 69 files. 2 inline issues posted (2 high).

Additional notes

  • Previous review findings still open: The critical bson:"omitempty" bug on boolean fields (pkg/models/namespace.go:54-62, pkg/models/device.go:104-112), the auth method bypass via SSH fallback (ssh/session/session.go Auth() method), and the required constraints removal from namespaceSettings.yaml from prior reviews remain unaddressed.
  • Dead code: SettingDisablePassword.vue and SettingDisablePublicKey.vue are not imported anywhere and reference the removed disable_password/disable_public_key API fields — they should be deleted.
  • Stale interface fields: INamespaceSettings in ui/src/interfaces/INamespace.ts still has disable_password? and disable_public_key? optional fields that no longer exist in the API — these should be removed to prevent future confusion.

If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread ui/src/components/Terminal/TerminalLoginForm.vue Outdated
Comment thread ui/src/components/Setting/SettingNamespaceToggle.vue Outdated
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch 2 times, most recently from c986066 to a1b0119 Compare April 15, 2026 22:15
@gustavosbarreto
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

Claude finished @gustavosbarreto's task in 3m 17s —— View job


Code Review Complete

Reviewed 69 files. 5 inline issues posted (2 critical, 3 high).

Additional notes

  • Previous review findings still open: The critical bson:"omitempty" bug on boolean fields (pkg/models/namespace.go:54-62, pkg/models/device.go:104-112), the auth method bypass via SSH fallback (ssh/session/session.go Auth() method), and the TerminalLoginForm.vue not filtering public key auth when allow_public_key=false from prior reviews remain unaddressed.

  • Cloud test helpers need updating: cloud/pkg/store/storetest/helpers.go and cloud/internal/admin/services/namespace_test.go construct NamespaceSettings with only SessionRecord and ConnectionAnnouncement. The new Allow* fields default to Go's false, so cloud tests will create namespaces with all SSH features disabled — breaking any test that exercises SSH connections.

  • Cloud admin NamespaceUpdate still missing new fields: cloud/internal/admin/services/namespace.go copies settings fields individually but does not copy the new Allow* fields, silently resetting them to false on admin updates.


If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread api/store/pg/migrations/002_create_ssh_settings_tables.tx.up.sql
Comment thread api/store/pg/device.go Outdated
Comment thread ssh/server/server.go
Comment thread ui-react/apps/console/src/pages/DeviceDetails.tsx Outdated
Comment thread ui-react/apps/console/src/pages/DeviceDetails.tsx
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch 4 times, most recently from 305adb5 to d51218a Compare April 17, 2026 23:03
@gustavosbarreto
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

Claude finished @gustavosbarreto's task in 1m 33s —— View job


Code Review Complete

Reviewed 69 files. 4 inline issues posted (2 high, 1 high, 1 medium).

Additional notes

  • Previous review findings still open: The critical bson:"omitempty" bug on boolean fields (pkg/models/namespace.go:54-62, pkg/models/device.go:104-112), the auth method restriction bypass via SSH fallback (ssh/session/session.go Auth() method), the upsert overwriting created_at and PK id columns (api/store/pg/device.go:165, api/store/pg/namespace.go:168), and the shallow copy sharing the Settings pointer in namespace tests (api/services/namespace_test.go) from prior reviews remain unaddressed.

  • Cloud admin NamespaceUpdate still drops new settings: cloud/internal/admin/services/namespace.go:69-70 copies only SessionRecord and ConnectionAnnouncement but not the 9 new Allow* fields. Admin namespace updates will silently reset these settings to false. A companion cloud change is still needed.


If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread ui-react/apps/console/src/pages/DeviceDetails.tsx
Comment thread openapi/spec/components/schemas/namespaceSettings.yaml
Comment thread ui/src/components/Setting/SettingAllowPassword.vue
Comment thread api/store/pg/device.go Outdated
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch 2 times, most recently from 9a6f26c to f2ba7e8 Compare April 21, 2026 22:47
@gustavosbarreto
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Claude finished @gustavosbarreto's task in 39s —— View job


Code Review Complete

Reviewed 69 files. 1 inline issue posted (1 high).

Additional notes

  • Previous review findings still open: The critical bson:"omitempty" bug on boolean fields (pkg/models/namespace.go:54-62, pkg/models/device.go:104-112), the auth method restriction bypass via SSH fallback (ssh/session/session.go Auth() method), the upsert overwriting created_at and PK id columns (api/store/pg/device.go:184, api/store/pg/namespace.go:187), the shallow copy sharing the Settings pointer in namespace tests (api/services/namespace_test.go:1223), the allow_password and allow_public_key added to required in namespaceSettings.yaml:51-55 (breaking API change), and the dead code SettingAllowPassword.vue/SettingAllowPublicKey.vue from prior reviews remain unaddressed.

  • Cloud admin NamespaceUpdate still drops new settings: cloud/internal/admin/services/namespace.go:69-70 copies only SessionRecord and ConnectionAnnouncement but not the 9 new Allow* fields. Admin namespace updates will silently reset these settings to false. A companion cloud change is still needed.


If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

Comment thread ui/src/utils/permission.ts Outdated
Comment on lines +44 to +45
"namespace:updateDisablePassword": Roles.ADMINISTRATOR,
"namespace:updateDisablePublicKey": Roles.ADMINISTRATOR,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

severity: high — Stale permission entries from the old disable_* naming convention.

namespace:updateDisablePassword and namespace:updateDisablePublicKey are defined but never referenced anywhere in the codebase — the PR renamed these to namespace:updateAllowPassword and namespace:updateAllowPublicKey (lines 46–47). These two entries are dead code that pollute the Action type.

Suggested change
"namespace:updateDisablePassword": Roles.ADMINISTRATOR,
"namespace:updateDisablePublicKey": Roles.ADMINISTRATOR,
"namespace:updateAllowPassword": Roles.ADMINISTRATOR,
"namespace:updateAllowPublicKey": Roles.ADMINISTRATOR,

@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch from f2ba7e8 to 6491df4 Compare April 25, 2026 15:23
Add allow-based SSH settings for both namespace and device
configuration, update the backend migrations and auth flow, and wire the
React console to edit the new settings consistently.

Closes #6136
@henrybarreto henrybarreto force-pushed the feat/allow-block-password-logins branch from 6491df4 to 1ad09f2 Compare April 26, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to disable password login and allow only public-key authentication

2 participants