Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Harden auth impl #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
fulleni merged 22 commits into main from harden_auth_impl
Jul 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cedbe20
chore(env): add JWT secret key requirement and update CORS origin
fulleni Jul 20, 2025
f0b2068
feat(config): add JWT secret key environment variable retrieval
fulleni Jul 20, 2025
1639d16
refactor(auth): replace hardcoded secret key with environment variable
fulleni Jul 20, 2025
a1468cb
feat(auth): add MongoDB token blacklist service
fulleni Jul 20, 2025
0d5e933
refactor(config): replace token blacklist service
fulleni Jul 20, 2025
01a2e5e
feat(auth): Add MongoDB verification code storage
fulleni Jul 20, 2025
0cb5741
refactor(mongodb): Improve verification code storage
fulleni Jul 20, 2025
8e74597
refactor(services): Replace in-memory verification code storage
fulleni Jul 20, 2025
1550783
refactor(services): remove unnecessary initialization
fulleni Jul 20, 2025
eb04f61
refactor(services): remove unnecessary init method
fulleni Jul 20, 2025
8e52d81
feat(database): add indexes to verification codes and tokens
fulleni Jul 20, 2025
48cbcfe
refactor(auth): replace print statements with logging
fulleni Jul 20, 2025
76589a3
fix(authorization): replace print statements with logger
fulleni Jul 20, 2025
7349220
fix(error_handler): use logger instead of print
fulleni Jul 20, 2025
2ea1f83
refactor: remove unused auth & verification services
fulleni Jul 20, 2025
74935bf
fix(auth): improve anonymous auth error handling
fulleni Jul 20, 2025
981e366
fix(auth): improve error handling in delete-account
fulleni Jul 20, 2025
205acd8
fix(auth): improve error handling in request-code handler
fulleni Jul 20, 2025
ee01c85
fix(auth): improve sign-out error logging
fulleni Jul 20, 2025
170539f
fix: improve error logging in verify-code handler
fulleni Jul 20, 2025
85a289b
fix(api): replace print statements with logger
fulleni Jul 20, 2025
89e2417
feat(auth): configure JWT issuer and expiry
fulleni Jul 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(config): add JWT secret key environment variable retrieval
- Implement jwtSecretKey getter in EnvironmentConfig class
- Add error handling for missing JWT_SECRET_KEY environment variable
- Include detailed error message when JWT_SECRET_KEY is not set
  • Loading branch information
fulleni committed Jul 20, 2025
commit f0b2068397d269d5b57cd051b6e953d2196b2e8d
18 changes: 18 additions & 0 deletions lib/src/config/environment_config.dart
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ abstract final class EnvironmentConfig {
return dbUrl;
}

/// Retrieves the JWT secret key from the environment.
///
/// The value is read from the `JWT_SECRET_KEY` environment variable.
///
/// Throws a [StateError] if the `JWT_SECRET_KEY` environment variable is not
/// set, as the application cannot function without it.
static String get jwtSecretKey {
final jwtKey = _env['JWT_SECRET_KEY'];
if (jwtKey == null || jwtKey.isEmpty) {
_log.severe('JWT_SECRET_KEY not found in environment variables.');
throw StateError(
'FATAL: JWT_SECRET_KEY environment variable is not set. '
'The application cannot start without a JWT secret.',
);
}
return jwtKey;
}

/// Retrieves the current environment mode (e.g., 'development').
///
/// The value is read from the `ENV` environment variable.
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /