-
Notifications
You must be signed in to change notification settings - Fork 3
added way to build without ee features #17
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,8 +56,10 @@ public class DatabaseManager { | |
| public func buildDatabaseConfig(_ config: [AnyHashable: Any]?) -> DatabaseConfiguration { | ||
| var databaseConfiguration = DatabaseConfiguration() | ||
| if let encKey = config?["encryptionKey"] as? String { | ||
| let key = EncryptionKey.password(encKey) | ||
| databaseConfiguration.encryptionKey = key | ||
| #if COUCHBASE_ENTERPRISE | ||
| let key = EncryptionKey.password(encKey) | ||
| databaseConfiguration.encryptionKey = key | ||
| #endif | ||
| } | ||
| if let directory = config?["directory"] as? String { | ||
| // Used to auto set the database to be in the documents folder, | ||
|
|
@@ -149,12 +151,14 @@ public class DatabaseManager { | |
| guard let database = self.getDatabase(databaseName) else { | ||
| throw DatabaseError.invalidDatabaseName(databaseName: databaseName) | ||
| } | ||
| if let newKeyString = newKey { | ||
| let encryptionKey = EncryptionKey.password(newKeyString) | ||
| try database.changeEncryptionKey(encryptionKey) | ||
| return | ||
| } | ||
| try database.changeEncryptionKey(nil) | ||
| #if COUCHBASE_ENTERPRISE | ||
| if let newKeyString = newKey { | ||
| let encryptionKey = EncryptionKey.password(newKeyString) | ||
| try database.changeEncryptionKey(encryptionKey) | ||
| return | ||
| } | ||
| try database.changeEncryptionKey(nil) | ||
| #endif | ||
|
Comment on lines
+154
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a non-enterprise build, calling Since this function can throw, it's better to throw an error in the non-enterprise case to clearly signal that the feature is not available. This prevents any misunderstanding about the database's encryption state. #if COUCHBASE_ENTERPRISE
if let newKeyString = newKey {
let encryptionKey = EncryptionKey.password(newKeyString)
try database.changeEncryptionKey(encryptionKey)
return
}
try database.changeEncryptionKey(nil)
#else
throw DatabaseError.unknownError(message: "Changing the database encryption key is an enterprise-only feature.")
#endif |
||
| return | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building without
COUCHBASE_ENTERPRISE, theencryptionKeyfrom the configuration is silently ignored. This can be misleading, as a developer might assume the database is being encrypted when it is not. This could lead to sensitive data being stored unencrypted without any warning.To prevent this, it's better to provide explicit feedback. Since this function doesn't throw, consider adding an
#elseblock to print a warning to the console.