comparison mod_register_json.wiki @ 344:980a177b8a19

editing the wiki to reflect changes
author maranda3985@gmail.com
date Mon, 29 Apr 2013 21:02:29 +0000
parents 41d03be9ac76
children 73b078aeaf84
comparison
equal deleted inserted replaced
343:6cc2d1e280c9 344:980a177b8a19
1 #summary mini JSON registration servlet. 1 #summary Token based JSON registration & verification servlet.
2 #labels Stage-Beta 2 #labels Stage-Stable
3 3
4 = Introduction = 4 = Introduction =
5 5
6 This module let's you activate a httpserver interface to handle data from webforms with POST and JSON. 6 This module let's you activate a httpserver interface to handle data from webforms with POST and Base64 encoded JSON.
7 7
8 = Details = 8 = Implementation Details =
9 9
10 It will accept the following format: 10 Example Request format:
11 11
12 {{{ 12 {{{
13 POST /your_register_base_url HTTP/1.0 13 POST /your_register_base_url HTTP/1.1
14 Host: yourserveraddress.com:yourchoosenport 14 Host: yourserveraddress.com:yourchoosenport
15 Authorization: Basic base64authstring 15 Content-Type: application/encoded
16 Content-Type: application/json 16 Content-Transfer-Encoding: base64
17 17
18 {"username":"usernameofchoice","password":"theuserpassword","host":"yourserverorvhostaddress","ip":"theremoteaddroftheuser"} 18 eyJ1c2VybmFtZSI6InVzZXJuYW1lb2ZjaG9pY2UiLCJwYXNzd29yZCI6InRoZXVzZXJwYXNzd29yZCIsImlwIjoidGhlcmVtb3RlYWRkcm9mdGhldXNlciIsIm1haWwiOiJ1c2VybWFpbEB1c2VybWFpbGRvbWFpbi50bGQiLCJhdXRoX3Rva2VuIjoieW91cmF1dGh0b2tlbm9mY2hvaWNlIn0=
19 }}} 19 }}}
20 20
21 It will require a server admin (of the given host) to provide valid credentials to submit data via Basic HTTP auth first. 21 Where the encoded content is this (example) JSON Array:
22 22
23 The ip field is at the moment is required to be present even if unset (""), you will require to set it using the webserver's REMOTE_ADDR global (or similar) to pass the client's ip address should you want to employ throttling/blacklisting/whitelisting of requests. 23 <code language="javascript">
24 {"username":"usernameofchoice","password":"theuserpassword","ip":"theremoteaddroftheuser","mail":"usermail@usermaildomain.tld","auth_token":"yourauthtokenofchoice"}
25 </code>
26
27 Your form implementation needs to pass *all* parameters, the auth_token is needed to prevent misuses, if the request is successfull the server will answer with status code 200 and with the body of the response containing the token which your web app can send via e-mail to the user to complete the registration.
28
29 The module for now stores a hash of the user's mail address to help slow down duplicated registrations.
30
31 It's strongly encouraged to have the web server communicate with the servlet via https.
24 32
25 = Usage = 33 = Usage =
26 34
27 Copy the module file into your prosody modules directory. 35 Copy the module file into your prosody modules directory.
28 Load the module in your configuration file's global section, that would suffice to run it. 36 Add the module your vhost of choice modules_enabled.
29 37
30 Hint: pairing with mod_register_url is helpful, to allow server registrations only via your webform. 38 Hint: pairing with mod_register_url is helpful, to allow server registrations only via your webform.
31 39
32 Optional configuration directives: 40 Optional configuration directives:
33 <code language="lua"> 41 <code language="lua">
34 reg_servlet_base = "/base-path/" -- Base path of the plugin 42 reg_servlet_base = "/base-path/" -- Base path of the plugin (default is register_account)
35 reg_servlet_realm = "Your Realm Name of choice" -- Modifies the name of the authentication realm. 43 reg_servlet_secure = true -- Have the plugin only process requests on https (default is true)
36 reg_servlet_ttime = seconds -- Specifies the time (in seconds) between each request coming from the same remote address. 44 reg_servlet_ttime = seconds -- Specifies the time (in seconds) between each request coming from the same remote address.
37 reg_servlet_bl = { "1.2.3.4", "4.3.2.1" } -- The ip addresses in this list will be blacklisted and will not be able to submit registrations. 45 reg_servlet_bl = { "1.2.3.4", "4.3.2.1" } -- The ip addresses in this list will be blacklisted and will not be able to submit registrations.
38 reg_servlet_wl = { "1.2.3.4", "4.3.2.1" } -- The ip addresses in this list will be ignored by the throttling. 46 reg_servlet_wl = { "1.2.3.4", "4.3.2.1" } -- The ip addresses in this list will be ignored by the throttling.
47 reg_servlet_filtered_mails = { ".*banneddomain.tld", ".*deamailprovider.tld" } -- allows filtering of mail addresses via Lua patterns.
39 </code> 48 </code>
40 49
41 = Info = 50 = Compatibility =
42 51
43 * This is only compatible with 0.9, please look at the 0.8-diverge branch for older versions 52 * 0.9