Posts tagged “security”
-
How do you deliver webhooks so no event is ever lost?
Write every event to an outbox, retry with backoff and jitter for a day or more, sign each request with a timestamp, and let receivers replay what they missed. Receivers answer fast, deduplicate by event ID and never trust order. The design, and the quiet failure it prevents.
-
How should you store passwords?
With a slow, memory-hard password hash (argon2id, or scrypt or bcrypt), a unique salt per password, and settings that make each guess cost tens of milliseconds. A fast hash like SHA-256 lets a GPU try billions of guesses a second. Plus the parts around the hash that matter as much: rate limits…
-
Which open-source observability stack can you self-host, and what does compliance change?
OpenTelemetry to collect, Prometheus or VictoriaMetrics for metrics, Loki or OpenSearch for logs, Tempo or Jaeger for traces, Grafana on top, or SigNoz in one box. What each costs to run, what the licences mean for a SaaS, and the compliance work you can't skip: redaction, retention, access and…
-
CSRF, CORS and SameSite cookies: what each actually protects
CORS doesn't protect your server; it decides which other sites may read your responses in a browser. CSRF is another site making the browser send a request with your cookies, and SameSite cookies stop most of it, but not all. Fetch Metadata headers and a CSRF token close the rest. What each layer…
-
API keys, OAuth client credentials or mTLS: how should services authenticate?
API keys are simple and fine for low-risk public APIs if they're hashed, scoped and rotatable. OAuth client credentials give short-lived, scoped tokens and central control. Mutual TLS proves identity at the connection level and suits internal service meshes. Signed requests (HMAC) protect…
-
How do you prepare for a technology audit as a one-person infrastructure team?
Auditors don't want to see that you're careful; they want evidence that controls exist and work: who can access production, how changes reach it, whether backups restore, and what happens when something goes wrong. How to produce that evidence cheaply, from the systems you already run.
-
OAuth 2.0 and OpenID Connect: which flow for which client?
Authorization code with PKCE for anything with a user (web, SPA, mobile, desktop), client credentials for machine-to-machine, the device flow for TVs and CLIs. The implicit and password grants are retired. OAuth is about access to APIs; OpenID Connect adds who the user is. Diagrams of each flow.
-
Which kind of 2FA should you offer?
SMS codes are better than nothing and the weakest option. Authenticator-app codes (TOTP) stop password reuse but not phishing. Push approvals invite fatigue attacks. Security keys and passkeys are the only phishing-resistant option. What each defends against, what to offer, and why recovery codes…
-
RBAC, ABAC or ReBAC: how should you model permissions?
Roles answer "what can an editor do?", attributes answer "under which conditions?", relationships answer "who can see this particular document?". Most SaaS products need roles per tenant plus a few attribute rules; sharing features need relationships. Where to enforce them, and why the database…
-
Sessions or JWTs: which should you use to keep users signed in?
Two good ideas for different jobs. For a web app with its own backend, server-side sessions are simpler and safer: a random cookie, instant revocation, nothing sensitive in the browser. JWTs earn their place between services and across organisations, where checking a signature beats a database…
-
How should users sign up?
Email and password is universal but leaves you guarding passwords. Magic links remove passwords but depend on email speed. Social login is one click but ties users to another company. Passkeys are the most secure and still unfamiliar to many. B2B customers will ask for SSO. How to choose, and how…
-
Encoding, encryption, hashing, signing: what's the difference?
Encoding changes format and protects nothing. Encryption hides data from anyone without the key and can be reversed. Hashing can't be reversed and proves data hasn't changed. Signatures and MACs prove who produced the data. Which one to use for passwords, secrets, webhooks, tokens and files, with…
-
Access tokens and refresh tokens: why two, where do they live, and what happens when one leaks?
Why two tokens: a short-lived access token shown to every API, and a longer-lived refresh token shown only to the auth server and rotated, so reusing a stolen one raises an alarm. Diagrams of the flows, where to store each token on web, mobile and server, and what an attacker gets from each kind…
-
How do you rate-limit without running out of memory?
A rate limiter is a map that attackers get to grow. How I key it, bound it, and decide what happens when it's full, with the Go code and tests.
-
How do you keep tenants apart when they share one database?
How I let Postgres, not application code, keep tenants apart, so a forgotten tenant filter returns nothing instead of another customer's data: FORCE, non-owner roles, transaction-local settings, fail-closed policies, and tests that prove it.