September 19, 2026
Application Security Explained: How Modern Apps Protect Users from Login to Database
Assisted using AI
By Shravan Srinivas
6 min read
When we use an application, security often feels invisible.
We log in, view our profile, send information to a server, retrieve data, and continue using the application without thinking about everything happening underneath.
But behind the scenes, an application has to constantly answer important questions:
- Who is this user?
- Are they actually authenticated?
- What are they allowed to access?
- Can we trust the information they sent?
- Is their data protected while traveling across the network?
- How should passwords be stored?
- What happens if someone tries to access another user's information?
Application security isn't one feature that gets added at the end of development.
Security is a continuous part of the application's architecture.
In this article, we'll follow a request through a modern application and examine the major security concepts involved.
The Big Picture
A simplified application might look like this:
User
โ
Frontend
โ
HTTP / HTTPS
โ
Security
โ
Controller
โ
Service
โ
Repository
โ
DatabaseUser
โ
Frontend
โ
HTTP / HTTPS
โ
Security
โ
Controller
โ
Service
โ
Repository
โ
DatabaseSecurity doesn't replace these layers.
Instead, it works alongside them.
For example, a student using a scholarship application might request their profile:
React Native
โ
GET /api/profile
โ
Authentication
โ
Authorization
โ
Validation
โ
Controller
โ
Service
โ
Database
โ
Response
โ
React NativeReact Native
โ
GET /api/profile
โ
Authentication
โ
Authorization
โ
Validation
โ
Controller
โ
Service
โ
Database
โ
Response
โ
React NativeAt every stage, the application needs to make appropriate security decisions.
Authentication: Who Are You?
One of the first concepts in application security is authentication.
Authentication answers:
"Who are you?"
When a user logs into an application, they might provide:
Email
PasswordEmail
PasswordThe server verifies those credentials.
Conceptually:
User
โ
Login
โ
Server
โ
Verify credentials
โ
AuthenticatedUser
โ
Login
โ
Server
โ
Verify credentials
โ
AuthenticatedOnce authentication succeeds, the application needs a way to recognize that user on future requests.
That's where sessions and tokens come in.
Sessions
A session-based system can work conceptually like this:
Login
โ
Server authenticates user
โ
Server creates session
โ
Client receives session identifier
โ
Client sends identifier on later requests
โ
Server recognizes the userLogin
โ
Server authenticates user
โ
Server creates session
โ
Client receives session identifier
โ
Client sends identifier on later requests
โ
Server recognizes the userThe server can maintain information associated with that session.
For example:
Session ID โ User 42Session ID โ User 42Later, when the user makes another request, the server can determine which authenticated user the request belongs to.
The important idea isn't memorizing a particular implementation.
It's understanding the problem:
The server needs a way to recognize an authenticated user across multiple requests.
Token-Based Authentication
Another approach is token-based authentication.
The flow looks like:
Login
โ
Server authenticates user
โ
Server issues token
โ
Client presents token
โ
Server validates token
โ
Request continuesLogin
โ
Server authenticates user
โ
Server issues token
โ
Client presents token
โ
Server validates token
โ
Request continuesA request might conceptually contain:
Authorization: Bearer <token>Authorization: Bearer <token>JWTs are one common token format used in token-based systems.
Sessions and tokens solve a similar overall problem โ maintaining authenticated identity โ but they do so differently.
Authentication vs Authorization
These two terms are easy to confuse.
Authentication
Who are you?
Authorization
What are you allowed to do?
Suppose two students use an application.
Student A logs into their account.
Authentication establishes:
This is Student A.This is Student A.But that doesn't automatically mean Student A should be able to access Student B's profile.
Authorization determines:
Is Student A allowed to access this resource?Is Student A allowed to access this resource?So a protected request might look like:
GET /api/profile
โ
Authenticated?
โ
Authorized?
โ
Controller
โ
Service
โ
DatabaseGET /api/profile
โ
Authenticated?
โ
Authorized?
โ
Controller
โ
Service
โ
DatabaseThis distinction is one of the most important concepts in application security.
Password Security
Passwords are extremely sensitive information.
An application should not store users' passwords as plain text.
Instead, applications should use secure password hashing.
Conceptually:
User password
โ
Secure password hashing
โ
Stored password hashUser password
โ
Secure password hashing
โ
Stored password hashWhen the user logs in again, the system can verify the supplied password against the stored hash without simply storing the original password.
The important distinction is:
Encryption
โ
Can be decrypted with the appropriate key
Hashing
โ
Designed as a one-way transformationEncryption
โ
Can be decrypted with the appropriate key
Hashing
โ
Designed as a one-way transformationPassword storage requires appropriate password-hashing techniques rather than simply putting passwords into the database.
HTTPS: Protecting Data in Transit
Authentication isn't the only security concern.
Consider what happens when a user sends information to a server.
Client
โ
Network
โ
ServerClient
โ
Network
โ
ServerThat information travels across a network.
HTTPS uses TLS to protect HTTP communication in transit.
Conceptually:
HTTP
+
TLS
=
HTTPSHTTP
+
TLS
=
HTTPSThis helps protect information while it travels between the client and server.
For a real application, HTTPS is especially important when handling information such as:
- Login credentials
- Personal information
- Authentication credentials
- Application data
During local development, you might see:
http://localhost:8080http://localhost:8080because the application is communicating locally.
Production applications should use appropriately configured HTTPS.
Validation: Never Blindly Trust the Client
Here's an important security principle:
Client-side validation is useful, but the backend must validate untrusted input too.
Suppose a scholarship application asks for a GPA.
The frontend might check:
GPA must be between 0 and 4GPA must be between 0 and 4But a malicious or malfunctioning client could attempt to send:
GPA = 50GPA = 50The backend should not simply assume the frontend already checked it.
Instead:
Client input
โ
Backend validation
โ
Business logic
โ
DatabaseClient input
โ
Backend validation
โ
Business logic
โ
DatabaseThe server should treat incoming data as untrusted until it has been validated appropriately.
SQL Injection and Safe Database Access
Another important security concept involves databases.
Suppose an application constructs SQL queries by directly inserting untrusted user input into SQL strings.
That can create opportunities for SQL injection.
The basic problem is:
User input
โ
Unexpected SQL behavior
โ
DatabaseUser input
โ
Unexpected SQL behavior
โ
DatabaseModern frameworks and database-access techniques provide safer approaches for handling parameters.
For example, using JPA/Spring Data JPA helps applications work with structured data access rather than manually constructing every SQL query from raw strings.
The broader lesson is:
User input should never accidentally become executable database instructions.
Security Throughout the Request
One of the biggest misconceptions about security is thinking:
"Security happens when the user logs in."
It doesn't.
Security continues after login.
Consider this lifecycle:
USER
โ
REGISTER
โ
LOGIN
โ
AUTHENTICATION
โ
AUTHENTICATED STATE
โ
PROTECTED REQUEST
โ
AUTHENTICATION CHECK
โ
AUTHORIZATION CHECK
โ
INPUT VALIDATION
โ
BUSINESS LOGIC
โ
DATABASEUSER
โ
REGISTER
โ
LOGIN
โ
AUTHENTICATION
โ
AUTHENTICATED STATE
โ
PROTECTED REQUEST
โ
AUTHENTICATION CHECK
โ
AUTHORIZATION CHECK
โ
INPUT VALIDATION
โ
BUSINESS LOGIC
โ
DATABASEEvery protected request can require security checks.
That's why security is better thought of as a system-wide concern rather than one login screen.
A Security Layer Around the Backend
A simplified backend architecture might look like:
React Native
โ
HTTPS
โ
Spring Security
โ
Authentication
โ
Authorization
โ
Validation
โ
Controller
โ
Service
โ
Repository
โ
PostgreSQLReact Native
โ
HTTPS
โ
Spring Security
โ
Authentication
โ
Authorization
โ
Validation
โ
Controller
โ
Service
โ
Repository
โ
PostgreSQLSpring Security is a framework used with Spring applications to implement authentication and authorization features.
It doesn't replace the Controller-Service-Repository architecture.
Instead, it helps protect access to that architecture.
401 vs 403
HTTP status codes also communicate security-related outcomes.
401 Unauthorized
Typically means the request doesn't have valid authentication credentials.
Think:
"You haven't successfully authenticated."
403 Forbidden
Typically means the request is authenticated, but the user isn't allowed to perform the requested action.
Think:
"I know who you are, but you're not allowed to do that."
This distinction becomes particularly useful when designing APIs.
Security and the Database
Security doesn't stop at the API.
The database itself also needs protection.
A simplified architecture might be:
Internet
โ
Frontend
โ
Backend
โ
DatabaseInternet
โ
Frontend
โ
Backend
โ
DatabaseThe frontend should not normally connect directly to a production database.
Instead:
Frontend
โ
Backend API
โ
DatabaseFrontend
โ
Backend API
โ
DatabaseThe backend acts as the controlled intermediary.
This allows the application to enforce authentication, authorization, validation, business rules, and controlled database access.
Secrets and Credentials
Applications often need credentials for external systems.
Examples might include:
Database password
API key
Authentication secret
Third-party service credentialDatabase password
API key
Authentication secret
Third-party service credentialThese shouldn't simply be hard-coded into publicly shared source code.
Instead, applications commonly use environment variables, secret-management systems, or other secure configuration mechanisms.
The principle is simple:
Don't expose secrets unnecessarily.
Security Isn't Just Encryption
It's easy to think:
"Security means encrypt everything."
That's too simplistic.
Different security mechanisms solve different problems.
HTTPS / TLS
โ
Protects data in transit
Password hashing
โ
Protects stored passwords
Authentication
โ
Identifies the user
Authorization
โ
Controls what the user can access
Validation
โ
Rejects invalid or dangerous input
Safe database access
โ
Reduces injection risks
Secrets management
โ
Protects credentials and sensitive configurationHTTPS / TLS
โ
Protects data in transit
Password hashing
โ
Protects stored passwords
Authentication
โ
Identifies the user
Authorization
โ
Controls what the user can access
Validation
โ
Rejects invalid or dangerous input
Safe database access
โ
Reduces injection risks
Secrets management
โ
Protects credentials and sensitive configurationApplication security is therefore a collection of different protections working together.
Putting Everything Together
Let's imagine a student opens ScholarWay and requests their scholarship matches.
The complete conceptual flow could look like:
Student
โ
React Native
โ
HTTPS Request
โ
Spring Security
โ
Authentication
โ
Authorization
โ
Input Validation
โ
ScholarshipController
โ
ScholarshipService
โ
EligibilityChecker
โ
MatchingEngine
โ
ScholarshipRepository
โ
Spring Data JPA
โ
Hibernate
โ
PostgreSQL
โ
DatabaseStudent
โ
React Native
โ
HTTPS Request
โ
Spring Security
โ
Authentication
โ
Authorization
โ
Input Validation
โ
ScholarshipController
โ
ScholarshipService
โ
EligibilityChecker
โ
MatchingEngine
โ
ScholarshipRepository
โ
Spring Data JPA
โ
Hibernate
โ
PostgreSQL
โ
DatabaseThen the response travels back:
Database
โ
Hibernate
โ
JPA
โ
Repository
โ
Service
โ
Controller
โ
JSON
โ
HTTPS
โ
React Native
โ
React State
โ
Scholarship Cards
โ
StudentDatabase
โ
Hibernate
โ
JPA
โ
Repository
โ
Service
โ
Controller
โ
JSON
โ
HTTPS
โ
React Native
โ
React State
โ
Scholarship Cards
โ
StudentSecurity isn't one box in this diagram.
It's a set of protections that help determine whether the request should be allowed to continue.
Security Is a Continuous Process
A secure application isn't created by adding one security library and declaring the project finished.
Security has to be considered throughout development.
A developer needs to think about:
Authentication
Authorization
Input validation
Password storage
Network security
Database access
Secrets
Error handling
Logging
TestingAuthentication
Authorization
Input validation
Password storage
Network security
Database access
Secrets
Error handling
Logging
TestingAnd security should evolve as the application becomes more complex.
A small student project might have a relatively simple security architecture.
A large financial platform could require much more sophisticated controls.
The principles remain similar.
The Biggest Lesson
The most useful security mindset is:
Never assume the environment around your application is automatically trustworthy.
The frontend can contain bugs.
Users can send unexpected data.
Networks can be hostile.
Authentication credentials can be targeted.
Users may attempt to access resources they aren't authorized to access.
Databases contain valuable information.
A well-designed application therefore places security controls at appropriate points throughout the system.
Final Mental Model
If you remember only one diagram from this article, remember this:
APPLICATION SECURITY
USER
โ
FRONTEND
โ
HTTPS
โ
AUTHENTICATION
โ
AUTHORIZATION
โ
VALIDATION
โ
CONTROLLER
โ
SERVICE
โ
BUSINESS LOGIC
โ
REPOSITORY
โ
DATABASE ACCESS
โ
DATABASEAPPLICATION SECURITY
USER
โ
FRONTEND
โ
HTTPS
โ
AUTHENTICATION
โ
AUTHORIZATION
โ
VALIDATION
โ
CONTROLLER
โ
SERVICE
โ
BUSINESS LOGIC
โ
REPOSITORY
โ
DATABASE ACCESS
โ
DATABASEAnd around the entire system:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SECURITY โ
โ โ
โ Authentication โ
โ Authorization โ
โ HTTPS / TLS โ
โ Password hashing โ
โ Input validation โ
โ Safe database access โ
โ Secrets management โ
โ Secure error handling โ
โ Security testing โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SECURITY โ
โ โ
โ Authentication โ
โ Authorization โ
โ HTTPS / TLS โ
โ Password hashing โ
โ Input validation โ
โ Safe database access โ
โ Secrets management โ
โ Secure error handling โ
โ Security testing โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโApplication security isn't just about protecting a login page.
It's about designing the entire system so that users, data, and functionality are protected throughout the application's lifecycle.
And once you understand that, security becomes much easier to reason about because you're no longer memorizing isolated terms โ you can see how each concept fits into the architecture.