web_signatures.mli 7.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
(*  Copyright © 2012-2014 Inria                                           *)
(*                                                                        *)
(*  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 23
module type EMPTY = sig end

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
module type MAIN_SERVICES = sig

  val home :
    (unit, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ], unit, unit,
     [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val source_code :
    (unit, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ], unit, unit,
     [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val election_file :
    'a Serializable_t.params ->
    Services.election_file ->
    (unit, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ], unit, unit,
     [< Eliom_service.registrable > `Unregistrable ], 'b)
    Eliom_service.service

  val election_vote :
    (Serializable_t.uuid, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ],
     [ `One of Serializable_t.uuid ] Eliom_parameter.param_name,
     unit, [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val election_cast :
    (Serializable_t.uuid, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ],
     [ `One of Serializable_t.uuid ] Eliom_parameter.param_name,
     unit, [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val election_cast_post :
    (Serializable_t.uuid, string option * Eliom_lib.file_info option,
     [> `Attached of
          ([> `Internal of [ `Coservice | `Service ] ], [> `Post ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ],
     [ `One of Serializable_t.uuid ] Eliom_parameter.param_name,
     [ `One of string ] Eliom_parameter.param_name *
     [ `One of Eliom_lib.file_info ] Eliom_parameter.param_name,
     [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val election_update_credential :
    (Serializable_t.uuid, string * string,
     [> `Attached of
          ([> `Internal of [ `Coservice | `Service ] ], [> `Post ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ],
     [ `One of Serializable_t.uuid ] Eliom_parameter.param_name,
     [ `One of string ] Eliom_parameter.param_name *
     [ `One of string ] Eliom_parameter.param_name,
     [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val get :
    unit ->
    (unit, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ], unit, unit, Eliom_service.registrable, 'a)
    Eliom_service.service Lwt.t

end


module type AUTH_CONFIG = sig
  val cas_server : string
  val enable_cas : bool
  val enable_dummy : bool
  val rewrite_prefix : string -> string
  open Util
  val password_db : (SMap.key * SMap.key) SMap.t option
end

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
module type CONT_SERVICE = sig
  val cont :
    unit ->
    (unit, unit,
     [> `Attached of
          ([> `External | `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ], unit, unit, Eliom_service.registrable, 'a)
    Eliom_service.service Lwt.t
end

type user = {
  user_type : string;
  user_name : string;
}

type logged_user = {
  user_admin : bool;
  user_user : user;
  user_logout : (module CONT_SERVICE);
}
141 142 143

module type AUTH_SERVICES = sig

144
  val get_auth_systems : unit -> string list
145
  val get_logged_user : unit -> logged_user option Lwt.t
146

Stephane Glondu's avatar
Stephane Glondu committed
147 148 149 150 151 152 153 154 155 156 157
  val login :
    (string option, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
     [ `WithoutSuffix ],
     [ `One of string ] Eliom_parameter.param_name, unit,
     [< Eliom_service.registrable > `Registrable ], 'a)
    Eliom_service.service

  val logout :
158 159 160 161
    (unit, unit,
     [> `Attached of
          ([> `Internal of [> `Service ] ], [> `Get ])
          Eliom_service.a_s ],
Stephane Glondu's avatar
Stephane Glondu committed
162 163
     [ `WithoutSuffix ], unit, unit,
     [< Eliom_service.registrable > `Registrable ], 'a)
164 165
    Eliom_service.service

Stephane Glondu's avatar
Stephane Glondu committed
166 167 168
end


169 170
module type TEMPLATES = sig

Stephane Glondu's avatar
Stephane Glondu committed
171
  val dummy_login :
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    service:(unit, 'a, [< Eliom_service.post_service_kind ],
             [< Eliom_service.suff ], 'b,
             [< string Eliom_parameter.setoneradio ]
             Eliom_parameter.param_name,
             [< Eliom_service.registrable ], 'c)
            Eliom_service.service ->
    [> `Html ] Eliom_content.Html5.F.elt Lwt.t

  val password_login :
    service:(unit, 'a, [< Eliom_service.post_service_kind ],
             [< Eliom_service.suff ], 'b,
             [< string Eliom_parameter.setoneradio ]
             Eliom_parameter.param_name *
             [< string Eliom_parameter.setoneradio ]
             Eliom_parameter.param_name,
             [< Eliom_service.registrable ], 'c)
            Eliom_service.service ->
    [> `Html ] Eliom_content.Html5.F.elt Lwt.t

191 192 193
  val generic_login :
    unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t

194
end
Stephane Glondu's avatar
Stephane Glondu committed
195 196 197 198 199 200


module type ALL_SERVICES = sig
  include MAIN_SERVICES
  include AUTH_SERVICES
end
Stephane Glondu's avatar
Stephane Glondu committed
201

202 203 204 205
module type NAME = sig
  val name : string
end

206 207 208
type on_success_handler =
  user_name:string -> user_logout:(module CONT_SERVICE) -> unit Lwt.t

209 210
module type AUTH_INSTANCE = sig

211
  val handler :
212
    on_success:on_success_handler -> unit ->
213 214 215
    (Eliom_registration.browser_content,
     Eliom_registration.http_service)
    Eliom_registration.kind Lwt.t
216

Stephane Glondu's avatar
Stephane Glondu committed
217
end
218

219 220 221 222 223
module type AUTH_SERVICE =
  functor (N : NAME) ->
  functor (S : CONT_SERVICE) ->
  functor (T : TEMPLATES) ->
  AUTH_INSTANCE