Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Email password auth method with refresh tokens and sqlite3 default db support. Only supporting for argon2 hashing for now.
Copilot summary:
Authentication Service Implementation:
authS/authS.go
: Added theAuthService
struct and methods for handling email-password signup (EmailSignup
), login (EmailLogin
), and token refresh (HandleRefresh
). This includes request validation, password hashing, token generation, and database interactions.Configuration Setup:
config/config.go
: Defined theConfig
struct to hold configuration settings such as JWT secrets, token TTLs, database configuration, and password hashing settings. Added aDefaultConfig
function to provide default values.Database Interface and Implementation:
db/interface.go
: Created theDatabase
interface with methods for checking email existence, managing users, and handling refresh tokens.db/sqlite3/sqlite3.go
: Implemented theDatabase
interface for SQLite3, including methods for creating users, storing refresh tokens, and checking token revocation.Utility Functions:
internal/utils/jwt.go
: Added utility functions for generating access and refresh tokens using JWT.internal/utils/password.go
: Implemented password hashing and verification using Argon2 algorithm.internal/utils/utils.go
: Added utility functions for validating email and password, and generating unique IDs.Example Application:
example/main.go
: Created an example application to demonstrate the usage of theAuthService
, including routes for signup, login, and token refresh.These changes collectively establish a robust foundation for an authentication system with secure password handling and token-based session management.