You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2020/11/04 15:44:06 UTC

[couchdb] branch aegis_db_info created (now c067e95)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch aegis_db_info
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at c067e95  Add an "encryption" object to db info

This branch includes the following new commits:

     new c067e95  Add an "encryption" object to db info

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Add an "encryption" object to db info

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch aegis_db_info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c067e9501f9a05801bb0dd811f5c0fa01ac6f90d
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Nov 4 15:39:09 2020 +0000

    Add an "encryption" object to db info
    
    The encryption object contains a boolean "enabled"
    property. Additional properties might be added by the key manager.
---
 src/aegis/src/aegis.erl             | 10 ++++++++++
 src/aegis/src/aegis_key_manager.erl |  8 ++++++++
 src/fabric/src/fabric2_fdb.erl      |  4 +++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/aegis/src/aegis.erl b/src/aegis/src/aegis.erl
index e8a0b4b..08fdbb2 100644
--- a/src/aegis/src/aegis.erl
+++ b/src/aegis/src/aegis.erl
@@ -20,6 +20,7 @@
 -export([
     init_db/2,
     open_db/1,
+    get_db_info/1,
 
     decrypt/2,
     decrypt/3,
@@ -39,6 +40,15 @@ open_db(#{} = Db) ->
     }.
 
 
+get_db_info(#{is_encrypted := IsEncrypted} = Db) ->
+    case erlang:function_exported(?AEGIS_KEY_MANAGER, get_db_info, 1) of
+        true ->
+            [{enabled, IsEncrypted} | ?AEGIS_KEY_MANAGER:get_db_info(Db)];
+        false ->
+            [{enabled, IsEncrypted}]
+    end.
+
+
 encrypt(#{} = _Db, _Key, <<>>) ->
     <<>>;
 
diff --git a/src/aegis/src/aegis_key_manager.erl b/src/aegis/src/aegis_key_manager.erl
index aa9e342..4426c4f 100644
--- a/src/aegis/src/aegis_key_manager.erl
+++ b/src/aegis/src/aegis_key_manager.erl
@@ -20,3 +20,11 @@
 
 
 -callback open_db(Db :: #{}) -> {ok, binary()} | false.
+
+
+-callback get_db_info(Db :: #{}) -> list().
+
+
+-optional_callbacks([
+    get_db_info/1
+]).
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 36fa451..aa2bade 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -495,7 +495,9 @@ get_info(#{} = Db) ->
         tx := Tx,
         db_prefix := DbPrefix
     } = ensure_current(Db),
-    get_info_wait(get_info_future(Tx, DbPrefix)).
+    DbInfo = get_info_wait(get_info_future(Tx, DbPrefix)),
+    AegisProps = aegis:get_db_info(Db),
+    [{encryption, {AegisProps}} | DbInfo].
 
 
 get_info_future(Tx, DbPrefix) ->