Commit 4eccfcfb authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add path to NAME, parametrize Auth_common.Make over NAME

The new field is used as root for services specific to an auth system.
parent f960113f
......@@ -52,7 +52,7 @@ module Make (C : CONFIG) (N : NAME) (S : CONT_SERVICE) (T : TEMPLATES) : AUTH_IN
()
let login_cas = Eliom_service.service
~path:["auth"; N.name]
~path:N.path
~get_params:Eliom_parameter.(opt (string "ticket"))
()
......
......@@ -43,7 +43,7 @@ let get_config_spec () = !config_spec
(* TODO: make the authentication system more flexible *)
module Make (X : EMPTY) = struct
module Make (N : NAME) = struct
let instances = Hashtbl.create 10
let auth_systems = ref []
......@@ -68,12 +68,12 @@ module Make (X : EMPTY) = struct
let get_logged_user () = Eliom_reference.get user
let login = Eliom_service.service
~path:["login"]
~path:(N.path @ ["login"])
~get_params:Eliom_parameter.(opt (string "service"))
()
let logout = Eliom_service.service
~path:["logout"]
~path:(N.path @ ["logout"])
~get_params:Eliom_parameter.unit
()
......@@ -85,7 +85,10 @@ module Make (X : EMPTY) = struct
if Hashtbl.mem instances name then (
failwith ("multiple instances with name " ^ name)
) else (
let module N = struct let name = name end in
let module N = struct
let name = name
let path = N.path @ ["auth"; name]
end in
let module A = (val auth : AUTH_SERVICE) (N) (C) (T) in
let i = (module A : AUTH_INSTANCE) in
Hashtbl.add instances name i;
......
......@@ -36,7 +36,7 @@ val register_auth_system :
val get_config_spec :
unit -> Ocsigen_extensions.Configuration.element list
module Make (X : EMPTY) : sig
module Make (N : NAME) : sig
module Services : AUTH_SERVICES
module Register (S : CONT_SERVICE) (T : TEMPLATES) : EMPTY
end
......@@ -25,7 +25,7 @@ open Auth_common
module Make (N : NAME) (S : CONT_SERVICE) (T : TEMPLATES) : AUTH_INSTANCE = struct
let service = Eliom_service.service
~path:["auth"; N.name]
~path:N.path
~get_params:Eliom_parameter.unit
()
......
......@@ -31,7 +31,7 @@ end
module Make (C : CONFIG) (N : NAME) (S : CONT_SERVICE) (T : TEMPLATES) : AUTH_INSTANCE = struct
let service = Eliom_service.service
~path:["auth"; N.name]
~path:N.path
~get_params:Eliom_parameter.unit
()
......
......@@ -231,7 +231,10 @@ let can_vote m user =
| None -> false (* voters must log in *)
| Some u -> check_acl (Some acls) u.user_user
module SAuth = Auth_common.Make (struct end)
module SAuth = Auth_common.Make (struct
let name = "site"
let path = []
end)
module SSite = struct
open Eliom_service
......
......@@ -329,6 +329,7 @@ end
module type NAME = sig
val name : string
val path : string list
end
type on_success_handler =
......
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