~
This commit is contained in:
parent
2d67963656
commit
be56240ddc
2 changed files with 27 additions and 31 deletions
|
|
@ -240,32 +240,24 @@ let verify_auditor_add_sig
|
|||
h_auditor_url= Bin_type.Hash_64_cstr.hash auditor_url;
|
||||
}
|
||||
|
||||
(* todo: there is something about use of monotonic time + protection against replay attack that I don't understand *)
|
||||
let update_auditor ~db_conn
|
||||
AuditorSetupMessage.
|
||||
{ auditor_url; auditor_name; auditor_pub; master_sig= _; validity_start }
|
||||
=
|
||||
(* TODO timestamps last_change +/- checks *)
|
||||
(* todo: there is something about use of monotonic time
|
||||
+ protection against replay attack that I don't understand *)
|
||||
let update_auditor ~db_conn v =
|
||||
let auditor_pub = v.AuditorSetupMessage.auditor_pub in
|
||||
let validity_start = v.AuditorSetupMessage.validity_start in
|
||||
let* last_date_opt =
|
||||
Pg.lookup_auditor_timestamp db_conn auditor_pub |> unwrap_err_caqti
|
||||
in
|
||||
match last_date_opt with
|
||||
| None ->
|
||||
let+ () =
|
||||
Pg.insert_auditor db_conn ~auditor_pub ~auditor_url ~auditor_name
|
||||
~start_date:validity_start
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
let+ () = Pg.insert_auditor db_conn v |> unwrap_err_caqti in
|
||||
()
|
||||
| Some last_date ->
|
||||
let cmp = Timestamp.compare last_date validity_start |> Option.get in
|
||||
if cmp > 0 then Error "more recent management auditor already present"
|
||||
else
|
||||
let enabled = true in
|
||||
let+ () =
|
||||
Pg.update_auditor db_conn ~auditor_pub ~auditor_url ~auditor_name
|
||||
~enabled ~change_date:validity_start
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
let+ () = Pg.update_auditor db_conn v |> unwrap_err_caqti in
|
||||
()
|
||||
|
||||
let verify_auditor_disable_sig auditor_pub
|
||||
|
|
@ -285,10 +277,8 @@ let auditor_disable ~db_conn auditor_pub
|
|||
let cmp = Timestamp.compare last_date validity_end |> Option.get in
|
||||
if cmp > 0 then Error "more recent management auditor already present"
|
||||
else
|
||||
let enabled = false in
|
||||
let+ () =
|
||||
Pg.update_auditor db_conn ~auditor_pub ~auditor_url:""
|
||||
~auditor_name:"" ~enabled ~change_date:validity_end
|
||||
Pg.disable_auditor db_conn ~auditor_pub ~change_date:validity_end
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue