chore: remove jwt secret env variable (#3291)

This commit is contained in:
Nathan.fooo 2023-08-30 11:51:33 +08:00 committed by GitHub
parent b88aed887a
commit 897d7980f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 22 deletions

View File

@ -29,21 +29,12 @@ abstract class Env {
defaultValue: '',
)
static final String supabaseAnonKey = _Env.supabaseAnonKey;
@EnviedField(
obfuscate: true,
varName: 'SUPABASE_JWT_SECRET',
defaultValue: '',
)
static final String supabaseJwtSecret = _Env.supabaseJwtSecret;
}
bool get isSupabaseEnabled {
// Only enable supabase in release and develop mode.
if (integrationMode().isRelease || integrationMode().isDevelop) {
return Env.supabaseUrl.isNotEmpty &&
Env.supabaseAnonKey.isNotEmpty &&
Env.supabaseJwtSecret.isNotEmpty;
return Env.supabaseUrl.isNotEmpty && Env.supabaseAnonKey.isNotEmpty;
} else {
return false;
}

View File

@ -34,7 +34,6 @@ AppFlowyEnv getAppFlowyEnv() {
enable_sync: true,
url: Env.supabaseUrl,
anon_key: Env.supabaseAnonKey,
jwt_secret: Env.supabaseJwtSecret,
);
return AppFlowyEnv(

View File

@ -27,13 +27,11 @@ class SupabaseConfiguration {
final bool enable_sync;
final String url;
final String anon_key;
final String jwt_secret;
SupabaseConfiguration({
this.enable_sync = true,
required this.url,
required this.anon_key,
required this.jwt_secret,
});
factory SupabaseConfiguration.fromJson(Map<String, dynamic> json) =>

View File

@ -22,7 +22,6 @@ SupabaseConfiguration _$SupabaseConfigurationFromJson(
enable_sync: json['enable_sync'] as bool? ?? true,
url: json['url'] as String,
anon_key: json['anon_key'] as String,
jwt_secret: json['jwt_secret'] as String,
);
Map<String, dynamic> _$SupabaseConfigurationToJson(
@ -31,5 +30,4 @@ Map<String, dynamic> _$SupabaseConfigurationToJson(
'enable_sync': instance.enable_sync,
'url': instance.url,
'anon_key': instance.anon_key,
'jwt_secret': instance.jwt_secret,
};

View File

@ -5,7 +5,6 @@ use flowy_error::{ErrorCode, FlowyError};
pub const ENABLE_SUPABASE_SYNC: &str = "ENABLE_SUPABASE_SYNC";
pub const SUPABASE_URL: &str = "SUPABASE_URL";
pub const SUPABASE_ANON_KEY: &str = "SUPABASE_ANON_KEY";
pub const SUPABASE_JWT_SECRET: &str = "SUPABASE_JWT_SECRET";
pub const SUPABASE_DB: &str = "SUPABASE_DB";
pub const SUPABASE_DB_USER: &str = "SUPABASE_DB_USER";
@ -20,8 +19,6 @@ pub struct SupabaseConfiguration {
pub url: String,
/// The key of the supabase server.
pub anon_key: String,
/// The secret used to sign the JWT tokens.
pub jwt_secret: String,
}
impl SupabaseConfiguration {
@ -31,9 +28,6 @@ impl SupabaseConfiguration {
.map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_URL"))?,
anon_key: std::env::var(SUPABASE_ANON_KEY)
.map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_ANON_KEY"))?,
jwt_secret: std::env::var(SUPABASE_JWT_SECRET).map_err(|_| {
FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_JWT_SECRET")
})?,
})
}
@ -41,6 +35,5 @@ impl SupabaseConfiguration {
pub fn write_env(&self) {
std::env::set_var(SUPABASE_URL, &self.url);
std::env::set_var(SUPABASE_ANON_KEY, &self.anon_key);
std::env::set_var(SUPABASE_JWT_SECRET, &self.jwt_secret);
}
}