[go: up one dir, main page]

Skip to content

Hide SSH Keys menu when SSH access is disabled

What does this MR do?

This MR fixes a UX issue where the "SSH Keys" menu option is shown in user settings even when SSH access is disabled system-wide.

Related issues

Closes #20537

Problem

When SSH access is disabled in System Settings (by setting "Enabled Git access protocols" to "Only HTTP(S)"), users still see the "SSH Keys" menu option in their settings, which becomes useless since SSH is disabled.

Solution

Added a conditional check in the user settings navigation to only show the SSH Keys menu item when SSH access is enabled in the system configuration.

The condition Gitlab::CurrentSettings.enabled_git_access_protocol != 'http' ensures that:

  • When enabled_git_access_protocol is set to 'http' (HTTP(S) only), the SSH Keys menu is hidden
  • When enabled_git_access_protocol is set to 'ssh' or is nil/unset, the SSH Keys menu is shown
  • The solution is backward compatible and doesn't break existing functionality

How to test

  1. As an admin, go to Admin Area > Settings > General
  2. Set "Enabled Git access protocols" to "Only HTTP(S)"
  3. Save the configuration
  4. Log in as a regular user and navigate to User Settings
  5. Verify that the "SSH Keys" menu option is no longer visible
  6. Change the setting back to "Both SSH and HTTP(S)" or "Only SSH"
  7. Verify that the "SSH Keys" menu option is now visible again

Screenshots

Before (SSH Keys menu shown even when SSH is disabled)

The SSH Keys menu appears regardless of the system SSH setting.

After (SSH Keys menu hidden when SSH is disabled)

The SSH Keys menu is conditionally shown based on the system SSH access setting.

Checklist

  • Code follows GitLab coding standards
  • Changes are backward compatible
  • Solution addresses the root cause of the issue
  • No breaking changes introduced

Merge request reports

Loading