Skip to content

Refact: Restrict CLI Command Visibility Before User Authentication

Anil Kumar Valaboju requested to merge cmd-visibility into main

Description

Overview

This merge request implements authentication-based command visibility and access control for the Corpus CLI.

Previously, all CLI commands were visible and executable before user authentication, which exposed protected commands to unauthenticated users and created an inconsistent CLI experience.

This update ensures that only the login command is accessible before authentication. After successful login, all authorized commands become visible and executable dynamically.


Changes Made

Before Authentication

  • Restricted command visibility to only:
    • login
  • Hidden all protected/authenticated commands from help menu and command listings.
  • Blocked execution of unauthorized commands for unauthenticated users.

After Authentication

  • Dynamically enabled and displayed authenticated commands after successful login.
  • Refreshed CLI command registry based on authentication state.
  • Updated help/menu output to reflect available commands correctly.

Security & UX Improvements

  • Prevents unauthorized access attempts to protected commands.
  • Improves command-line user experience by showing only relevant commands.
  • Reduces confusion for first-time users.
  • Ensures cleaner and more secure CLI behavior.

Acceptance Criteria Covered

  • Only login command visible before authentication
  • Protected commands hidden for unauthenticated users
  • All commands visible after successful login
  • Unauthorized command execution blocked
  • Help/menu output updates dynamically based on authentication state

Testing Performed

  • Verified CLI behavior before login
  • Verified successful login flow
  • Tested visibility of commands after authentication
  • Tested unauthorized command execution handling
  • Validated updated help output/menu rendering

Merge request reports

Loading