8000 fix(api): accept only sign-in tokens on the GraphQL socket by mwoods79 · Pull Request #730 · huddlz-hq/huddlz · GitHub
[go: up one dir, main page]

Skip to content

fix(api): accept only sign-in tokens on the GraphQL socket - #730

Merged
mwoods79 merged 3 commits into
mainfrom
t3/graphql-socket-token-purpose
Nov 30, 2026
Merged

mwoods79 merged 3 commits into
mainfrom
t3/graphql-socket-token-purpose

Conversation

@mwoods79
Copy link
Copy Markdown
Contributor

Summary

The GraphQL socket (/ws/gql) now takes exactly the bearer token the HTTP GraphQL endpoint takes: a stored, unrevoked sign-in token. A token minted for another purpose connects with no actor.

 connect(token) / every document
-  verify signature, expiry, not revoked
-  load the person
+  the library's bearer check, the one `:load_from_bearer` runs for HTTP:
+    signature, expiry, not revoked
+    not minted for an action or another purpose
+    stored as a sign-in token
+    load the person
   refuse a suspended account
  • The check runs at connect and again on every document, through one function, so the socket cannot drift from the HTTP endpoint.
  • The socket keeps the token for that re-check; it is hidden from inspect, so a crash report of the socket's state does not print it.
  • API keys are still not accepted on the socket (unchanged). The HTTP endpoint accepts them; adding them to the socket would be a new feature.
  • Confirmation.discard_links/1 is unchanged: a discarded link is already refused by the confirm action and the HTTP endpoint, and now by the socket.

Evidence

  • Before:
    connect(socket, token from a confirmation link)       -> me = the person
    connect(socket, discarded confirmation link token)    -> me = the person
    connect(socket, token from a password reset link)     -> me = the person
    connect(socket, sign-in page exchange token)          -> me = the person
    open session, stored token removed, next document     -> me = the person
    
    After:
    each of the five                                      -> me = nil
    sign-in token                                         -> me = the person
    suspended, revoked or expired session, next document  -> me = nil
    
    For the same tokens the HTTP endpoint answers 401 (link tokens) and 200 (sign-in token).

Merge Danger

Door: two-way

No schema or data change; reverting restores the old check.

Blast Radius: narrow

Only clients of /ws/gql. A client connecting with a sign-in token is unaffected. Each document over the socket now costs one more token lookup.

The socket checked a token's signature, expiry and revocation but not what
the token was minted for, so it was looser than the HTTP GraphQL endpoint.
A token from a confirmation link, a password reset link or the sign-in
page's short-lived exchange is not a sign-in and now connects with no actor.

The socket now runs the same bearer check the HTTP endpoint does, at connect
and again on every document, so the two cannot drift apart. A session whose
stored token is gone stops working on the next document.
The library reads a token's subject before verifying it and raises when
it is not a string, which ended the socket connection attempt with an
error instead of an anonymous connection.
The rescue around the bearer check also swallowed unrelated failures and
answered them as an anonymous connection. The subject is checked before
the lookup, so anything else that goes wrong surfaces as it does over HTTP.
@mwoods79
mwoods79 merged commit 93b99f3 into main Nov 30, 2026
5 checks passed
@mwoods79
mwoods79 deleted the t3/graphql-socket-token-purpose branch November 30, 2026 04:27
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…vocation

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…-tokens

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…arer-token

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)

# Conflicts:
#	lib/huddlz_web/graphql_socket.ex
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…n-escaping

* origin/main:
  fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…dl-links

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…mutations

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…ership

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
* origin/main:
  fix(auth): bind administrator viewing credentials to the browser session (#736)
  fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
mwoods79 added a commit that referenced this pull request Nov 30, 2026
…r-leave

* origin/main:
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Dec 1, 2026
* origin/main:
  fix(auth): have open pages follow a change of access (#735)
  fix(groups): authorize membership changes against their roster (#739)
  fix(auth): bind administrator viewing credentials to the browser session (#736)
  fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79 added a commit that referenced this pull request Dec 1, 2026
…d-sorts

* origin/main:
  fix(auth): have open pages follow a change of access (#735)
  fix(groups): authorize membership changes against their roster (#739)
  fix(auth): bind administrator viewing credentials to the browser session (#736)
  fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
  fix(api): accept only sign-in tokens on the GraphQL socket (#730)
  fix(huddl): tie organizer-only huddl details to the current role (#726)
  fix(groups): keep a group's address book with its organizers (#725)
  fix(discover): noindex empty filtered public discovery responses (#734)
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.

1 participant

0