![]() |
VOOZH | about |
Keeping digital information secure is like building a strong foundation, and a well-designed security system is essential for protecting it. This article explains how to design a robust security system step by step, starting from defining goals to implementing scalable architecture.
This section defines the functional and non-functional requirements for the authentication system.
This section describes the core features of the system.
This section defines system qualities like performance and security.
You can estimate the system capacity by analyzing certain data like traffic, number of user coming on site. Here is the simplified calculation given:
Assumption - Traffic is 100,000 vistors per month
Each authentication request is assumed to take 1 second for simplification.
Traffic per second = 100000/30*24*60*60= 0.038
Authentication Requests per Second = Traffic per Second
Authentication Requests per Second = 0.038
Assumption - Each authentication request is assumed to take approx 2kb/file size
Monthly Storage = Monthly Visitors Γ Average Authentication request/User Data Size
Monthly Storage=100,000Γ2βKB
Monthly Storage = 200,000KB or 195.31βMB(approx)
The web user initiates the interaction by logging in or registering. After successful authentication, the user can perform actions like viewing transaction history, checking balance, or processing bill payments. The user may choose to log out when the interaction is complete.
Low-level design majorly focuses on component and module of the system. It focuses on the actual implementation details, algorithms, and data structures. Key components in the low-level design of an authentication system are described below:
The main components of Low Level Design:
This component handles token generation and validation.
This component interacts with both authentication and resource servers.
This component provides access to protected resources.
High-level design provides a indepth overview of the overall system architecture, which describes the interaction between major components. It mainly focus on the system's structure, major modules, and the flow of data. Key components in the high-level design of an authentication system are described as follow:
High Level Design of the Authentication System:
Handles the process of capturing and preparing new user data for the system.
Data Acquisition: Collects and verifies user-provided registration details.
Pre-processing and Feature Extraction: Prepares raw data and extracts meaningful attributes for future use.
Manages user credential input and prepares it for authentication checks.
Data Acquisition: Captures and validates user login credentials.
Pre-processing and Feature Extraction: Transforms login data into a comparable format with stored models.
Performs live verification of users based on their stored models.
Model Overview: Defines what a model is and its role in authentication.
Model Generation: Creates and stores user-specific models for verification.
Model Database: Stores and manages all user models securely.
Classifier Decision: Determines whether the user is legitimate or an imposter.
If True (Legitimate User): Grants access when the user is verified successfully.
If False (Imposter): Triggers security actions when unauthorized access is detected.
Database design for authentication system:
The User Table stores user data with the following fields:
user_id (PK): Unique identifier for each user.username: User's username for authentication.email: User's email address for communication.password: Encrypted password for user authentication.created_at: Timestamp indicating when the user account was created.The Credentials Table stores login credentials, including hashed passwords, with the following fields:
credential_id (PK): Unique identifier for each credential.user_id (FK): Foreign key referencing the User Table.password_hash: Hashed password for user authentication.last_login: Timestamp indicating the user's last login.Password table are used to store passwords set by user. It includes field like
It is used to store information related to password reset requests initiated by users. It include field like
The Session Table tracks user sessions with the following fields:
session_id (PK): Unique identifier for each session.user_id (FK): Foreign key referencing the User Table.login_time: Timestamp indicating the session login time.last_activity: Timestamp indicating the session's last activity.The Token Table stores information about user tokens with the following fields:
token_id (PK): Unique identifier for each token.user_id (FK): Foreign key referencing the User Table.token_value: Value of the token for authentication.expiration_time: Timestamp indicating when the token expires.Defines the individual, independent services responsible for handling specific functionalities within the system.
This microservice handles tasks related to user registration, profile management, and user data storage. It includes functionalities such as creating new user accounts, updating user information, and handling account deletion requests.
API Endpoints:
/register: Create a new user account./update/:userId: Update user information./delete/:userId: Delete a user account.Responsible for verifying user credentials during the login process, implementing multi-factor authentication (MFA), and generating authentication tokens. This microservice ensures the security of the authentication process.
API Endpoints:
/login: Authenticate user credentials./logout: End user session and revoke authentication tokens./mfa/:userId: Handle multi-factor authentication.Manages access control and permissions based on user roles. This microservice ensures that authenticated users have the appropriate permissions to access specific resources or perform certain actions.
API Endpoints:
/grant/:userId/:permission: Grant specific permissions to a user./revoke/:userId/:permission: Revoke permissions from a user./check/:userId/:resource: Check user's access to a specific resource.Handles the creation, maintenance, and termination of user sessions. This microservice ensures secure session handling and can implement features like session timeouts and token revocation.
API Endpoints:
/create/:userId: Create a new user session./expire/:sessionId: Expire a user session./validate/:sessionId: Validate an active user session.APIs (Application Programming Interfaces) serve as the communication channels between different microservices and external components. The APIs define the rules and protocols for how different software components should interact. In the context of an authentication system, various APIs are used for seamless communication between microservices:
RESTful APIs are commonly used for communication between microservices due to their simplicity and statelessness. Each microservice exposes a set of RESTful endpoints, allowing other services to make HTTP requests to perform specific actions.
For secure communication and data exchange, token-based APIs, such as JSON Web Tokens (JWT), are often employed. JWTs can be used to carry authentication information securely between microservices without the need to repeatedly verify credentials.
OpenID Connect and OAuth 2.0 are widely adopted authentication and authorization protocols. They define a set of rules for secure and standardized user authentication, allowing third-party applications to access user data without exposing sensitive credentials.
GraphQL is an alternative to RESTful APIs that allows clients to request only the specific data they need. In the context of an authentication system, GraphQL can be used to efficiently query user information and manage authentication-related operations.
Describes how APIs are developed and structured to enable communication between different system components.
Handles new user account creation and registration requests.
Endpoint:
/api/user/register
Description: Allows users to securely create their accounts.
Manages user login and authentication process.
Endpoint:
/api/user/authenticate
Description: Initiates user authentication.
Controls access to secured resources based on authentication.
Endpoint:
/api/resource/access
Description: Allows access to a protected resource.
Enables users to change or update their account password securely.
Endpoint:
/api/user/update-password
Description: Updates the user's password.
Consideration for scalability is crucial to ensure the system can handle increased load. Key strategies for scalability in an authentication system include:
Implement load balancing mechanisms to distribute incoming authentication requests evenly across multiple servers. This ensures optimal resource utilization and prevents any single point of failure.
Design the system to scale horizontally, allowing the addition of more servers or instances to accommodate growing user traffic.
Utilize caching mechanisms for frequently accessed data, such as user credentials or session information, to reduce the load on the database and improve response times.
Implement auto-scaling features to dynamically adjust resources based on demand. This ensures efficient resource utilization during peak periods and cost-effectiveness during low traffic times.