Commit c3c91857 authored by Stephane Glondu's avatar Stephane Glondu

Force the server to be a trustee (in basic mode)

parent 94ba5553
...@@ -47,7 +47,6 @@ let election_draft_voters_add = create_attached_post ~fallback:election_draft_vo ...@@ -47,7 +47,6 @@ let election_draft_voters_add = create_attached_post ~fallback:election_draft_vo
let election_draft_voters_remove = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") () let election_draft_voters_remove = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_voters_passwd = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") () let election_draft_voters_passwd = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_trustee_add = create_attached_post ~fallback:election_draft ~post_params:(string "id") () let election_draft_trustee_add = create_attached_post ~fallback:election_draft ~post_params:(string "id") ()
let election_draft_trustee_add_server = create_attached_post ~fallback:election_draft ~post_params:unit ()
let election_draft_trustee_del = create_attached_post ~fallback:election_draft ~post_params:(int "index") () let election_draft_trustee_del = create_attached_post ~fallback:election_draft ~post_params:(int "index") ()
let election_draft_credential_authority = create ~path:(Path ["draft"; "credential-authority"]) ~meth:(Get (uuid "uuid")) () let election_draft_credential_authority = create ~path:(Path ["draft"; "credential-authority"]) ~meth:(Get (uuid "uuid")) ()
let election_draft_credentials = create ~path:(Path ["draft"; "credentials"]) ~meth:(Get uuid_and_token) () let election_draft_credentials = create ~path:(Path ["draft"; "credentials"]) ~meth:(Get uuid_and_token) ()
......
...@@ -799,10 +799,27 @@ let () = ...@@ -799,10 +799,27 @@ let () =
) )
) )
let trustee_add_server se =
let st_id = "server" and st_token = "" in
let module G = (val Group.of_string se.se_group) in
let module K = Trustees.MakeSimple (G) (LwtRandom) in
let%lwt private_key = K.generate () in
let%lwt public_key = K.prove private_key in
let st_public_key = string_of_trustee_public_key G.write public_key in
let st_private_key = Some private_key in
let trustee = {st_id; st_token; st_public_key; st_private_key} in
se.se_public_keys <- se.se_public_keys @ [trustee];
return_unit
let () = let () =
Any.register ~service:election_draft_trustee_add Any.register ~service:election_draft_trustee_add
(fun uuid st_id -> (fun uuid st_id ->
with_draft_election uuid (fun se -> with_draft_election uuid (fun se ->
let%lwt () =
if List.exists (fun x -> x.st_id = "server") se.se_public_keys then
return_unit
else trustee_add_server se
in
if is_email st_id then ( if is_email st_id then (
let%lwt st_token = generate_token () in let%lwt st_token = generate_token () in
let trustee = {st_id; st_token; st_public_key = ""; st_private_key = None} in let trustee = {st_id; st_token; st_public_key = ""; st_private_key = None} in
...@@ -816,23 +833,6 @@ let () = ...@@ -816,23 +833,6 @@ let () =
) )
) )
let () =
Any.register ~service:election_draft_trustee_add_server
(fun uuid () ->
with_draft_election uuid (fun se ->
let st_id = "server" and st_token = "" in
let module G = (val Group.of_string se.se_group) in
let module K = Trustees.MakeSimple (G) (LwtRandom) in
let%lwt private_key = K.generate () in
let%lwt public_key = K.prove private_key in
let st_public_key = string_of_trustee_public_key G.write public_key in
let st_private_key = Some private_key in
let trustee = {st_id; st_token; st_public_key; st_private_key} in
se.se_public_keys <- se.se_public_keys @ [trustee];
redir_preapply election_draft_trustees uuid ()
)
)
let () = let () =
Any.register ~service:election_draft_trustee_del Any.register ~service:election_draft_trustee_del
(fun uuid index -> (fun uuid index ->
......
...@@ -642,18 +642,6 @@ let election_draft_trustees uuid se () = ...@@ -642,18 +642,6 @@ let election_draft_trustees uuid se () =
] ]
) uuid ) uuid
in in
let form_trustees_add_server =
match List.filter (fun {st_id; _} -> st_id = "server") se.se_public_keys with
| [] ->
post_form
~service:election_draft_trustee_add_server
(fun () ->
[
input ~input_type:`Submit ~value:"Add the server" string
]
) uuid
| _ -> pcdata ""
in
let mk_form_trustee_del value = let mk_form_trustee_del value =
post_form post_form
~service:election_draft_trustee_del ~service:election_draft_trustee_del
...@@ -701,7 +689,7 @@ let election_draft_trustees uuid se () = ...@@ -701,7 +689,7 @@ let election_draft_trustees uuid se () =
td [ td [
pcdata (if t.st_public_key = "" then "No" else "Yes"); pcdata (if t.st_public_key = "" then "No" else "Yes");
]; ];
td [mk_form_trustee_del i]; td [if t.st_id = "server" then pcdata "(cannot be removed)" else mk_form_trustee_del i];
] ]
) ts ) ts
) )
...@@ -723,7 +711,6 @@ let election_draft_trustees uuid se () = ...@@ -723,7 +711,6 @@ let election_draft_trustees uuid se () =
] ]
else pcdata ""); else pcdata "");
form_trustees_add; form_trustees_add;
form_trustees_add_server;
] ]
else pcdata "" else pcdata ""
in in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment