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