Skip to content

Conversation

@ahmd7
Copy link
Contributor

@ahmd7 ahmd7 commented Aug 23, 2025

Introduce a new endpoint for retrieving user information and enhance it to handle JWT claims. Implement team management functionalities, including team creation, deletion, and user assignments, while ensuring unique team names. Update API versioning and improve team-user relationships in the data models. Refactor code for consistency and clarity.

@coderabbitai
Copy link

coderabbitai bot commented Aug 23, 2025

Warning

Rate limit exceeded

@ahmd7 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 415168f and 2d583d6.

📒 Files selected for processing (6)
  • cmd/cli/commands/login.go (1 hunks)
  • cmd/cli/commands/whoami.go (0 hunks)
  • internal/api/app/service/team_service.go (1 hunks)
  • internal/api/core/model/team.go (1 hunks)
  • internal/api/presentation/handlers/team.go (1 hunks)
  • internal/api/presentation/router.go (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/whoami

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ahmd7 ahmd7 merged commit a456eb6 into dev Aug 23, 2025
2 checks passed
ahmd7 added a commit that referenced this pull request Sep 25, 2025
* Feature/cli skeleton (#5)

* Add initial configuration files and scripts for project setup (#1)

- Create CI pipeline configuration for automated builds and tests
- Add auto review settings for code consistency checks
- Include .gitignore to exclude sensitive files
- Set up golangci-lint configuration for code quality checks
- Implement Taskfile for managing development tasks
- Add Go module file for dependency management
- Create scripts for encrypting and decrypting environment files

* Refactor CLI structure and enhance task definitions in Taskfile.yml; add connect command with user and machine flags; update package comments for clarity.

* removed unnecessary file

* fix connection to a server not a machine

* tidy mod file

* fix(build): ensure dependencies are declared and create bin directory before build

---------

Co-authored-by: Ahmed Samir <134155493+ahmd7@users.noreply.github.com>

* Implement backend server with health and version endpoints, add configuration management, and update Taskfile for CLI operations (#6)

* Implement login command with improved config handling (#7)

* Implement login command with server configuration loading and token management

* Fix config directory path from ~/.tempssh to ~/.tunnelr in connect and login commands

* Improve error handling for response body closure in connect and login commands

* Implement CLI commands for login and connect, add backend server initialization, and update Taskfile for building CLI and API applications

---------

Co-authored-by: Menna Hassan <h.menna85@gmail.com>

* feat: add initial database setup and user authentication (#8)

* feat: add initial database setup and user authentication

- Introduced `atlas.hcl` for environment configuration and database connection strings.
- Updated `main.go` to initialize database connection and set up user repository and authentication service.
- Enhanced `configs.go` to manage database and JWT configurations with sensible defaults.
- Implemented user model and repository for user management.
- Created authentication service for user registration and login functionalities.
- Added HTTP handlers for user operations including registration and login.
- Implemented middleware for JWT authentication and role-based access control.
- Established database migrations for user table schema.
- Removed deprecated router implementation and organized routes with Chi router.

* resolve coderabbit comments

* fix linting

* Implement CLI and backend server with user authentication (#9)

* feat: add GetUserInfo endpoint and whoami command for user information retrieval

* feat: enhance GetUserInfo to handle JWT claims normalization

* Implement CLI and backend server with user authentication (#10)

* feat: add GetUserInfo endpoint and whoami command for user information retrieval

* feat: enhance GetUserInfo to handle JWT claims normalization

* feat: implement team management functionality with repository, service, and handler layers

* feat: enhance team service with JWT role extraction and user admin checks

* feat: implement team deletion functionality and enforce unique team names

* feat: update API versioning and enhance team-user relationships in models

* feat: remove unused JWT utility function for role extraction

* feat: enhance team management by adding GetTeamUsers method and updating team routes

* refactor: rename ExtractUserRole to extractUserRole for consistency and clarity

---------

Co-authored-by: Menna Hassan <h.menna85@gmail.com>

* feat: enhance login command and add team management functionality (#12)

* feat: enhance login command and add team management functionality

* fix: linting

* refactor: coderabbit comments

* Add user information retrieval and team management features (#13)

* feat: add GetUserInfo endpoint and whoami command for user information retrieval

* feat: enhance GetUserInfo to handle JWT claims normalization

* feat: implement team management functionality with repository, service, and handler layers

* feat: enhance team service with JWT role extraction and user admin checks

* feat: implement team deletion functionality and enforce unique team names

* feat: update API versioning and enhance team-user relationships in models

* feat: remove unused JWT utility function for role extraction

* feat: enhance team management by adding GetTeamUsers method and updating team routes

* refactor: rename ExtractUserRole to extractUserRole for consistency and clarity

* feat: implement AddUserToTeam functionality with corresponding HTTP handler and router endpoint

* feat: add RemoveUserFromTeam functionality with corresponding HTTP handler and router endpoint

* refactor: clean up imports and remove unnecessary whitespace in whoami command

---------

Co-authored-by: Menna Hassan <h.menna85@gmail.com>

* feat: Add machine management functionality (#14)

- Implemented GetMachinesByTeamID method in TeamService to retrieve machines associated with a team.
- Created Machine model to represent machine data in the application.
- Added MachineRepository interface for machine data operations.
- Developed repository methods for creating, updating, retrieving, and deleting machines.
- Introduced MachineHandler for handling HTTP requests related to machine operations.
- Added routes for machine management in the router.
- Implemented user and team access checks for machine operations.
- Created SQL migration scripts for machines and machine_teams tables.
- Added utility functions for extracting user ID from JWT claims.

* Implement CLI and backend server with user and machine management (#15)

* feat: implement machines management commands for CLI

* feat: enhance machines command with team management and detailed operations

* feat: implement machines management commands for CLI

* feat: enhance machines command with team management and detailed operations

* fix: update machine ID reference and clean up team addition command flags

* refactor: streamline machine removal and response handling; improve error logging

* feat: enhance machine removal command with URL encoding and add alias for delete

* Implement CLI and backend server with user and machine management (#16)

* feat: implement machines management commands for CLI

* feat: enhance machines command with team management and detailed operations

* feat: implement machines management commands for CLI

* feat: enhance machines command with team management and detailed operations

* fix: update machine ID reference and clean up team addition command flags

* refactor: streamline machine removal and response handling; improve error logging

* feat: enhance machine removal command with URL encoding and add alias for delete

* fix: update key field type to text for better handling of larger key data

* Refactor/cli teams commands (#18)

* Refactor CLI commands to utilize centralized config and request handling

- Moved configuration loading to utils package and updated CLI commands (connect, login, machines, team, whoami) to use utils.LoadConfig().
- Implemented MakeAuthenticatedRequest in utils to handle authenticated HTTP requests, replacing direct request handling in CLI commands.
- Removed redundant loadConfig function from CLI commands.
- Added team management commands (add, remove, get) with appropriate request handling and response parsing.
- Updated router to include team-related endpoints.

* feat: add shared types for Team, User, Machine, and responses

- Introduced shared types for Team, User, and Machine in `cmd/cli/shared/types.go`.
- Added response types for listing team members and machines in `cmd/cli/shared/types.go`.

feat: implement table printing utilities for machines, users, and teams

- Created utility functions in `cmd/cli/utils/tables.go` to print formatted tables for machines, users, and teams.

refactor: update team service to return machines with team details

- Modified `GetMachinesByTeamID` in `internal/api/app/service/team_service.go` to return a team with its machines.
- Updated `GetTeamByID` to remove user ID check, simplifying the function.

fix: adjust repository and model definitions for teams and machines

- Updated `internal/api/core/model/team.go` to include a slice of machines in the Team model.
- Changed return types in `TeamRepository` and its implementation to return slices of machines instead of pointers.

chore: clean up unused migration files

- Deleted initial schema migration files that are no longer needed in `internal/cli/infrastructure/migrations`.

* refactor: update utils references to cliutils across multiple files

* fix coderabbit comments

* Implement access logging and ephemeral user management for shell access (#17)

* feat: Implement access logging and ephemeral user management for shell access

- Added AccessLogService and AccessLogRepository for managing access logs.
- Created AccessLog model to represent SSH access records.
- Enhanced MachineRepository to include password and key fields in GetMachineByID.
- Introduced ShellHandler for WebSocket connections, enabling shell access with ephemeral accounts.
- Implemented ephemeral account creation, management, and cleanup on target machines.
- Added WebSocket endpoint for shell access, including session management and error handling.
- Updated router to include new WebSocket endpoint and access log service.
- Enhanced authentication middleware to log incoming requests.
- Added utility functions to extract username from JWT claims.

* fix: add access logs to atlas

* added migration files

* feat: Enhance access log service and WebSocket handler with context management and error handling

* feat: Improve error handling and logging in WebSocket and SSH session management

- Enhanced error handling for writing messages and closing connections in WebSocket handlers.
- Refactored WebSocket session management to improve readability and maintainability by extracting setup and lifecycle management into helper functions.
- Added context management for SSH session setup and ephemeral user creation, ensuring proper cleanup and error logging.
- Updated access log status handling to ensure accurate session state tracking.

* feat: Add WebSocket SSH access command and improve session handling (#19)

* fix: Correct LoadConfig function reference in access command

* coderabbit comments

---------

Co-authored-by: Menna Hassan <h.menna85@gmail.com>

* remove test  ssh endpoint

---------

Co-authored-by: Ahmed Samir <134155493+ahmd7@users.noreply.github.com>
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.

3 participants