Backend For Dummies: Securing Your Web App

Securing your web app isn’t optional. If you’re building anything on the internet, you’re automatically inviting people to try and break it, sometimes just for fun. This post is for beginners who don’t know where to even start thinking about security.
We’ll start with how to think about security, then talk about some practical tools and habits that’ll actually make your app harder to crack.
There are two main ways I like to think about backend security.
1. Authentication and Authorization (The Double A’s)
Here’s my goofy analogy:
Imagine you’re guarding a leprechaun’s gold. Your data is the gold. Your job is to let only the right leprechauns in.
Authentication asks: “Who are you?”
This is the login process. Passwords, JWT’s, OAuth2, etc
Authorization asks: “Now that I know who you are, what are you allowed to do?”
Admins might have superpowers, while regular users shouldn’t even see those options.
Together, they make sure people can only touch what they’re supposed to.
2. Think About Data Directly
This one’s less about users and more about the information your app touches.Every piece of data that goes in or out is a potential leak or attack. Let’s break it down.
a. Data Input (What your server receives)
The number one rule: never trust user input.
Anything coming from a form, an upload, or even an API call needs to be checked. Validate the type, format, and size of every field. Use parameterized queries to prevent SQL injection. Sanitize inputs to stop weird scripts or HTML tags sneaking in.
b. Data Output (What users see)
Be stingy about what you send back. If your admin dashboard shows more data than a normal user dashboard, that’s intentional.
- Create Data Transfer Objects (DTOs) for each user type so you decide what gets sent.
- Never leak sensitive info in error messages. “Something went wrong” is plenty.
c. Data Storage (Where it all lives)
Your database is your vault. Treat it like one.Never store passwords in plain text. Ever.
- Use hashing algorithms like bcrypt or Argon2. That way, even if your database gets leaked, hackers can’t reverse the hashes.
- Keep API keys and secrets in .env files, not in your GitHub repo.
And please, back up your database securely.
Extra Layers That Most Beginners Forget (me included)
- Use your framework’s built-in safety nets. If you’re using something like Spring Boot, Django, or Express, they already give you tools to help. Spring has SQL injection prevention and CSRF protection out of the box.
- Never send confidential data to the client.
- Just because something isn’t shown on screen doesn’t mean it’s hidden. If it’s in the browser, it’s visible to anyone who knows where to look.
- Keep logs and audit trails.Track who did what. If something breaks, logs are your time machine.
- Use HTTPS every time.
3. Making It Practical
Here’s how I like to approach securing a new backend project.
- Decide what actually needs protection. Not everything is sensitive, but know what is.
- Define your user types and their limits. (Who can view, edit, or delete?)
Stay safe, yall.
Originally published on Medium.