Authentication Overview
The Sistema de Gestión de Propiedades API uses HTTP Basic Authentication to secure administrative operations. Public read endpoints don’t require authentication, but creating, updating, or deleting properties requires valid credentials.Authentication Model
Public Endpoints (No Auth Required)
These endpoints are publicly accessible:GET /api/propiedades- List all propertiesGET /api/propiedades/{id}- Get a specific propertyGET /doc- OpenAPI specificationGET /ui- Swagger UI
Protected Endpoints (Basic Auth Required)
These administrative endpoints require authentication:POST /api/propiedades- Create a new propertyPATCH /api/propiedades/{id}- Update a propertyDELETE /api/propiedades/{id}- Delete a propertyGET /api/auth/verify- Verify credentials
HTTP Basic Authentication
Basic Authentication is a simple authentication scheme built into the HTTP protocol. Credentials are sent as base64-encodedusername:password pairs in the Authorization header.
How It Works
Example
If your credentials are:- Username:
admin - Password:
secret123
Making Authenticated Requests
- curl
- JavaScript
- Python
Verifying Credentials
Before saving credentials in your application, you can verify them using the verification endpoint:Security Best Practices
Recommendations
- Use HTTPS Only - The API is served over HTTPS, ensuring credentials are encrypted in transit
- Don’t Hardcode Credentials - Store credentials in environment variables or secure configuration
- Rotate Credentials Regularly - Update passwords periodically
- Limit Credential Exposure - Only share admin credentials with trusted team members
- Validate Before Storing - Use the
/api/auth/verifyendpoint before persisting credentials
Environment Variables
For deployment, credentials are configured using Cloudflare Workers environment variables:ADMIN_USER- Administrator usernameADMIN_PASS- Administrator password
Error Responses
401 Unauthorized
Returned when:- No
Authorizationheader is provided - Credentials are invalid
- Credentials are malformed
Example Error Scenario
Implementation Details
The API uses Hono’sbasicAuth middleware to validate credentials:
Next Steps
Basic Auth Details
Deep dive into Basic Authentication implementation
Environment Variables
Configure authentication credentials for deployment
Creating Properties
Use authentication to create properties
Verify Endpoint
API reference for credential verification