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: JWT auth #418

Merged
merged 18 commits into from
Aug 10, 2024
Merged

feat: JWT auth #418

merged 18 commits into from
Aug 10, 2024

Conversation

rolznz
Copy link
Contributor

@rolznz rolznz commented Aug 7, 2024

Part of #381

Replaces cookie auth + CSRF with JWT.

JWT is stored in local storage.

Notes:

  • All CSRF code removed
  • COOKIE_SECRET replaced with JWT_SECRET
  • Token is saved in local storage
  • added JWT_EXPIRY_DAYS so expiry can be customised so app developers can set a longer expiry. Default is 30 days.
  • Restricted group with JWT middleware is used instead of custom middleware
  • Logout is done clientside now - JWTs/sessions are currently not stored in the hub
  • Token injection is done in the http platform-specific request - (external API access only works in http mode).
  • View token in settings -> developer (EXPERIMENTAL)
  • XSS protection - React has some XSS protection built in but we still need to be careful with any user data.

TODOs:

  • security review
    • CSP headers

Tests done:

  • onboarding
  • start
  • login (brand new session)
  • invalid token
  • expired token
  • logout

Screenshots

image

Copy link
Collaborator

@rdmitr rdmitr left a comment

Choose a reason for hiding this comment

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

Backend changes look good to me — didn't check frontend though

@rolznz rolznz added this to the v1.5.0 milestone Aug 7, 2024
Copy link
Contributor

@reneaaron reneaaron left a comment

Choose a reason for hiding this comment

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

tACK

frontend/src/screens/channels/IncreaseOutgoingCapacity.tsx Outdated Show resolved Hide resolved
frontend/src/screens/peers/Peers.tsx Outdated Show resolved Hide resolved
frontend/src/screens/setup/RestoreNode.tsx Outdated Show resolved Hide resolved
frontend/src/screens/setup/RestoreNode.tsx Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
http/http_service.go Outdated Show resolved Hide resolved
@rolznz rolznz requested a review from bumi August 9, 2024 16:47
rolznz and others added 3 commits August 10, 2024 15:54
* feat: basic csp

* fix: remove vaul to avoid injection of inline scripts and styles

* fix: images to work with CSP

* chore: remove posthog

* chore: remove chatwoot

* fix: image csp issues
@rolznz rolznz merged commit 8c17360 into master Aug 10, 2024
8 checks passed
@rolznz rolznz deleted the feat/jwt-auth branch August 10, 2024 10:04
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.

4 participants