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

Fix of broken API Auth #8338

Merged
merged 10 commits into from
Nov 6, 2024
Merged

Fix of broken API Auth #8338

merged 10 commits into from
Nov 6, 2024

Conversation

guillim
Copy link
Contributor

@guillim guillim commented Nov 5, 2024

Fix done this morning with @FelixMalfait from #8295

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR fixes API authentication for self-hosted instances by modifying the JWT payload structure and validation logic to properly handle API key tokens.

  • Added type: 'API_KEY' field in JWT payload in packages/twenty-server/src/engine/core-modules/auth/services/api-key.service.ts to distinguish API tokens
  • Modified user lookup logic in jwt.auth.strategy.ts to skip user validation when payload.type === 'API_KEY'
  • Updated token validation in jwt.auth.strategy.ts to properly handle API keys by checking apiKey.revokedAt status
  • Fixed workspace ID resolution by using payload.workspaceId ?? payload.sub for consistent workspace lookup

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first PR! 🙌

@charlesBochet charlesBochet merged commit 4b5d096 into main Nov 6, 2024
19 checks passed
@charlesBochet charlesBochet deleted the fix-8295 branch November 6, 2024 13:45
Copy link

github-actions bot commented Nov 6, 2024

Thanks @guillim for your contribution!
This marks your 2nd PR on the repo. You're top 15% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants