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: Added Custom Auth #1139

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

Conversation

kaanrkaan
Copy link

Description

Motivation: The current self-hosted version supports authentication through Google, GitHub, and local accounts. However, to provide a more flexible and comprehensive authentication solution, we propose integrating a Generic OAuth2. This integration enhances the versatility and scalability of the self-hosted version, making it more adaptable to diverse environments and user needs.

This pull request introduces support for a new custom OAuth flow, including backend and frontend changes. The most important changes include adding new API endpoints, updating the OAuth configuration, and modifying the frontend login page to support the custom OAuth provider.

Backend Changes:

  • API Endpoints: Added new endpoints for starting and completing the custom OAuth flow in openapi.yaml and user.yaml. ([[1]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-97b387589242cdf48a7b66f4daa27066a206a9dcd8659d8587740c904aaa1ce7R43-R46), [[2]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-c9b0ba958712a3995a7c08989693bf7ddc047f2ada30416b359c158d444ad0f9R180-R209))
  • OAuth Callback Handler: Implemented the handler for the custom OAuth callback, including user creation and token handling in custom_oauth_callback.go. ([api/v1/server/handlers/users/custom_oauth_callback.goR1-R171](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-efb7cb724507a0ef56ab3cc46321b34c90f4092cf4e0b7f7e27a6f4317915ed5R1-R171))
  • OAuth Start Handler: Implemented the handler for initiating the custom OAuth flow in custom_oauth_start.go. ([api/v1/server/handlers/users/custom_oauth_start.goR1-R30](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-dd6f0cfcf68493068af113851e0eb93db747cc84ec34f24b0c926da594a1eac2R1-R30))
  • OAuth Configuration: Added a new configuration structure and client creation function for the custom OAuth provider in configs.go. ([[1]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-0a89e2dc1668b45a0c13a724b8370395c6ba7858fc2e056b4dbe3c2294609922R14-R18), [[2]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-0a89e2dc1668b45a0c13a724b8370395c6ba7858fc2e056b4dbe3c2294609922R66-R78))

Frontend Changes:

  • Login Page: Updated the login page to include the custom OAuth provider option in index.tsx. ([[1]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-58fcbd495ec97f2dcd23d93ae89964a861312c6ad7e57e77581aabb6ecbbd561R26-R33), [[2]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-58fcbd495ec97f2dcd23d93ae89964a861312c6ad7e57e77581aabb6ecbbd561R45), [[3]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-58fcbd495ec97f2dcd23d93ae89964a861312c6ad7e57e77581aabb6ecbbd561R161-R170))

Other Changes:

  • Protobuf Updates: Updated protobuf files to a newer version. ([[1]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-5dae58817d67249465ccd577680efbe209af6efd05e69414732d6e1e5f273b34L4-R4), [[2]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-a7b46e898d2bf451ca3ddef8aec670eaf3819e194f660c19dac9da4f2548edc5L4-R4), [[3]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-4aad7ea9705bab7520e2aebcf18514f535b747ca161334b11d5a3c0f7e8fe46eL4-R4), [[4]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-6b1d5f75ca8e6540cb6248394678ed3e41631a394681e9b69bb14fd356a96b9cL4-R4), [[5]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-ee2f134689e37199fade5382ed922d587113363950401bf11f36a6b377644e65L4-R4), [[6]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-379298bd2027b3e847425ab728ebd7d083ea09afcae68991e1a4db672c075d07L4-R4))
  • Client Interface: Added new methods to the client interface for the custom OAuth endpoints in gen.go. ([[1]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R2129-R2134), [[2]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R3277-R3300), [[3]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R7531-R7584), [[4]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R8751-R8756), [[5]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R10533-R10574), [[6]](https://github.com/hatchet-dev/hatchet/pull/1139/files#diff-984209ef99f3799ba42a3c327662ca8344b5a2e5cda37abc31040e0aff2c9a58R11894-R11911))

Added following env values:

  • SERVER_AUTH_CUSTOM_ENABLED
  • SERVER_AUTH_CUSTOM_CLIENT_ID
  • SERVER_AUTH_CUSTOM_CLIENT_SECRET
  • SERVER_AUTH_CUSTOM_AUTHORIZATION_URL
  • SERVER_AUTH_CUSTOM_ACCESS_TOKEN_URL
  • SERVER_AUTH_CUSTOM_RESOURCE_URL
  • SERVER_AUTH_CUSTOM_SCOPES

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Copy link

vercel bot commented Dec 19, 2024

@kaanrkaan is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

@kaanrkaan
Copy link
Author

@abelanger5, I would greatly appreciate any feedback or review you may have on this. Thank you!

@abelanger5
Copy link
Contributor

Hey @kaanrkaan, thanks for the PR! I'll be taking a close look at this in the next couple of days and will keep you updated.

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.

2 participants