giselles-ai / giselle

Giselle: AI for Agentic Workflows. Human-AI Collaboration. Open Source.
https://giselles.ai
Apache License 2.0
10 stars 4 forks source link

Add GitHub Login #64

Open satococoa opened 1 week ago

satococoa commented 1 week ago

Summary

ref https://github.com/route06inc/giselle/issues/53

This PR enables users to sign up and sign in with their GitHub accounts using Supabase Auth. https://supabase.com/docs/guides/auth/social-login/auth-github

Additionally, I have implemented the linking and unlinking of GitHub accounts to existing Giselle accounts through manual identity linking feature. https://supabase.com/docs/guides/auth/auth-identity-linking

Until this PR, we only supported email signup. This PR introduces a second signup method, so I've slightly modified the signup flow to meet these requirements.

Related Issue

Changes

This pull request introduces a comprehensive GitHub OAuth integration, including authorization, callback handling, and user management within the authentication and settings modules. The changes are grouped into three main themes: OAuth Authorization, User Management, and UI Components.

OAuth Authorization

User Management

UI Components

Testing

Case 1

Given: You have Giselle account: foobar@route06.co.jp.

Sign up with your GitHub account using the email foobar@route06.co.jp (note that your GitHub account may have additional emails, and your primary email can be different).

👉 The GitHub identity is linked to your existing Giselle account: foobar@route06.co.jp.

Case 2

Given: You don't have a Giselle account.

Sign up with your GitHub account using the emails foobar@gmail.com and foobar@route06.co.jp. The Gmail one is primary.

👉 A new Giselle account foobar@gmail.com with the GitHub identity will be created.

Then sign up with the email foobar@route06.co.jp.

👉 Another Giselle account foobar@route06.co.jp will be created.

In this case, you cannot link your GitHub account (having foobar@gmail.com and foobar@route06.co.jp) to the Giselle account foobar@route06.co.jp unless you delete the Giselle account foobar@gmail.com.

Case3

Given: You have a Giselle account with the email foobar@route06.co.jp. (not created via GitHub signup)

You can link any GitHub account on /settings/account. (This uses Supabase's manual linking feature)

Additionally, if you also have an email identity, you can unlink your GitHub account on /settings/account.

Other Information

Preparation

TODO before merging this PR

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giselle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 2:06am
shige commented 1 week ago

@satococoa Thank you for the implementation!

First, I have one question regarding the GITHUB_APP_CLIENT_ID environment variable.

Are you planning to use the same GitHub App for GitHub Login and GitHub repository integration, or will they be separate applications?

Context:

Considering this, I think it might be beneficial to separate the applications and their corresponding environment variable names to avoid confusion in operations.

For example, in the following scenarios, handling could become complicated if the apps are not separate, so I believe it might be better to set them up as separate applications from the start.

  1. Log in to the Giselle app using GitHub login
  2. Install the GitHub App on the repository https://github.com/route06inc/giselle
  3. If you want to unlink GitHub login, you can use Unlink an identity
satococoa commented 1 week ago

@shige I plan to use the same GitHub App for GitHub Login and GitHub repository integration.

Here is my thought...

First, Authorizing a GitHub App and Installing a GitHub App is a different matter.

You can authorize an App as a GitHub user and install the App into any GitHub account (personal account or organization). Difference between installation and authorization


If we use different GitHub Apps (a GitHub App for some GitHub automation, and a GitHub OAuth App for authentication), some use cases could become complicated.

Example use case.

You will want to get a list of repositories that can access both as a GitHub user and as a GitHub App. GET /user/installations/{installation_id}/repositories should work for this use case. This endpoint requires GitHub App user access tokens

But if we use separate GitHub App and GitHub OAuth App, this use case would require:


For example, the AWS Amplify and Vercel use the same GitHub App for both authentication and repository management.

Therefore, I believe using the same GitHub App for both purposes will simplify the process and reduce potential complications.

shige commented 1 week ago

@satococoa Thank you for your reply!

Therefore, I believe using the same GitHub App for both purposes will simplify the process and reduce potential complications.

I see! It seems the idea I had wasn’t the best. I’ll resume the review now!

satococoa commented 2 days ago

Thank you for the review! I will fix the conflicts and prepare for release.

📝 The planned release date is Monday, November 11