feat(01-01): Create secure Supabase configuration system
- Created .env template with SUPABASE_URL and SUPABASE_ANON_KEY placeholders - Added .env to .gitignore to prevent committing secrets - Created SupabaseConstants class with secure environment loading - Added validation to ensure required environment variables are set - Created core/constants directory structure
This commit is contained in:
47
.gitignore
vendored
Normal file
47
.gitignore
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
|
||||
# Environment variables (secrets)
|
||||
.env
|
||||
.env.*
|
||||
25
lib/core/constants/supabase_constants.dart
Normal file
25
lib/core/constants/supabase_constants.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
/// Supabase configuration constants
|
||||
/// Environment variables are loaded securely from .env file
|
||||
class SupabaseConstants {
|
||||
SupabaseConstants._();
|
||||
|
||||
static late final String supabaseUrl;
|
||||
static late final String supabaseAnonKey;
|
||||
|
||||
/// Initialize Supabase constants from environment variables
|
||||
static Future<void> initialize() async {
|
||||
await dotenv.load(fileName: '.env');
|
||||
|
||||
supabaseUrl = dotenv.env['SUPABASE_URL'] ?? '';
|
||||
supabaseAnonKey = dotenv.env['SUPABASE_ANON_KEY'] ?? '';
|
||||
|
||||
if (supabaseUrl.isEmpty || supabaseAnonKey.isEmpty) {
|
||||
throw Exception(
|
||||
'SUPABASE_URL and SUPABASE_ANON_KEY must be set in .env file\n'
|
||||
'Get these values from Supabase Dashboard → Settings → API',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user