Skip to main content

Overview

The Saved Passwords feature allows authenticated users to securely store generated passwords along with metadata such as the associated URL and page name. Each user has their own isolated password vault with full CRUD (Create, Read, Update, Delete) capabilities.

Data Model

The SavedPasswords model stores password entries with associated metadata (models.py:5-14):

Page Name

Optional descriptive label for the password entry (e.g., “GitHub”, “Email Account”)

URL

Required URL field to identify where the password is used

Password

The actual password string to be saved
Each password entry is linked to a specific user via a foreign key relationship. The on_delete=models.CASCADE ensures that when a user is deleted, all their saved passwords are automatically removed.

Saving Passwords

Authenticated users can save passwords with metadata through the API.

API Endpoint

URL: POST /api/passwords/save/ Authentication: Required (IsAuthenticated) Request Body:
Response:

Implementation

The save endpoint is implemented in views.py:30-59:

Frontend Form

The React form component for saving passwords (FormSavedPasswords.jsx):
The form pre-fills the password field with a newly generated password, but users can modify it before saving.

Viewing Saved Passwords

Users can retrieve all their saved passwords through a dedicated endpoint.

API Endpoint

URL: GET /api/passwords/saved/ Authentication: Required (IsAuthenticated) Response:

Implementation

The view endpoint (views.py:62-85):
The endpoint automatically filters passwords by the authenticated user, ensuring users can only access their own password entries.

Updating Saved Passwords

Users can modify existing password entries using the update endpoint.

API Endpoint

URL: PUT /api/passwords/update/<pk>/ Authentication: Required (IsAuthenticated) Request Body (partial updates supported):
Response:

Implementation

The update endpoint (views.py:88-103):
The endpoint verifies that the password entry belongs to the authenticated user (pk=pk, user=request.user), preventing unauthorized modifications.

Deleting Saved Passwords

Users can permanently delete password entries they no longer need.

API Endpoint

URL: DELETE /api/passwords/delete/<pk>/ Authentication: Required (IsAuthenticated) Response:

Implementation

The delete endpoint (views.py:106-117):

CRUD Operations Summary

Create

POST /api/passwords/save/ - Save new password with metadata

Read

GET /api/passwords/saved/ - Retrieve all saved passwords

Update

PUT /api/passwords/update/<pk>/ - Modify existing password entry

Delete

DELETE /api/passwords/delete/<pk>/ - Remove password entry

UI Features

The frontend provides several components for managing saved passwords:

Password Display Component

The ViewPasswords.jsx component displays saved passwords in a user-friendly format with search and filter capabilities.

Search Functionality

The SearchBar.jsx component allows users to quickly find saved passwords by name or URL. The ModalSavedPasswords.jsx component provides a modal dialog for viewing and editing password details.

Data Serialization

The SavedPasswordsSerializer handles all data validation and serialization (serializers.py:5-8):

Security Considerations

Important Security Notes:
  • Passwords are stored in plain text in the database. For production use, implement encryption at rest.
  • Always use HTTPS to prevent password interception during transmission.
  • Implement proper access controls to ensure users can only access their own passwords.
  • Consider implementing password encryption using libraries like django-encrypted-model-fields.

User Isolation

The system enforces strict user isolation:

Error Handling

All endpoints include comprehensive error handling:
For best practices, implement client-side validation before submitting password data to reduce unnecessary API calls and improve user experience.