web_services.ml 8.88 KB
Newer Older
1 2 3
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
Stephane Glondu's avatar
Stephane Glondu committed
4
(*  Copyright © 2012-2018 Inria                                           *)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU Affero General Public License as        *)
(*  published by the Free Software Foundation, either version 3 of the    *)
(*  License, or (at your option) any later version, with the additional   *)
(*  exemption that compiling, linking, and/or using OpenSSL is allowed.   *)
(*                                                                        *)
(*  This program is distributed in the hope that it will be useful, but   *)
(*  WITHOUT ANY WARRANTY; without even the implied warranty of            *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *)
(*  Affero General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Affero General Public      *)
(*  License along with this program.  If not, see                         *)
(*  <http://www.gnu.org/licenses/>.                                       *)
(**************************************************************************)

open Eliom_service
open Eliom_service.Http
open Eliom_parameter
open Web_common

let home = service ~path:[""] ~get_params:unit ()
let admin = service ~path:["admin"] ~get_params:unit ()
let site_login = service ~path:["login"] ~get_params:(opt (string "service")) ()
Stephane Glondu's avatar
Stephane Glondu committed
30
let logout = service ~path:["logout"] ~get_params:unit ()
31 32 33 34 35

let source_code = service ~path:["belenios.tar.gz"] ~get_params:unit ()

let tool = preapply (static_dir ()) ["static"; "belenios-tool.html"]

Stephane Glondu's avatar
Stephane Glondu committed
36 37
let election_setup_new = post_coservice ~csrf_safe:true ~fallback:admin ~post_params:(radio string "credmgmt" ** radio string "auth" ** string "cas_server") ()
let election_setup_pre = service ~path:["setup"; "new"] ~get_params:unit ()
38
let election_setup = service ~path:["setup"; "election"] ~get_params:(uuid "uuid") ()
39 40
let election_setup_questions = service ~path:["setup"; "questions"] ~get_params:(uuid "uuid") ()
let election_setup_questions_post = post_coservice ~fallback:election_setup_questions ~post_params:(string "questions") ()
41
let election_setup_description = post_coservice ~fallback:election_setup ~post_params:(string "name" ** string "description") ()
42
let election_setup_languages = post_coservice ~fallback:election_setup ~post_params:(string "languages") ()
43
let election_setup_contact = post_coservice ~fallback:election_setup ~post_params:(string "contact") ()
44
let election_setup_voters = service ~path:["setup"; "voters"] ~get_params:(uuid "uuid") ()
45
let election_setup_voters_add = post_service ~fallback:election_setup_voters ~post_params:(string "voters") ()
46 47
let election_setup_voters_remove = post_coservice ~fallback:election_setup_voters ~post_params:(string "voter") ()
let election_setup_voters_passwd = post_coservice ~fallback:election_setup_voters ~post_params:(string "voter") ()
48
let election_setup_trustee_add = post_coservice ~fallback:election_setup ~post_params:(string "id") ()
49
let election_setup_trustee_add_server = post_coservice ~fallback:election_setup ~post_params:unit ()
50
let election_setup_trustee_del = post_coservice ~fallback:election_setup ~post_params:(int "index") ()
51
let election_setup_credential_authority = service ~path:["setup"; "credential-authority"] ~get_params:(uuid "uuid") ()
52 53 54
let election_setup_credentials = service ~path:["setup"; "credentials"] ~get_params:(string "token") ()
let election_setup_credentials_post = post_coservice ~fallback:election_setup_credentials ~post_params:(string "public_creds") ()
let election_setup_credentials_post_file = post_coservice ~fallback:election_setup_credentials ~post_params:(file "public_creds") ()
55 56
let election_setup_credentials_server = post_coservice ~fallback:election_setup ~post_params:unit ()

57
let election_setup_trustees = service ~path:["setup"; "trustees"] ~get_params:(uuid "uuid") ()
58 59
let election_setup_trustee = service ~path:["setup"; "trustee"] ~get_params:(string "token") ()
let election_setup_trustee_post = post_coservice ~fallback:election_setup_trustee ~post_params:(string "public_key") ()
60 61 62 63 64 65 66 67

let election_setup_threshold_trustees = service ~path:["setup"; "threshold-trustees"] ~get_params:(uuid "uuid") ()
let election_setup_threshold_trustee = service ~path:["setup"; "threshold-trustee"] ~get_params:(string "token") ()
let election_setup_threshold_trustee_post = post_coservice ~fallback:election_setup_threshold_trustee ~post_params:(string "data") ()
let election_setup_threshold_set = post_coservice ~fallback:election_setup_threshold_trustees ~post_params:(int "threshold") ()
let election_setup_threshold_trustee_add = post_coservice ~fallback:election_setup_threshold_trustees ~post_params:(string "id") ()
let election_setup_threshold_trustee_del = post_coservice ~fallback:election_setup_threshold_trustees ~post_params:(int "index") ()

68
let election_setup_confirm = service ~path:["setup"; "confirm"] ~get_params:(uuid "uuid") ()
69
let election_setup_create = post_coservice ~csrf_safe:true ~fallback:election_setup ~post_params:unit ()
70
let election_setup_destroy = post_coservice ~csrf_safe:true ~fallback:election_setup ~post_params:unit ()
71
let election_setup_auth_genpwd = post_coservice ~fallback:election_setup ~post_params:unit ()
72

73 74
let election_setup_import = service ~path:["setup"; "import"] ~get_params:(uuid "uuid") ()
let election_setup_import_post = post_coservice ~fallback:election_setup_import ~post_params:(uuid "from") ()
75 76
let election_setup_import_trustees = service ~path:["setup"; "import-trustees"] ~get_params:(uuid "uuid") ()
let election_setup_import_trustees_post = post_coservice ~fallback:election_setup_import_trustees ~post_params:(uuid "from") ()
77

78
let election_home = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "")) ()
Stephane Glondu's avatar
Stephane Glondu committed
79
let set_cookie_disclaimer = coservice' ~get_params:unit ()
80
let election_admin = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "admin")) ()
81 82
let election_regenpwd = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "regenpwd")) ()
let election_regenpwd_post = post_coservice ~fallback:election_regenpwd ~post_params:(string "user") ()
83
let election_login = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "login") (opt (string "service"))) ()
84 85
let election_open = post_coservice ~fallback:election_admin ~post_params:unit ()
let election_close = post_coservice ~fallback:election_admin ~post_params:unit ()
86
let election_archive = post_coservice ~fallback:election_admin ~post_params:unit ()
87 88 89 90 91 92
let election_update_credential = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "update-cred")) ()
let election_update_credential_post = post_service ~fallback:election_update_credential ~post_params:(string "old_credential" ** string "new_credential") ()
let election_vote = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "vote")) ()
let election_cast = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "cast")) ()
let election_cast_post = post_service ~fallback:election_cast ~post_params:(opt (string "encrypted_vote") ** opt (file "encrypted_vote_file")) ()
let election_cast_confirm = post_coservice ~csrf_safe:true ~fallback:election_cast ~post_params:unit ()
93
let election_pretty_ballots = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "ballots")) ()
94
let election_pretty_ballot = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "ballot") (string "hash")) ()
95
let election_pretty_records = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "pretty-records")) ()
96

97 98
let election_missing_voters = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "missing")) ()

99
let election_compute_encrypted_tally = post_coservice ~csrf_safe:true ~fallback:election_admin ~post_params:unit ()
100
let election_tally_trustees = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "trustees" ** string "token")) ()
101
let election_tally_trustees_post = post_service ~fallback:election_tally_trustees ~post_params:(string "partial_decryption") ()
102
let election_tally_release = post_service ~fallback:election_admin ~post_params:unit ()
103 104

let election_dir = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** election_file "file")) ()
105

106 107
let dummy_post = post_coservice' ~post_params:(string "username") ()
let password_post = post_coservice' ~post_params:(string "username" ** string "password") ()
108 109

let set_language = coservice' ~get_params:(string "lang") ()