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: support for gitlab and github and safer token storage #766

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

Conversation

D-Byte
Copy link

@D-Byte D-Byte commented Dec 16, 2024

Updated version after commit dustinwloring1988:feat/enhanced-github-connection

Schermafbeelding 2024-12-16 101641

Secure Git Credentials Management System

Overview

Implemented a secure credential management system for GitHub and GitLab integrations, featuring encrypted storage and seamless authentication handling.

Key Features

  • Secure encryption using Web Crypto API with AES-GCM
  • Automatic encryption key management without user intervention
  • Support for both GitHub and GitLab credentials
  • Automatic migration from legacy cookie storage
  • Unified interface for managing multiple Git provider credentials
  • Improved error handling and user feedback
  • Clean separation of concerns between UI and credential management

Technical Implementation

  • Uses AES-GCM encryption for secure credential storage
  • Implements automatic key generation and management
  • Stores encrypted credentials in cookies with proper domain isolation
  • Provides fallback and migration from legacy storage formats
  • Handles both GitHub and GitLab API authentication formats
  • Includes comprehensive error handling and user notifications

UI/UX Improvements

  • Clear feedback for authentication states
  • Guided user flow for credential setup
  • Improved error messages and notifications
  • GitHub or GitLab button visible on workbench when credentials are set
  • Streamlined repository creation process

Schermafbeelding 2024-12-16 101729
GitHub setup form

Schermafbeelding 2024-12-16 101740
GitLab setup form

Schermafbeelding 2024-12-16 101749
Only show push to ... button when there are credentials set.

@D-Byte D-Byte changed the title feat: GitLab support and safer token storage also for GitHub feat: support for GitLab and GitHub and safer token storage Dec 17, 2024
@D-Byte D-Byte changed the title feat: support for GitLab and GitHub and safer token storage Support for GitLab and GitHub and safer token storage Dec 17, 2024
@D-Byte D-Byte changed the title Support for GitLab and GitHub and safer token storage feat: Support for GitLab and GitHub and safer token storage Dec 17, 2024
@D-Byte D-Byte changed the title feat: Support for GitLab and GitHub and safer token storage feat: support for gitlab and github and safer token storage Dec 17, 2024
@thecodacus
Copy link
Collaborator

@D-Byte - Great work on this! I noticed you're importing useCredentials in the hooks section, but it's not being used as a hook. To improve the implementation, could you:

Wrap these functions into a custom hook
Use useEffect to initialize the master key within the hook
This way, we avoid redundant

Let me know if you'd like help with the implementation.

@thecodacus thecodacus added enhancement New feature or request ui-enhancement Enhancement made to the UI labels Dec 18, 2024
@D-Byte
Copy link
Author

D-Byte commented Dec 18, 2024

@thecodacus, Thanks is it maybe an idea that i put all the git stuf in a lib and also the auth stuf in a lib? So that these can scale more easy the git related things in there?

@thecodacus
Copy link
Collaborator

thecodacus commented Dec 19, 2024

@thecodacus, Thanks is it maybe an idea that i put all the git stuf in a lib and also the auth stuf in a lib? So that these can scale more easy the git related things in there?

this makes more sense, thanks.
let me know when you are ready for me to test.

@thecodacus
Copy link
Collaborator

also one thing is bugging me whats the point of encrypting if the key to decryption is also stored in browser?

@D-Byte
Copy link
Author

D-Byte commented Dec 19, 2024

@thecodacus You are right but my reasoning was some encryption is better than none. But for most cases its safer than a normal cookie. The local storage is protected by the Same-Origin Policy. For now I think this is a little better. I first wanted to have this function with GitLab and GitHub working. The encryption is some extra that need some extra attention later on, maybe some other community user has a bright idea about it.

I am now going to test if pulling and pushing to GitHub works.
Later i want to add some more features more in line with Git pull, push, commit and branch.

@dustinwloring1988
Copy link
Collaborator

@D-Byte I really like this PR however can you please run pnpm typecheck and fix the errors

@D-Byte
Copy link
Author

D-Byte commented Dec 21, 2024

@D-Byte I really like this PR however can you please run pnpm typecheck and fix the errors

I am moving some things around again to make the code more flexible so it can host other git providers without breaking.
So at the moment its a WIP

@D-Byte
Copy link
Author

D-Byte commented Dec 22, 2024

@thecodacus, @dustinwloring1988 I think its ready for testing, it only do some basic pull, push and commit (create, update)
Only in my test i sometimes not see the icons on the buttons and in the connection settings page.

@thecodacus
Copy link
Collaborator

looks good so far, I am not able to connect to gitlab though, even after adding api, write_repository, scopes

will test again, and if all look good will target for 0.0.5 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ui-enhancement Enhancement made to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants