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

feat: improvement for the GitHub API Authentication Fix #1421

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Stijnus
Copy link
Collaborator

@Stijnus Stijnus commented Mar 2, 2025

GitHub API Authentication and UI Improvements

Summary

This PR fixes the GitHub API rate limiting issue when downloading templates and improves the UI of the Connections tab.

Changes Made

  1. Fixed GitHub API Rate Limiting Issue

    • Updated all GitHub API calls to use the modern Bearer token format instead of the older token format
    • This ensures proper authentication and increases the rate limit from 60 to 5,000 requests per hour
    • Implemented proper token handling with both cookie storage and environment variable support
    • Added support for both classic and fine-grained GitHub tokens
  2. Token Implementation Details

    • Added proper cookie storage for GitHub tokens: githubToken, githubUsername, and git:github.com
    • Implemented fallback to environment variables (VITE_GITHUB_ACCESS_TOKEN) when cookies are not available
    • Added support for specifying token type via VITE_GITHUB_TOKEN_TYPE environment variable
    • Created a reference-based token type tracking system to ensure consistent token type usage
    • Ensured token information is properly cleared on disconnect
  3. Improved Connections Tab UI

    • Made the Environment Variables section collapsible to match the GitHub connection component
    • Added help icon and improved visual consistency
    • Enhanced the token type display with color-coded badges (blue for classic, green for fine-grained)

These changes ensure that template downloads work properly without hitting rate limits and provide a cleaner, more consistent user interface. The implementation supports both manual token entry through the UI and automatic configuration via environment variables.

@Stijnus Stijnus changed the title improvement for the GitHub API Authentication Fix feat: improvement for the GitHub API Authentication Fix Mar 2, 2025
All GitHub API calls now use Bearer ${token} format ✅
All other API calls (OpenAI, Netlify, etc.) already use the correct Bearer format ✅
No instances of the old token format remain ✅
The changes we've made ensure:
Higher rate limits (5,000 requests per hour vs 60)
Consistent authentication format across the codebase
Better security by using the modern OAuth 2.0 standard
@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 4, 2025 via email

Stijnus added 5 commits March 5, 2025 17:02
GitHub has phased out basic username/password authentication for API access for security reasons. This change has been in effect for a while now as part of GitHub's security improvements.
Here's the situation:
Why Username/Password Authentication Is No Longer Available
Security Improvement: GitHub discontinued basic username/password authentication for API access to enhance security.
Industry Standard: This follows the industry trend of moving away from password-based authentication toward token-based authentication for APIs.
Better Access Control: Personal access tokens allow for more granular control over permissions compared to using your full account credentials.
Your Options for Accessing Private Repositories
To access private repositories, you now have these options:
Personal Access Token (PAT):
This is what we've implemented in the form
You create this token in your GitHub account settings
It's the most straightforward method for individual users
OAuth Apps:
More complex to set up but provides a more seamless user experience
Requires registering an application with GitHub
GitHub Apps:
Enterprise-level solution
More complex but provides the most granular permissions
How to Get a Personal Access Token
Getting a token is straightforward:
Go to GitHub Settings > Developer settings > Personal access tokens
Click "Generate new token" (classic)
Give it a name like "Bolt DIY Access"
Select the "repo" scope to access private repositories
Click "Generate token"
Copy the token and paste it into our application
Important Considerations
Repository Access: You still need to be granted access to the private repository by its owner, regardless of having a token.
Token Security: Treat your token like a password - it provides access to your GitHub account based on the permissions you grant it.
Token Scope: For accessing private repositories, your token needs the "repo" scope.
@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 7, 2025

@thecodacus made the changes...

@thecodacus
Copy link
Collaborator

looks good to me. the url option should allow user to use any non github url. but that we can do in another PR.
just resolve the conflicts and we are good to merge

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.

4 participants