add auditors diable
This commit is contained in:
parent
c150ff242c
commit
bffed5d0b4
2 changed files with 40 additions and 1 deletions
|
|
@ -99,3 +99,16 @@ let management_auditors req server _env =
|
||||||
Ok ""
|
Ok ""
|
||||||
in
|
in
|
||||||
respond_with_res res req
|
respond_with_res res req
|
||||||
|
|
||||||
|
let management_auditors_disable_jsont = AuditorSetupMessage.jsont
|
||||||
|
|
||||||
|
let management_auditors_disable req auditor_pub server _env =
|
||||||
|
let open Management in
|
||||||
|
let db_conn = Vif.Server.device Devices.db_connection server in
|
||||||
|
let res =
|
||||||
|
let* v = Vif.Request.of_json req |> unwrap_err_msg in
|
||||||
|
let* () = verify_auditor_disable_sig auditor_pub v in
|
||||||
|
let* () = auditor_disable ~db_conn auditor_pub v in
|
||||||
|
Ok ""
|
||||||
|
in
|
||||||
|
respond_with_res res req
|
||||||
|
|
|
||||||
|
|
@ -264,9 +264,35 @@ let update_auditor ~db_conn
|
||||||
let cmp = Timestamp.compare last_date validity_start |> Option.get in
|
let cmp = Timestamp.compare last_date validity_start |> Option.get in
|
||||||
if cmp > 0 then Error "more recent management auditor already present"
|
if cmp > 0 then Error "more recent management auditor already present"
|
||||||
else
|
else
|
||||||
|
let enabled = true in
|
||||||
let+ () =
|
let+ () =
|
||||||
Pg.update_auditor db_conn ~auditor_pub ~auditor_url ~auditor_name
|
Pg.update_auditor db_conn ~auditor_pub ~auditor_url ~auditor_name
|
||||||
~enabled:true ~change_date:validity_start
|
~enabled ~change_date:validity_start
|
||||||
|
|> unwrap_err_caqti
|
||||||
|
in
|
||||||
|
()
|
||||||
|
|
||||||
|
let verify_auditor_disable_sig auditor_pub
|
||||||
|
AuditorTeardownMessage.{ master_sig; validity_end } =
|
||||||
|
let open Bin_sig.MasterDelAuditor in
|
||||||
|
verify ~key:Config.Exchange.master_public_key master_sig
|
||||||
|
{ end_date= validity_end; auditor_pub }
|
||||||
|
|
||||||
|
let auditor_disable ~db_conn auditor_pub
|
||||||
|
AuditorTeardownMessage.{ master_sig= _; validity_end } =
|
||||||
|
let* last_date_opt =
|
||||||
|
Pg.lookup_auditor_timestamp db_conn auditor_pub |> unwrap_err_caqti
|
||||||
|
in
|
||||||
|
match last_date_opt with
|
||||||
|
| None -> Error "auditor not found"
|
||||||
|
| Some last_date ->
|
||||||
|
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
|
||||||
|> unwrap_err_caqti
|
|> unwrap_err_caqti
|
||||||
in
|
in
|
||||||
()
|
()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue