annotate src/ur/openidUser.urs @ 18:dd8eb53da51b

Pretend user isn't logged in when he gives bogus session data; add some documentation to openidUser.urs
author Adam Chlipala <adam@chlipala.net>
date Thu, 06 Jan 2011 15:17:15 -0500
parents df2eb629f21a
children 2342d9baa0df
rev   line source
adam@18 1 (* This module provides generic user authentication functionality, backed by
adam@18 2 * OpenID authentication. Each account (named with a short alphanumeric string)
adam@18 3 * is associated with one or more OpenID identifiers, any of which may be used
adam@18 4 * to log in as that user. This module provides all the code you need to sign
adam@18 5 * users up, log them in, and check which user is logged in.
adam@18 6 *
adam@18 7 * Module author: Adam Chlipala
adam@18 8 *)
adam@18 9
adam@18 10 (* Instantiate this functor to create your customized authentication scheme. *)
adam@16 11 functor Make(M: sig
adam@16 12 con cols :: {Type}
adam@16 13 constraint [Id] ~ cols
adam@17 14 val folder : folder cols
adam@17 15 val inj : $(map sql_injectable cols)
adam@18 16 (* Extra columns of profile information to include in the user
adam@18 17 * database table *)
adam@16 18
adam@17 19 type creationState
adam@18 20 (* The type of client-side state used while soliciting sign-up
adam@18 21 * input *)
adam@17 22 type creationData
adam@18 23 (* A functional representation of the latest client-side state *)
adam@18 24
adam@17 25 val creationState : transaction creationState
adam@18 26 (* Create some fresh client-side state. *)
adam@18 27
adam@17 28 val render : creationState -> xtable
adam@18 29 (* Display widgets. *)
adam@18 30
adam@17 31 val tabulate : creationState -> signal creationData
adam@18 32 (* Functionalize current state. *)
adam@18 33
adam@18 34 val choose : sql_table ([Id = string] ++ cols) [Pkey = [Id]]
adam@18 35 -> creationData -> transaction $cols
adam@18 36 (* Use functionalized state to choose initial column values,
adam@18 37 * given a handle to the users table. *)
adam@17 38
adam@16 39 val sessionLifetime : int
adam@16 40 (* Number of seconds a session may live *)
adam@16 41
adam@16 42 val afterLogout : url
adam@16 43 (* Where to send the user after he logs out *)
adam@16 44
adam@16 45 val secureCookies : bool
adam@18 46 (* Should authentication cookies be restricted to SSL
adam@18 47 * connections? *)
adam@16 48
adam@16 49 val association : Openid.association_mode
adam@16 50 (* OpenID cryptography preferences *)
adam@16 51
adam@16 52 val realm : option string
adam@18 53 (* See end of [Openid] module's documentation for the meaning
adam@18 54 * of realms. *)
adam@17 55
adam@17 56 val formClass : css_class
adam@18 57 (* CSS class for <table>, <th>, and <td> elements used in
adam@18 58 * sign-up form *)
adam@16 59 end) : sig
adam@16 60
adam@16 61 type user
adam@16 62 val show_user : show user
adam@16 63 val inj_user : sql_injectable_prim user
adam@18 64 (* The abstract type of user IDs. It's really [string], but this is only
adam@18 65 * exposed via some standard type class instances. *)
adam@16 66
adam@16 67 table user : ([Id = user] ++ M.cols)
adam@16 68 PRIMARY KEY Id
adam@16 69
adam@16 70 val current : transaction (option user)
adam@18 71 (* Figure out which, if any, user is logged in on this connection. *)
adam@16 72
adam@16 73 val main : (string -> xbody -> transaction page) -> transaction xbody
adam@18 74 (* Pass in your generic page template; get out the HTML snippet for user
adam@18 75 * management, suitable for, e.g., inclusion in your standard page
adam@18 76 * header. *)
adam@16 77
adam@16 78 end