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(platform): OAuth support + API key management + GitHub blocks #8044

Conversation

Pwuts
Copy link
Member

@Pwuts Pwuts commented Sep 12, 2024

Changes 🏗️

Config

  • For Supabase, the back end needs SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, and SUPABASE_JWT_SECRET
  • For the GitHub integration to work, the back end needs GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET
  • For integrations OAuth flows to work in local development, the back end needs FRONTEND_BASE_URL to generate login URLs with accurate redirect URLs

Front end

UI components

  • CredentialsInput for use on CustomNode: allows user to add/select credentials for a service.
    • APIKeyCredentialsModal: a dialog for creating API keys
    • OAuth2FlowWaitingModal: a dialog to indicate that the application is waiting for the user to log in to the 3rd party service in the provided pop-up window
  • NodeCredentialsInput: wrapper for CredentialsInput with the "usual" interface of node input components
  • New icons: IconKey, IconKeyPlus, IconUser, IconUserPlus

Data model

  • CredentialsProvider: introduces the app-level CredentialsProvidersContext, which acts as an application-wide store and cache for credentials metadata.
  • useCredentials for use on CustomNode: uses CredentialsProvidersContext and provides node-specific credential data and provider-specific data/functions
  • /auth/integrations/oauth_callback route to close the loop to the CredentialsInput after a user completes sign-in to the external service
  • Add BlockIOCredentialsSubSchema

API client

  • Add isAuthenticated method
  • Add methods for integration OAuth flow: oAuthLogin, oAuthCallback
  • Add CRD methods for credentials: createAPIKeyCredentials, listCredentials, getCredentials, deleteCredentials
  • Add mirrored types CredentialsMetaResponse, CredentialsMetaInput, OAuth2Credentials, APIKeyCredentials

REST API

  • Tweak output of OAuth /login endpoint: add state_token separately in response
  • Add POST /integrations/{provider}/credentials (for API keys)
  • Add DELETE /integrations/{provider}/credentials/{cred_id}

Back end

  • Add Supabase support to AppService
  • Add FRONTEND_BASE_URL config option, mainly for local development use

autogpt_libs.supabase_integration_credentials_store

  • Add CredentialsType alias
  • Add .bearer() helper methods to APIKeyCredentials and OAuth2Credentials

Blocks

  • Add CredentialsField(..) -> CredentialsMetaInput
  • Add GitHub blocks + "DEVELOPER_TOOLS" category
  • Add **kwargs to Block.run(..) signature to support additional kwargs
  • Add support for loading blocks from nested modules (e.g. blocks/github/issues.py)

Executor

  • Add strict support for credentials fields on blocks
  • Fetch credentials for graph execution and pass them down through to the node execution

PR Quality Scorecard ✨

  • Have you used the PR description template?   +2 pts
  • Is your pull request atomic, focusing on a single change?   +5 pts
  • Have you linked the GitHub issue(s) that this PR addresses?   +5 pts
  • Have you documented your changes clearly and comprehensively?   +5 pts

Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added conflicts Automatically applied to PRs with merge conflicts documentation Improvements or additions to documentation platform/backend AutoGPT Platform - Back end size/xl and removed conflicts Automatically applied to PRs with merge conflicts labels Sep 12, 2024
Copy link

netlify bot commented Sep 12, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 14673a8
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/66f48a2f573d220008fbb861

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Sep 12, 2024
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Sep 12, 2024
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Sep 14, 2024
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Sep 16, 2024
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@Pwuts Pwuts requested a review from a team as a code owner September 25, 2024 11:32
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Sep 25, 2024
@Pwuts
Copy link
Member Author

Pwuts commented Sep 25, 2024

Config

  • For Supabase, the back end needs SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, and SUPABASE_JWT_SECRET
  • For the GitHub integration to work, the back end needs GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET
  • For integrations OAuth flows to work in local development, the back end needs FRONTEND_BASE_URL to generate login URLs with accurate redirect URLs

@aarushik93 does this require changes to any of the helm charts?

@Pwuts Pwuts mentioned this pull request Sep 25, 2024
3 tasks
@ntindle ntindle self-requested a review September 25, 2024 19:08
@aarushik93
Copy link
Contributor

aarushik93 commented Sep 25, 2024

hey yes we do need them can you add the secrets as empty strings for now? in the values file please. Or I can do it.

Is the service role key a secret key?

@Pwuts
Copy link
Member Author

Pwuts commented Sep 25, 2024

hey yes we do need them can you add the secrets as empty strings for now? in the values file please. Or I can do it.

I can add them, but is this appropriate/necessary? All of the newly required config options are secrets, and if I search for e.g. SUPABASE_JWT_SECRET in the helm charts, I only find one entry, in autogpt-market/values.dev.yaml: not in the charts for the front end or back end.

Is the service role key a secret key?

Yes. It has admin level privileges within Supabase.

ntindle
ntindle previously approved these changes Sep 25, 2024
@Pwuts Pwuts force-pushed the reinier/open-1806-implement-front-to-back-github-oauth-support-on-blocks branch from 60ccb3d to 60b7c00 Compare September 25, 2024 19:53
@Pwuts Pwuts merged commit 5e2874c into master Sep 25, 2024
16 checks passed
@Pwuts Pwuts deleted the reinier/open-1806-implement-front-to-back-github-oauth-support-on-blocks branch September 25, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/xl
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement front-to-back GitHub OAuth support on blocks
6 participants