Commit Graph

94 Commits

Author SHA1 Message Date
f2753e1495 refactor: declaring controller methods externally because the big idiot swaggo does not want to work unless the comments are attached to a gin handler func;
fix: swagger docs work now;
chore: remove incomplete account and profile controllers;
fix: correct client info type in request middleware
2025-07-17 22:37:07 +03:00
d6e2d02bff refactor: transitioned auth controller to use the new controller structure;
feat: setup DI for controllers;
refactor: marked old utils and routes package parts as deprecated
2025-07-17 21:42:47 +03:00
f9d7439def fix: Setup interface mismatch;
refactor: GetRequest now panics on missing client_info since it is only supposed to be used on handlers behind AuthMiddleware
2025-07-17 17:53:07 +03:00
7298ab662f experiment: prototyping new ASP.NET-like controllers;
feat: ControllerMethod struct for storing data about an individual API endpoint;
feat: controllerImpl struct for setting up a controller;
feat: GetRequest method for parsing and validating a request with automatic abortion on binding/validation errors
2025-07-17 17:20:48 +03:00
ec56f64420 fix: wrong role 'guest' instead of 'user' defaulting in schema 2025-07-17 04:35:34 +03:00
249bbe4a98 feat: add user role support to database and queries;
fix: add max length validation for refresh token in RefreshRequest;
refactor: use named constants for cache durations in AuthService;
refactor: select all user columns in GetValidUserByLoginCredentials query;
2025-07-17 04:31:25 +03:00
b986d45d82 fix: handle large terminated sessions caching with pagination to prevent RAM overflow;
feat: add paginated query for terminated sessions GUIDs with limit and offset;
refactor: batch processing terminated sessions in Redis with pipeline;
chore: log batch caching progress for terminated sessions;
fix: set TTL for session termination cache keys (8 hours);
refactor: update SQL query for terminated sessions to use pagination;
fix: correct loop structure in auth service initialization
2025-07-17 04:09:15 +03:00
827928178e feat: add change password endpoint using old password;
feat: implement change password service method with validation;
fix: correct ErrorIsOneOf function logic to return true on match;
refactor: rename 'log_out_accounts' to 'log_out_sessions' for clarity;
refactor: update session termination to return GUIDs and cache in Redis;
fix: ensure RollbackOnError only rolls back uncommitted transactions;
fix: handle transaction commit errors properly in dbHelper;
refactor: add helper methods for session termination and registration;
refactor: pass client info to login and registration complete methods;
fix: improve token validation error handling in refresh endpoint;
refactor: update auth middleware to set session info correctly;
chore: remove unused ClientInfo DTO;
fix: correct password reset complete to use session termination helper;
refactor: adjust database queries for session management;
chore: update SQL schema and queries for sessions;
docs: update swagger docs with new endpoint and model changes
2025-07-17 03:44:22 +03:00
8b558eaf5f feat: fully implemented Refresh method;
fix: Improve error handling in Refresh method for token validation;
fix: Update Refresh route to use correct request model;
fix: Correct request model for password reset complete route;
fix: Redis pipeline error handling in AuthService constructor;
fix: Refresh method wanted access token;
refactor: Enhance error handling for unexpected token validation errors;
refactor: Simplify claims extraction in ValidateToken method;
fix: Ensure session termination state is correctly dereferenced;
refactor: Return structured session info in ValidateToken method;
feat: New util method to check if an error is one of multiple given ones;
2025-07-15 23:32:25 +03:00
e465da6854 refactor: Simplify AuthMiddleware;
refactor: Move token validation logic to AuthService;
refactor: Remove Redis cache checks from middleware;
fix: Improve error handling for token validation;
refactor: Update Refresh method to use new validation logic;
chore: Clean up unused imports and comments
2025-07-15 22:37:41 +03:00
a582b75c82 feat: new ValidateToken method for AuthService, based on code from the monolithic implementation of auth middleware;
feat: add detailed authentication error types;
2025-07-15 21:59:05 +03:00
b3a405016e refactor: introduce DTOs for claims, session, and request handling
feat: add token validation service method
refactor: update middleware to use structured DTOs
feat: implement session info propagation through context
refactor: replace ad-hoc structs with DTOs in middleware
chore: organize auth-related data structures
2025-07-15 20:54:12 +03:00
ee6cff4104 feat: add registration attempt rate limiting with Redis
feat: prevent email enumeration by caching registration state
fix: correct Redis key formatting for session termination cache
refactor: improve registration flow with Redis cooldown checks
chore: add Redis caching for registration in-progress state
2025-07-15 02:55:26 +03:00
d8ea9f79c6 feat: add session expiration tracking and validation
feat: implement Redis caching for terminated sessions
feat: add new session GUID queries for validation
refactor: extend Session model with last_refresh_exp_time
refactor: update token generation to include role and session
refactor: modify auth middleware to validate session status
refactor: replace GetUserSessions with GetValidUserSessions
chore: add uuid/v5 dependency
fix: update router to pass dependencies to auth middleware
chore: update SQL schema and queries for new expiration field
2025-07-14 20:44:30 +03:00
24cb8ecb6e feat: implemented controller methods for passwordresetcomplete, refresh in auth controller 2025-07-13 20:58:36 +03:00
95294686b7 feat: PasswordResetBegin of auth controller;
fix: sql query updateLoginInformationByUsername used in-database hashing;
refactor: renamed LogOutAccounts into LogOutSessions in models/auth;
refactor: added error checks on opening transactions for all auth service methods;
refactor: added error checks on commiting transactions likewise;
refactor: simplified PasswordResetBegin logic;
feat: implemented PasswordResetComplete method of auth service;
2025-07-13 19:10:34 +03:00
65ea47dbb6 feat: new RollbackOnError method added for transactional db helper and integrated into auth service 2025-07-13 15:57:34 +03:00
a3bebd89be chore: todo comments;
fix: txless creation of confirmation code in passwordresetbegin
2025-07-13 02:18:46 +03:00
a2dd8993a6 feat: auth service logic for purging expired unverified accounts upon registration, new sql queries for this purpose 2025-07-13 01:57:19 +03:00
8fa57eddb1 feat: implemented PasswordResetBegin method in auth service with cooldown for each email being stored in redis 2025-07-12 19:32:53 +03:00
b91ff2c802 refactor: added redisclient connection error check 2025-07-12 17:04:09 +03:00
541847221b chore: tidy swagger comments;
feat: password reset models;
feat: verification code validator
2025-07-11 17:44:48 +03:00
c988a16783 refactor: removed error logs from smtp service since they are redundant 2025-07-10 12:21:23 +03:00
f59b647b27 feat: development compose file;
fix: smtp service
2025-07-10 01:51:48 +03:00
15c140db31 feat: implemented smtp service;
feat: implemented registration emails;
fix: config variables for password length used the same env variable;
refactor: all available config variables added to docker-compose.yml
2025-07-09 23:26:30 +03:00
63b63038d1 feat: initialized smtp service;
refactor: config now returns a copy of a struct to prevent editing;
chore: corrected identation
2025-07-08 23:21:00 +03:00
b5fdcd5dca feat: smtp config;
chore: added license comment blocks to the rest of backend and to sqlc schema & queries
2025-07-07 01:31:21 +03:00
72a512bb4f feat: automatic termination of older sessions on login (temporary until release 4);
fix: login controller method not returning tokens
2025-07-06 14:45:36 +03:00
8588a17928 chore: updated docs 2025-07-06 14:03:55 +03:00
bc9f5c6d3c fix: unique user id in user session;
feat: login controller method;
fix: name validation hander
2025-07-06 14:00:59 +03:00
333817c9e1 refactor: moved hashing logic into application layer for security;
fix: error handling in auth service for database;
refactor: removed redundant taken email check;
chore: removed todos that were completed/not needed;
fix: leaking transactions in complete registration and login on error;
refactor: got rid of txless requests during transactions;
2025-07-06 13:01:08 +03:00
5e32c3cbd3 refactor: password requirements variables;
refactor: password validation function moved to custom validators;
refactor: adjusted model's validation fields
2025-07-05 17:50:01 +03:00
8319afc7ea refactor/fix: now using pgx errors for postgres error checking instead of trying to look up the error code;
feat: implemented working custom validation;
fix: authservice begin/complete registration
2025-07-05 03:08:00 +03:00
0a51727af8 refactor: updated swagger;
feat: helper function in errors for checking postgres error types;
feat: sql query method for finding users by their email;
feat: registration begin/complete with checking existing username/email;
refactor: error handling in controller
2025-07-03 04:33:25 +03:00
d08db300fc fix: getconfirmationcode query 2025-07-02 14:09:10 +03:00
96e41efdec feat: added session guid and token type fields to jwt tokens;
feat: very minimal implementation of registration functions;
refactor: login function now uses the transactional db helper function and creates a session;
feat: enum for jwt token type
2025-07-01 14:18:01 +03:00
284d959bc3 feat: new general and auth errors;
feat: NewPointer helper function in utils;
refactor: length validation in auth models
2025-06-30 01:34:59 +03:00
e2d83aa779 refactor: database update methods use coalesce to omit nil fields 2025-06-27 13:30:03 +03:00
69d55ce060 fix: added missing return statement;
refactor: redundant comments
2025-06-25 16:21:16 +03:00
cbcfb8a286 feat: middleware for request body parsing, validation and authentication;
feat: helper function for getting request info from gin context
2025-06-24 17:31:48 +03:00
c2059dcd6e feat: middlewares for authorization and automatic request parsing;
feat: roles enum
2025-06-24 13:57:39 +03:00
be9aee7145 chore: GPL-3.0 license propagated into *.go files in backend 2025-06-24 01:37:47 +03:00
cfe60cfb8e chore: corrected misleading error descriptions, removed redundant comments 2025-06-24 01:11:49 +03:00
e5d245519a feat: preparing structures for validation features;
feat: config variables for password requirements;
feat: util function for validating passwords
2025-06-24 00:25:59 +03:00
0a00a5ee2b feat: registrationBegin method without email;
fix: missing sqlc query parameter name;
feat: util for generating security codes;
feat: enums package
2025-06-23 16:23:46 +03:00
1b55498b00 refactor: a better DI-friendy logger implementation that doesn't suck 2025-06-23 14:18:25 +03:00
ea3743cb04 fixed: error handling in commit;
refactor: exposed untransactional queries for transactional db helper again but with a clearer name this time since it still may be useful
2025-06-22 12:41:22 +03:00
613deae8e2 feat: db regular and transactional helpers to reduce boilerplate 2025-06-21 20:04:20 +03:00
e1df58b434 Merge pull request 'fix: viper not unmarshalling env variables into the struct' (#3) from fix-config into main
Reviewed-on: #3
2025-06-21 16:20:46 +03:00
ad118cc832 chore: removed database url print in config 2025-06-21 16:20:20 +03:00