Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove unused JSON superuser signup route #37378

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Nov 13, 2024

The JSON payload version of the super user signup route is not used anywhere significant. This PR removes it.

Automation

/test sanity authentication

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11830003644
Commit: d051ed8
Cypress dashboard.
Tags: @tag.Sanity, @tag.Authentication
Spec:


Thu, 14 Nov 2024 03:53:00 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Updated user creation process to use URL-encoded data instead of JSON for super user creation.
  • Bug Fixes

    • Removed deprecated createSuperUser methods from the API and server controllers, streamlining user management.
  • Chores

    • Modified setup scripts to reflect changes in user data transmission for creating super users.

Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

The pull request involves the removal of the createSuperUser method from both the UserApi class in the client-side TypeScript code and the UserControllerCE class in the server-side Java code. Additionally, the superUserURL property has been eliminated from the UserApi. The changes also include updates to scripts that handle user creation, transitioning from JSON payloads to URL-encoded data formats for API interactions. Overall, these modifications simplify the user management functionality by removing super user creation capabilities.

Changes

File Change Summary
app/client/src/ce/api/UserApi.tsx Removed createSuperUser method and superUserURL property from UserApi class.
app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java Removed createSuperUser method from UserControllerCE class, retaining other user functionalities.
deploy/ansible/appsmith_playbook/roles/setup-appsmith/templates/appsmith/scripts/first-time-setup.sh Updated user data transmission to API using --data-urlencode instead of JSON.
deploy/aws_ami/first-time-setup.sh Modified user data transmission to API using --data-urlencode instead of JSON.

Possibly related PRs

  • chore: Remove explicit JSON props #33577: The removal of the createSuperUser method in the main PR is related to the changes in this PR, which also involves the removal of functionality associated with JSON properties, indicating a broader effort to simplify user-related API interactions.
  • chore: Remove unused new from JSON exports/responses #34652: This PR's focus on removing unused fields from JSON responses aligns with the main PR's removal of the createSuperUser method, both contributing to a cleaner API structure by eliminating unnecessary elements.

Suggested reviewers

  • mohanarpit
  • nidhi-nair
  • rahulbarwal

🎉 In code we trust, our functions must align,
With createSuperUser gone, our paths now intertwine.
From JSON to URL, the data flows anew,
Simplifying our scripts, making life easier for you!
So here's to the changes, let the code be bright,
Together we code, making everything right! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3378c56 and d051ed8.

📒 Files selected for processing (1)
  • app/client/src/ce/api/UserApi.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/ce/api/UserApi.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

Documentation and Community

  • 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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 13, 2024
@sharat87 sharat87 added the ok-to-test Required label for CI label Nov 13, 2024
@sharat87 sharat87 marked this pull request as ready for review November 14, 2024 01:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
deploy/ansible/appsmith_playbook/roles/setup-appsmith/templates/appsmith/scripts/first-time-setup.sh (1)

114-120: Consider using POST data instead of URL parameters for sensitive information.

The current implementation passes the password as a URL parameter, which might be logged in server logs.

Consider using the -d flag with application/x-www-form-urlencoded content type for better security:

-    curl http://localhost/api/v1/users/super \
-      --data-urlencode "name=$default_user_name" \
-      --data-urlencode "email=$default_user_name" \
-      --data-urlencode "password=$default_user_password" \
-      -d source=FORM \
-      -d state=ACTIVATED \
-      -d isEnabled=true
+    curl -X POST http://localhost/api/v1/users/super \
+      -H "Content-Type: application/x-www-form-urlencoded" \
+      -d "name=$default_user_name" \
+      -d "email=$default_user_name" \
+      -d "password=$default_user_password" \
+      -d "source=FORM" \
+      -d "state=ACTIVATED" \
+      -d "isEnabled=true"
deploy/aws_ami/first-time-setup.sh (1)

113-119: Add error handling for the curl command.

The URL-encoded format change looks good, but the curl command should include error handling to ensure the super user was created successfully.

Consider adding error handling:

-    curl http://localhost/api/v1/users/super \
+    response=$(curl -s -w "\n%{http_code}" http://localhost/api/v1/users/super \
      --data-urlencode "name=$default_user_name" \
      --data-urlencode "email=$default_user_name" \
      --data-urlencode "password=$default_user_password" \
      -d source=FORM \
      -d state=ACTIVATED \
-      -d isEnabled=true
+      -d isEnabled=true)
+    
+    status_code=$(echo "$response" | tail -n1)
+    if [[ $status_code -ne 200 ]]; then
+        echo "Failed to create super user. Status code: $status_code"
+        exit 1
+    fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d90faa2 and 3378c56.

📒 Files selected for processing (4)
  • app/client/src/ce/api/UserApi.tsx (0 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java (0 hunks)
  • deploy/ansible/appsmith_playbook/roles/setup-appsmith/templates/appsmith/scripts/first-time-setup.sh (1 hunks)
  • deploy/aws_ami/first-time-setup.sh (1 hunks)
💤 Files with no reviewable changes (2)
  • app/client/src/ce/api/UserApi.tsx
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java
🔇 Additional comments (1)
deploy/aws_ami/first-time-setup.sh (1)

113-119: Verify removal of JSON endpoint.

Let's verify that the JSON endpoint for super user creation has been completely removed from the codebase.

✅ Verification successful

JSON endpoint for super user creation has been removed

Based on the search results, there are no JSON-specific endpoints or content-type headers for super user creation in the codebase. The current implementation in first-time-setup.sh uses form-encoded data which is the correct approach.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to JSON super user creation

# Check for JSON content-type headers with super user endpoints
rg -i 'content-type.*application/json.*users/super' 

# Check for any remaining JSON payload structures for super user creation
rg -i '{"name".*"email".*"password".*users/super'

# Check for any remaining createSuperUser method definitions
ast-grep --pattern 'createSuperUser($$$) {
  $$$
}'

Length of output: 276


Script:

#!/bin/bash
# Let's fix the regex and search patterns

# Check for JSON content-type headers with super user endpoints
rg -i "content-type.*json.*users/super"

# Check for JSON-like patterns in super user creation
rg -i "users/super.*json"

# Search for createSuperUser function definitions
ast-grep --pattern 'function createSuperUser($_) {
  $$$
}'

# Search for class method definitions of createSuperUser
ast-grep --pattern 'createSuperUser($_) {
  $$$
}'

# Look for any API routes handling super user creation
rg -i "router\.(post|put).*users/super"

Length of output: 226


Script:

#!/bin/bash
# Let's try a broader search for super user related endpoints and implementations

# Search for any super user endpoints
rg -i "/users/super" -A 3 -B 3

# Search for any files containing super user related code
rg -l "super.*user"

# Look for API route definitions with users/super
rg -i "app\.(post|put|get).*users/super"

# Search for any remaining references to JSON in user creation
rg -i "application/json.*user" -A 2

Length of output: 50133

@sharat87 sharat87 requested a review from mohanarpit November 14, 2024 08:09
@sharat87 sharat87 merged commit a007bd0 into release Nov 14, 2024
45 checks passed
@sharat87 sharat87 deleted the chore/no-json-super-signup branch November 14, 2024 08:44
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
The JSON payload version of the super user signup route is not used
anywhere significant. This PR removes it.


## Automation

/test sanity authentication

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11830003644>
> Commit: d051ed8
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11830003644&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 03:53:00 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Updated user creation process to use URL-encoded data instead of JSON
for super user creation.
  
- **Bug Fixes**
- Removed deprecated `createSuperUser` methods from the API and server
controllers, streamlining user management.

- **Chores**
- Modified setup scripts to reflect changes in user data transmission
for creating super users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
The JSON payload version of the super user signup route is not used
anywhere significant. This PR removes it.


## Automation

/test sanity authentication

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11830003644>
> Commit: d051ed8
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11830003644&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 03:53:00 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Updated user creation process to use URL-encoded data instead of JSON
for super user creation.
  
- **Bug Fixes**
- Removed deprecated `createSuperUser` methods from the API and server
controllers, streamlining user management.

- **Chores**
- Modified setup scripts to reflect changes in user data transmission
for creating super users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants