Commit Graph

9 Commits

Author SHA1 Message Date
db123-test
7930f2ec99 fix: validate action parameter and correct database health check logic
- Add whitelist of valid actions to prevent arbitrary action values
- Fix error handling to properly detect database failures

Previously, any action value was accepted without validation, which could lead to unexpected behavior. The health check also incorrectly set dbOK to true when queries succeeded, now correctly sets it to false when errors occur.
2026-05-11 12:19:47 +03:30
db123-test
ef7abd386e fix(auth): corrected apu_client_ip to only return an string instead of array with valid true 2026-05-07 18:15:06 +03:30
db123-test
3ba6d61117 fix: use sql.NullString for apiClientIP in logs query
Change apiClientIP from string to sql.NullString to properly handle
NULL values from the database, preventing potential runtime errors
when the column contains NULL entries.
2026-05-07 17:46:23 +03:30
db123-test
c3869f4f10 feat: add env file support and parameterize SQL queries
Add .env and .env.local loading with InitEnv() helper that reads
environment variables from config files without overwriting existing
values.

Refactor SQL queries to use parameterized arguments instead of
string formatting for LIMIT/OFFSET clauses, improving query security
and preventing SQL injection vulnerabilities.

Clean up unnecessary rows.Close() calls and simplify error handling
in database query functions.
2026-05-05 19:13:42 +03:30
db123-test
3202906153 fix(db): convert expires_at to RFC3339 string format and simplify cleanup 2026-05-05 18:25:40 +03:30
db123-test
a59509f017 refactor: auth and whitelist system for better organization
- Remove Config parameter from authHandler and CheckAuth
- Add doc comments and extract helper functions for IP extraction
- Refactor database operations (addPerm, addTemp, delPerm)
- Add CIDR matching support in IsPermanentWhitelisted
- Add request struct for temporary whitelist handler
- Update route registrations to match new function signatures
2026-05-05 18:18:00 +03:30
db123-test
3ce20314db refactor: rename 'entry' to 'ip' in audit log schema
Rename the 'entry' column to 'ip' throughout the database schema and
function signatures for clarity. This affects both the CREATE TABLE
statement and all INSERT queries in the audit_log table.

The parameter naming in AddPermanentEntry, DeletePermanentEntry, and
AddTempEntry functions has also been updated to reflect the more
specific 'ip' terminology. Corresponding log messages have been
adjusted to use 'temp ip' instead of 'temp entry' for consistency.
2026-05-05 17:54:07 +03:30
db123-test
31fc204ef2 refactor: rename entry field to ip across whitelist API
Rename the `entry` field to `ip` throughout the whitelist API for
clarity and consistency. This affects API request/response bodies,
path parameters, OpenAPI spec, documentation, and database queries
in the audit log endpoint.
2026-05-05 17:44:52 +03:30
db123-test
33b0e4e30e refactor: move Go source files to src/ directory
Organize project structure by relocating all Go files to a src/ directory,
following standard Go project conventions and improving code organization.
2026-05-05 11:46:58 +03:30