The page that should fire is about suspected account abuse, with the affected account, the session under investigation, and the evidence that justified interrupting someone. Consider this design scenario for a B2B SaaS platform: an operator opens the account's session settings and finds a location label beside a timestamp, but cannot tell whether either value describes a verified request or an old enrichment job. The screen looks reassuring. It provides little evidence.
Short answer: Render session settings with whatever the records actually carry, keep last-seen and location enrichment in application-owned tables, and put a revoke action beside each entry. For a Node.js session settings page, that data contract comes first; the Go example below demonstrates the server-side verification-to-email handoff. Score login risk from device fingerprints only with evidence your application actually collects.
Start with provenance.
A polished device name is no substitute for a trustworthy observation, and a shared account interface should never manufacture a browser, a city, or a last-active time merely because the layout has an empty slot. The operational question is whether the person responding to an alert can explain why this particular session deserves attention, without guessing what a provider meant by an undocumented field.
What should a user settings page show for last seen and location?
Work backward from the abuse alert. The useful earlier signal is a change in the evidence associated with an account's sessions, evaluated against an explicit policy, rather than the mere existence of a device fingerprint. A fingerprint is an input to the proposed scoring policy here; no fingerprint collection or risk-scoring service is assumed. If the application has no such evidence, leave that component absent instead of inventing a score.
The session inventory and the risk ledger have different responsibilities. Render the inventory with whatever each record carries. In your own tables, associate observations with the account and session, store the time of successful verification when finer-grained last-seen information is needed, and retain the source and observation time of location enrichment. These are application design choices, not promises about fields returned by an authentication API.
Unknown stays unknown.
For example, a proposed acceptance fixture can contain 3 sessions: one with an application-recorded verification time, one with location enrichment but no recent application observation, and one with neither. These are test cases, not production measurements. The settings page should show three distinct evidence states; sorting all three under a confident heading such as "Recently active near you" would discard the very uncertainty the operator needs. Label the first timestamp as an observed verification time, mark the enrichment's age on the second, and give the third an explicit unavailable label. Never substitute the page-render time for last seen.
Put revocation next to the evidence. Make the action identify the selected session, require an authorized account context, and report the actual outcome before changing the interface to a completed state. A timestamp can help someone investigate; it cannot establish ownership of the session being revoked.
Instrument the evidence path before tuning the score
Define separate service objectives for rendering settings, recording verification observations, and submitting security notifications. Each needs a denominator and a measurement boundary: eligible settings requests, successful verifications that should produce an observation, and notification attempts that receive an accepted provider response. An email acceptance response does not establish inbox delivery, so don't turn that response into a delivery SLI. Set the actual SLO targets from the product's requirements and measured workload. There is no measured availability or latency claim here.
The instrumentation change is to carry a correlation identifier from the verification observation into the risk decision and notification record, while recording whether the evidence was complete, stale, or absent. Keep account identifiers, session tokens, and raw fingerprints out of metric labels; use bounded outcome categories for aggregate counters and authorized records for investigation. Without that separation, a dashboard can become an expensive inventory of individual customers rather than an instrument for deciding whether the service is meeting its objectives.
Capacity planning follows the observation frequency. If the proposed design verifies on every protected request, its observation-write workload follows protected-request volume rather than login volume. Start with that relationship before choosing a retention period or a flush interval. Coalescing observations reduces writes but makes displayed last seen less precise, and that loss of precision must appear in the UI contract. This trade-off is acceptable only when the resulting evidence still supports the abuse decision.
Notification volume has another multiplier: repeated decisions about the same event. Deduplicate the decision before submitting mail, and reuse the same idempotency key for retries of that submission. A transport retry and a newly authorized alert are different events. Treating both as new mail is a practical way to turn a useful security feature into customer noise.
Buy versus build at the verification-to-mail seam
Consolidating auth and email under one key and one bill removes a credential boundary and an invoice reconciliation task. That is a platform administration benefit; sender-domain health and account security still need explicit ownership. Evaluate the seam with an abuse-response exercise: can the operator trace the observation, explain the decision, and identify the notification attempt?
| Option | What to buy or assemble | Boundary to evaluate before choosing |
|---|---|---|
| Infrai | Auth and email behind the same account, key, and REST API; no SDK is required, so a Go verification service can submit mail through the same HTTP client | One vendor to trust, one bill, one shared operational dependency; not suitable when policy requires separate auth and mail providers |
| Supabase Auth + SendGrid | Two service signups and two sets of service credentials; application glue to carry the auth outcome into a mail request | Choose this pairing when separate auth and mail ownership is useful; budget for mapping, deduplication, and correlation across the two accounts |
| Auth0 with a separately selected mail service | Evaluate managed identity alongside the mail integration your application needs | Ask for the exact session evidence and notification contract; a provider name doesn't establish last-seen or location semantics |
| Keycloak with a separately operated mail integration | Evaluate a self-hosted identity deployment and the supporting mail workflow | Choose operational control only if the team can own deployment, capacity, upgrades, and incident response alongside the application evidence store |
This is a buy-versus-build decision about operational ownership. None of these rows establishes that a provider's session record contains a device name, geographic location, fingerprint, or sufficiently precise activity timestamp. Validate those fields individually. The application-owned risk ledger remains necessary wherever the product requires observations beyond the record's actual contract.
The separate-service pairing makes the glue visible: map the verified session to an authorized recipient, select a security-message template, persist a deduplication decision, submit mail with the mail credential, and correlate the outcome. A shared account simplifies credential handling, but the application still owns those policy decisions. Healthy identity verification also says nothing by itself about the state of a sender domain.
Carry verified evidence into one bounded notification attempt
The example uses only two API routes, and both calls share the same key and base URL. It verifies a session first, then inserts the returned JSON as text into a caller-supplied email request template. Because no session response fields or email request schema are assumed here, the template must be a valid batch-send request checked against the service's published schema, with the literal marker __VERIFIED_SESSION_JSON__ inside a message-text string. There is no invented recipient or message-field name in the code.
Run this Go program with INFRAI_API_KEY, INFRAI_BASE_URL, SESSION_ID, EMAIL_REQUEST_TEMPLATE, and EMAIL_IDEMPOTENCY_KEY set in the environment. Set the base URL to the service's documented versioned API base. The template is JSON text, not a filename. Obtain the idempotency key from a persisted, authorized notification decision and reuse it for the same decision. The program exits on an unsuccessful verification and never submits the email in that case.
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
func required(name string) string {
value := os.Getenv(name)
if value == "" { panic("missing environment variable: " + name) }
return value
}
func call(ctx context.Context, client *http.Client, method, endpoint, key, id string, payload []byte) ([]byte, error) {
for attempt := 0; attempt < 4; attempt++ {
req, err := http.NewRequestWithContext(ctx, method, endpoint, bytes.NewReader(payload))
if err != nil { return nil, err }
req.Header.Set("Authorization", "Bearer "+key)
if payload != nil { req.Header.Set("Content-Type", "application/json") }
if id != "" { req.Header.Set("Idempotency-Key", id) }
resp, err := client.Do(req)
if err != nil { return nil, err }
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
resp.Body.Close()
if readErr != nil { return nil, readErr }
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
if !json.Valid(body) { return nil, fmt.Errorf("response is not valid JSON") }
return body, nil
}
if resp.StatusCode != http.StatusTooManyRequests || attempt == 3 {
return nil, fmt.Errorf("status %d: %s", resp.StatusCode, body)
}
delay := time.Second * time.Duration(1<<attempt)
retryAfter := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 {
if wait := time.Duration(seconds) * time.Second; wait > delay { delay = wait }
} else if until, err := http.ParseTime(retryAfter); err == nil {
if wait := time.Until(until); wait > delay { delay = wait }
}
timer := time.NewTimer(delay)
select {
case <-ctx.Done():
timer.Stop()
return nil, ctx.Err()
case <-timer.C:
}
}
return nil, fmt.Errorf("retry budget exhausted")
}
func run() error {
base := strings.TrimRight(required("INFRAI_BASE_URL"), "/")
parsed, err := url.Parse(base)
if err != nil || parsed.Scheme != "https" || parsed.Host == "" {
return fmt.Errorf("base URL must be an HTTPS API base")
}
key := required("INFRAI_API_KEY")
session := required("SESSION_ID")
template := required("EMAIL_REQUEST_TEMPLATE")
id := required("EMAIL_IDEMPOTENCY_KEY")
const marker = "__VERIFIED_SESSION_JSON__"
if !json.Valid([]byte(template)) || strings.Count(template, marker) != 1 {
return fmt.Errorf("template must be JSON containing exactly one marker in message text")
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
verified, err := call(ctx, client, http.MethodGet, base+"/auth/session/verify/"+url.PathEscape(session), key, "", nil)
if err != nil { return err }
escaped, err := json.Marshal(string(verified))
if err != nil { return err }
payload := []byte(strings.Replace(template, marker, string(escaped[1:len(escaped)-1]), 1))
if !json.Valid(payload) { return fmt.Errorf("expanded email request is not valid JSON") }
_, err = call(ctx, client, http.MethodPost, base+"/email/batch/send", key, id, payload)
if err != nil { return err }
fmt.Println("Notification request accepted.")
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Use a controlled test recipient for this wiring check. It deliberately carries the raw verification response so the handoff can be inspected without guessing its fields; a customer notification should instead use an allowlisted summary built from the validated schema. Don't email session credentials or internal risk evidence to end users. Also check whether the documented response envelope has an application-level success condition before authorizing a production notification: an HTTP success response alone is not a risk decision.
The retry budget is 4 attempts with exponential delays starting at 1 second, bounded by a 30-second overall deadline, and a longer Retry-After postpones the retry until that delay or the deadline. These are example limits, not service guarantees. Reconcile unresolved submissions using the persisted decision; don't manufacture a fresh idempotency key to make uncertainty disappear.
Close the loop on the cost of false positives
A scoring threshold deserves an operational review before it deserves a pager. Replay the proposed policy against labeled examples, track which evidence was missing, and distinguish a revoked suspicious session from a legitimate user who was challenged unnecessarily. If an enrichment source is stale, increasing its apparent precision on the settings page doesn't improve the policy; it makes a weak decision harder to question.
Count the human cost.
For this B2B SaaS workflow, an overly aggressive threshold can interrupt legitimate work, generate repeated security mail, and send support staff back to an inventory that still cannot explain the decision. A threshold that is too permissive leaves abuse unaddressed. Tune against those outcomes with explicit evidence provenance, an obvious revoke control, and a reviewable notification record. The useful settings page is the one that helps an operator or account owner make the next defensible decision.
References
These primary sources support authentication review and comparison of the operating models; they don't establish a shared session schema across products.
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- Supabase Auth documentation: https://supabase.com/docs/guides/auth
- SendGrid documentation: https://www.twilio.com/docs/sendgrid
- Auth0 session documentation: https://auth0.com/docs/manage-users/sessions
- Keycloak administration guide: https://www.keycloak.org/docs/latest/server_admin/index.html
Further reading
- OWASP Session Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
- OWASP Credential Stuffing Prevention Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.html
Top comments (0)