web_common.mli 4.62 KB
Newer Older
Stephane Glondu's avatar
Stephane Glondu committed
1 2 3
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
Stephane Glondu's avatar
Stephane Glondu committed
4
(*  Copyright © 2012-2018 Inria                                           *)
Stephane Glondu's avatar
Stephane Glondu committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(*                                                                        *)
(*  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/>.                                       *)
(**************************************************************************)

Stephane Glondu's avatar
Stephane Glondu committed
22
open Signatures
23
open Serializable_t
24
open Web_serializable_t
25

26
val site_auth_config : auth_config list ref
27
val spool_dir : string ref
28
val server_mail : string ref
29
val return_path : string option ref
30
val contact_uri : string option ref
31
val gdpr_uri : string ref
32
val warning_file : string option ref
33

Stephane Glondu's avatar
Stephane Glondu committed
34
module LwtRandom : RANDOM with type 'a t = 'a Lwt.t
35 36
(** Lwt-compatible random number generation. *)

37
type error =
38 39 40 41 42 43 44 45
  | Serialization of exn
  | ProofCheck
  | ElectionClosed
  | MissingCredential
  | InvalidCredential
  | RevoteNotAllowed
  | ReusedCredential
  | WrongCredential
46 47
  | UsedCredential
  | CredentialNotFound
48
  | UnauthorizedVoter
49 50 51

exception Error of error

52
val fail : error -> 'a Lwt.t
53

54
val explain_error : (module Web_i18n_sig.LocalizedStrings) -> error -> string
55

56 57 58 59 60
val open_security_log : string -> unit Lwt.t
(** Set the path to the security logger. *)

val security_log : (unit -> string) -> unit Lwt.t
(** Add an entry to the security log. *)
61 62 63

val fail_http : int -> 'a Lwt.t
val forbidden : unit -> 'a Lwt.t
64 65 66

val rewrite_prefix : string -> string
val set_rewrite_prefix : src:string -> dst:string -> unit
67

68 69 70
type election_file =
  | ESRaw
  | ESKeys
71
  | ESTParams
72 73
  | ESCreds
  | ESBallots
74
  | ESVoters
75
  | ESRecords
76
  | ESETally
77
  | ESResult
78 79 80

val election_file_of_string : string -> election_file
val string_of_election_file : election_file -> string
81 82 83 84 85 86

val election_file :
  string ->
  (election_file, [ `WithoutSuffix ],
   [ `One of election_file ] Eliom_parameter.param_name)
  Eliom_parameter.params_type
87 88 89

val uuid :
  string ->
90 91
  (uuid, [ `WithoutSuffix ],
   [ `One of uuid ] Eliom_parameter.param_name)
92 93
  Eliom_parameter.params_type

94 95 96 97 98 99 100 101 102 103
type captcha_error =
  | BadCaptcha
  | BadAddress

val captcha_error :
  string ->
  (captcha_error, [ `WithoutSuffix ],
   [ `One of captcha_error ] Eliom_parameter.param_name)
  Eliom_parameter.params_type

104 105 106
type add_account_error =
  | UsernameTaken
  | BadUsername
107
  | BadPassword of string
108

109
val generate_token : ?length:int -> unit -> string Lwt.t
110 111

val string_of_user : user -> string
112

113
val send_email : string -> string -> string -> unit Lwt.t
114 115

val split_identity : string -> string * string
Stephane Glondu's avatar
Stephane Glondu committed
116

117
val available_languages : string list
118 119
val get_languages : string list option -> string list
val string_of_languages : string list option -> string
120
val languages_of_string : string -> string list
121

122 123
val pcre_exec_opt : rex:Pcre.regexp -> string -> Pcre.substrings option

124
val is_email : string -> bool
125
val extract_email : string -> string option
126

127
val file_exists : string -> bool Lwt.t
128 129
val read_file : ?uuid:uuid -> string -> string list option Lwt.t
val write_file : ?uuid:uuid -> string -> string list -> unit Lwt.t
130 131

val cleanup_file : string -> unit Lwt.t
132
val rmdir : string -> unit Lwt.t
133

134 135 136
val urlize : string -> string
val unurlize : string -> string

137
val default_contact : string
138
val default_questions : question array
139 140
val default_name : string
val default_description : string
141 142

val default_creation_date : datetime
143
val default_validation_date : datetime
144 145
val default_tally_date : datetime
val default_archive_date : datetime
146 147 148

val days_to_archive : int
val days_to_delete : int
149 150
val days_to_mail : int
val days_between_mails : int