Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 30039246 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Share scopes in each module

parent d6468942
......@@ -35,6 +35,8 @@ end
module Make (C : CONFIG) (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
let scope = Eliom_common.default_session_scope
let cas_login = Eliom_service.external_service
~prefix:C.server
~path:["login"]
......@@ -63,13 +65,8 @@ module Make (C : CONFIG) (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
let self =
Eliom_uri.make_string_uri ~absolute:true ~service () |> rewrite_prefix
let login_cont = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let logout_cont = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let login_cont = Eliom_reference.eref ~scope None
let logout_cont = Eliom_reference.eref ~scope None
let () = Eliom_registration.Any.register
~service:login_cas
......
......@@ -37,26 +37,25 @@ let parse_config ~instance ~attributes =
module Make (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
let scope = Eliom_common.default_session_scope
let service = Eliom_service.service
~path:N.path
~get_params:Eliom_parameter.unit
()
let login_cont = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let login_cont = Eliom_reference.eref ~scope None
let () = Eliom_registration.Html5.register ~service
(fun () () ->
let post_params = Eliom_parameter.(string "username") in
let service = Eliom_service.post_coservice
~csrf_safe:true
~csrf_scope:Eliom_common.default_session_scope
~csrf_scope:scope
~fallback:service
~post_params ()
in
let () = Eliom_registration.Any.register ~service
~scope:Eliom_common.default_session_scope
let () = Eliom_registration.Any.register ~service ~scope
(fun () user_name ->
match_lwt Eliom_reference.get login_cont with
| Some cont ->
......
......@@ -42,6 +42,8 @@ end
module Make (C : CONFIG) (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
let scope = Eliom_common.default_session_scope
let service = Eliom_service.service
~path:N.path
~get_params:Eliom_parameter.unit
......@@ -55,9 +57,7 @@ module Make (C : CONFIG) (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
| _ -> failwith ("error while parsing db file for " ^ N.name)
) SMap.empty (Csv.load C.db)
let login_cont = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let login_cont = Eliom_reference.eref ~scope None
let () = Eliom_registration.Html5.register ~service
(fun () () ->
......@@ -66,12 +66,11 @@ module Make (C : CONFIG) (N : NAME) (T : TEMPLATES) : AUTH_HANDLERS = struct
) in
let service = Eliom_service.post_coservice
~csrf_safe:true
~csrf_scope:Eliom_common.default_session_scope
~csrf_scope:scope
~fallback:service
~post_params ()
in
let () = Eliom_registration.Any.register ~service
~scope:Eliom_common.default_session_scope
let () = Eliom_registration.Any.register ~service ~scope
(fun () (user_name, password) ->
if (
try
......
......@@ -60,12 +60,12 @@ end
module Make (N : CONFIG) = struct
let scope = Eliom_common.default_session_scope
let auth_instances = Hashtbl.create 10
let auth_instance_names = ref []
let user = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let user = Eliom_reference.eref ~scope None
module Services : AUTH_SERVICES = struct
......
......@@ -295,10 +295,6 @@ let make {raw_election; metadata; featured; params_fname; public_keys_fname} =
module Register (S : SITE_SERVICES) (T : ELECTION_TEMPLATES) : EMPTY = struct
open Eliom_registration
let ballot = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
(None : string option)
let if_eligible acl f () x =
lwt user = S.get_user () in
if acl metadata user then
......@@ -306,9 +302,10 @@ let make {raw_election; metadata; featured; params_fname; public_keys_fname} =
else
forbidden ()
let cast_confirmed = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
None
let scope = Eliom_common.default_session_scope
let ballot = Eliom_reference.eref ~scope None
let cast_confirmed = Eliom_reference.eref ~scope None
let () = Html5.register ~service:W.S.home
(if_eligible can_read
......@@ -470,16 +467,13 @@ let make {raw_election; metadata; featured; params_fname; public_keys_fname} =
let confirm () =
let service = Eliom_service.post_coservice
~csrf_safe:true
~csrf_scope:Eliom_common.default_session_scope
~csrf_scope:scope
~fallback:W.S.election_cast
~post_params:Eliom_parameter.unit
()
in
let () = Any.register
~service
~scope:Eliom_common.default_session_scope
do_cast
in service
let () = Any.register ~service ~scope do_cast in
service
in
let can_vote = can_vote metadata user in
T.cast_confirmation ~confirm ~user ~can_vote ()
......
......@@ -59,6 +59,8 @@ module Make (C : CONFIG) : SITE_SERVICES = struct
include Auth.Services
open Eliom_parameter
let scope = Eliom_common.default_session_scope
let home = service
~path:(make_path [""])
~get_params:unit
......@@ -74,8 +76,7 @@ module Make (C : CONFIG) : SITE_SERVICES = struct
~get_params:unit
()
let saved_service = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
let saved_service = Eliom_reference.eref ~scope
(module struct let s = home end : SAVED_SERVICE)
let cont () =
......
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