Commit 9f13fa67 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Export register_auth_system

Auth systems are wrapped into a module (with signature AUTH_SYSTEM) to
cope with polymorphism.
parent c94fbdee
......@@ -89,7 +89,10 @@ module Register (C : AUTH_CONFIG) (S : ALL_SERVICES) (T : TEMPLATES) = struct
| None -> get_default_auth_system ()
| Some x -> Lwt.return x
in
try Lwt.return (List.assoc x !auth_system_map)
try
let auth_system = List.assoc x !auth_system_map in
let module A = (val auth_system : AUTH_SYSTEM) in
Lwt.return A.service
with Not_found -> fail_http 404
)
......@@ -140,7 +143,10 @@ module Register (C : AUTH_CONFIG) (S : ALL_SERVICES) (T : TEMPLATES) = struct
) >> S.get ())
in T.string_login ~service ~kind:`Dummy
)
in register_auth_system "dummy" service
in
let module A = struct let service = service end in
let auth_system = (module A : AUTH_SYSTEM) in
register_auth_system "dummy" auth_system
)
let () = match C.password_db with
......@@ -182,7 +188,10 @@ module Register (C : AUTH_CONFIG) (S : ALL_SERVICES) (T : TEMPLATES) = struct
) else forbidden ())
in T.password_login ~service
)
in register_auth_system "password" service
in
let module A = struct let service = service end in
let auth_system = (module A : AUTH_SYSTEM) in
register_auth_system "password" auth_system
let () = if C.enable_cas then (
let cas_login = Eliom_service.external_service
......@@ -270,7 +279,9 @@ module Register (C : AUTH_CONFIG) (S : ALL_SERVICES) (T : TEMPLATES) = struct
)
in
let service = Eliom_service.preapply login_cas None in
register_auth_system "CAS" service
let module A = struct let service = service end in
let auth_system = (module A : AUTH_SYSTEM) in
register_auth_system "CAS" auth_system
)
let login_admin = Eliom_service.service
......
......@@ -36,6 +36,7 @@ val string_of_user : user -> string
val user : logged_user option Eliom_reference.eref
val get_auth_systems : unit -> string list
val register_auth_system : string -> (module AUTH_SYSTEM) -> unit
module Make (X : EMPTY) : AUTH_SERVICES
module Register (C : AUTH_CONFIG) (S : ALL_SERVICES) (T : TEMPLATES) : EMPTY
......@@ -195,3 +195,14 @@ module type LOGOUT_HANDLER = sig
[ `WithoutSuffix ], unit, unit, Eliom_service.registrable, 'a)
Eliom_service.service Lwt.t
end
module type AUTH_SYSTEM = sig
val service :
(unit, unit,
[> `Attached of
([> `Internal of [> `Service ] ], [> `Get ])
Eliom_service.a_s ],
[ `WithoutSuffix ], unit, unit,
Eliom_service.registrable, 'a)
Eliom_service.service
end
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