Choose a backend social login API when Google and GitHub should establish identity while your logistics application keeps control of account linking, sessions, and dispatch access. Build the authorize URL server-side, exchange the callback, and issue your own application session. Keep the provider list as a runtime read rather than a configuration file.
TL;DR: A Node.js backend can support this flow without NextAuth. The simplest defensible design separates completing sign-in from admitting an account to a carrier workspace. Successful social login must not grant shipment access by itself.
The architectural benefit of a stable capability contract is concrete: changing the vendor behind that capability can leave the application call unchanged. That does not remove provider registration or migrate user identities automatically. Runtime provider discovery offers a separate advantage here: adding a provider need not require an application redeploy.
Decision and scope
This decision record concerns a proposed logistics portal where dispatchers and carrier staff sign in with Google or GitHub. Its primary selection criterion is bot and abuse resistance. A real account at an identity provider is useful evidence of identity; it is not evidence that its owner belongs to a particular carrier or should see a delivery address.
Keep those decisions separate.
Use a server-owned authorization handoff, a callback exchange, and an application-owned session. Treat the provider list as available choices, with an application policy deciding which choices to expose. Discovery should not silently authorize a newly listed provider for a sensitive workspace. The runtime read removes a deployment dependency; it does not replace a security review.
This scope also keeps the delivery problem honest. Adding an email or SMS recovery path creates another admission surface, with its own throttling and delivery concerns. An accepted send request is not evidence that a person received a message. A social sign-in decision should therefore include the recovery design, even if the first release only offers two social providers.
How should Google and GitHub social login work without NextAuth?
There are three separate invariants: the callback belongs to a login attempt the browser actually started; the external identity maps to the intended local account; and the resulting session grants only the permissions that account already has. Losing any one of these breaks a different boundary. OAuth state and the applicable provider protocol checks protect the handoff. Deliberate linking protects the account mapping. Workspace authorization protects shipment data.
Identity is not membership.
Don't merge accounts implicitly.
For the handoff, bind a short-lived, single-use state value to the initiating browser session. Enforce expiration and consume it atomically. Use the provider's documented authorization flow, including PKCE where applicable, and validate the returned identity through the documented exchange. Google and GitHub do not have identical identity responses; a common email field is not an adequate identity abstraction. Store the provider namespace alongside its stable subject identifier.
The linking boundary deserves more attention than the login button. Suppose a proposed dispatcher record uses dispatch@example.invalid, and a callback supplies that same email address. Matching text alone must not attach a new identity to an existing dispatcher account. Require an authenticated linking operation or another explicitly verified ownership process. The callback exchange is where the backend makes that decision, before it creates a session. Concurrent callbacks also need a uniqueness constraint on the external identity mapping so a race cannot create two owners. Consider the next request as well: a dispatcher removed from a carrier must not retain access just because an earlier callback succeeded. Decide how membership changes affect outstanding sessions and test that behavior against the application's authorization layer. The provider has completed its job by establishing identity; the logistics system still has to enforce current authority over shipment records.
Rate limits belong at both login initiation and account creation. Scope them to more than an IP address: a carrier depot can place many legitimate users behind one network, while abusive traffic can spread across many networks. Choose thresholds from the application's traffic and threat model rather than treating a copied limit as a security guarantee. Where an upstream returns HTTP 429, honor Retry-After when present and use bounded exponential backoff; an expired login attempt should restart cleanly instead of accumulating retries.
Recovery can undo all of this. Avoid responses that reveal whether a dispatcher email exists, limit repeated code requests, and ensure an alternate recovery channel does not bypass the same linking policy. Keep codes, tokens, and full callback query strings out of routine logs. A request identifier and a coarse failure category usually answer the operational question without retaining credentials or unnecessary personal data.
Finally, register redirect URIs with each provider. A backend API does not remove that obligation. Session cookies, expiration, rotation after authentication, revocation, and workspace authorization remain explicit application responsibilities in this design.
Compare ownership before comparing convenience
The table compares integration models, not measured abuse outcomes. It makes no claim that one product blocks more bots than another. For a logistics portal, the decisive evaluation is whether the chosen model lets the application enforce its admission policy before granting access.
| Option | Integration model | Why it can fit | Boundary to evaluate |
|---|---|---|---|
| Auth0 | Managed identity platform with documented social connections | A fit when the team wants managed identity workflows and a platform for authentication policy | Map its identity and session model to carrier membership; a social connection does not establish that membership |
| Firebase Authentication | Managed authentication with documented Google and GitHub sign-in flows | A fit when Firebase already anchors application identity | Evaluate its client and server flow against a strictly backend-owned handoff, and keep resource authorization explicit |
| Supabase Auth | Authentication integrated with the Supabase stack and documented social login | A fit when identity should sit close to an existing Supabase application | Review how provider identities, sessions, and database access rules represent separate carrier workspaces |
| Infrai | One key, one bill, and a plain REST API with no SDK required | A fit for runtime provider discovery and a stable capability contract when switching backend vendors | The application still decides account linking and session policy, and registers provider redirect URIs |
None of these rows substitutes for a registration abuse policy. Exercise the actual integration with repeated callbacks, denied consent, an unrecognized identity, an existing email match, and a user who has authenticated successfully but has no workspace membership. The last case should be a normal denied admission, not an exceptional condition that accidentally falls through to shipment access.
A managed identity platform is a reasonable choice when its account model already fits the application. The trade-off is explicit: a capability API does not replace application session design. It is not a fit for a team seeking to delegate that entire design; evaluate Auth0 instead. A capability API is attractive when the team wants an explicit backend boundary and owns the surrounding session model.
Plain HTTP means no SDK to install in the dispatcher backend. The Node.js service and the Python review script can call the same REST API directly, keeping an SDK lifecycle out of this small integration.
One key and one bill cover backend services under the same platform contract. If the logistics application also uses messaging, that reduces the separate credentials and billing integrations its operators must manage. It does not make an authentication credential appropriate for browser distribution.
Public, self-describing discovery provides request and response schemas without an API key, so reviewers can inspect the contract before wiring credentials into the backend. Runnable examples in 10 languages support that review.
Inspect the provider choices before opening admission
Start the critical path by reading the provider list. This Python standard-library example makes that authenticated read with an explicit method and bounded retries. Set AUTH_API_ORIGIN to the service's HTTPS API origin, without a path, and INFRAI_API_KEY to a server-side credential. The response is printed as JSON without assuming an undocumented envelope or provider field. Keep this diagnostic on the server; it is not a browser credential pattern.
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import urlsplit
from urllib.request import Request, urlopen
def retry_delay(header, attempt):
if header:
try:
return max(0.0, float(header))
except ValueError:
try:
deadline = parsedate_to_datetime(header)
return max(
0.0,
(deadline - datetime.now(timezone.utc)).total_seconds(),
)
except (ValueError, TypeError, OverflowError):
pass
return 2 ** attempt
def read_providers():
origin = os.environ["AUTH_API_ORIGIN"].rstrip("/")
parsed = urlsplit(origin)
if (
parsed.scheme != "https"
or not parsed.hostname
or parsed.username is not None
or parsed.password is not None
or parsed.path
or parsed.query
or parsed.fragment
):
raise ValueError("AUTH_API_ORIGIN must be an HTTPS origin")
request = Request(
origin + "/v1/auth/oauth/providers",
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
method="GET",
)
for attempt in range(4):
try:
with urlopen(request, timeout=15) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected HTTP {response.status}")
return json.load(response)
except HTTPError as error:
reason = error.read().decode("utf-8", errors="replace")
retry_after = error.headers.get("Retry-After")
status = error.code
error.close()
if status != 429 or attempt == 3:
raise RuntimeError(f"HTTP {status}: {reason}") from error
time.sleep(retry_delay(retry_after, attempt))
if __name__ == "__main__":
print(json.dumps(read_providers(), indent=2))
The sample permits 4 attempts, uses a 15-second timeout per HTTP attempt, and honors Retry-After before falling back to exponential backoff. Those are example client choices, not measured service limits. This read does not create an account, so it requires no write deduplication. Do not copy its retry policy onto a callback exchange without checking that operation's replay and idempotency semantics.
The remaining critical path is the server-generated authorization URL, the browser handoff, and the callback exchange. Use the discovered schemas for those requests rather than guessing fields. Before session issuance, enforce the identity mapping and current membership checks described above. A valid but unlinked identity enters an enrollment decision; a known account without membership is denied access to the workspace. Neither case inherits privileges from an email match.
Record linking and membership changes as security events under a defined retention policy. Collect the minimum data needed to investigate abuse. Delivery addresses and recovery credentials have no place in an authentication debug dump.
Rejected option and when it becomes reasonable
Reject automatic enrollment into a privileged carrier workspace after any successful Google or GitHub callback. It is convenient, but it lets identity possession stand in for organizational authority. Reject automatic account linking by email for the same reason: a shared attribute does not express the user's intent to join two identities.
Open enrollment can still fit a public shipment inquiry product with no access to private shipment records, provided the application limits what a new account can do. In that case, social sign-in may create a low-privilege local account while additional checks govern invitations, address access, and operational actions. That is a narrower permission model with a different risk boundary.
For the dispatcher portal, retain explicit enrollment and linking decisions. The simplest backend-only implementation is the one whose trust boundaries remain understandable when a callback is repeated, a recovery message is delayed, or a valid social identity belongs to the wrong person.
Top comments (0)