# HG changeset patch # User maranda3985@gmail.com # Date 1367269349 0 # Node ID 980a177b8a196128649df02ecfd381a6ee0f3881 # Parent 6cc2d1e280c9347156103bd61a4c591765244888 editing the wiki to reflect changes diff -r 6cc2d1e280c9 -r 980a177b8a19 mod_register_json.wiki --- a/mod_register_json.wiki Thu Apr 25 09:50:58 2013 +0000 +++ b/mod_register_json.wiki Mon Apr 29 21:02:29 2013 +0000 @@ -1,43 +1,52 @@ -#summary mini JSON registration servlet. -#labels Stage-Beta +#summary Token based JSON registration & verification servlet. +#labels Stage-Stable = Introduction = -This module let's you activate a httpserver interface to handle data from webforms with POST and JSON. +This module let's you activate a httpserver interface to handle data from webforms with POST and Base64 encoded JSON. -= Details = += Implementation Details = -It will accept the following format: +Example Request format: {{{ -POST /your_register_base_url HTTP/1.0 +POST /your_register_base_url HTTP/1.1 Host: yourserveraddress.com:yourchoosenport -Authorization: Basic base64authstring -Content-Type: application/json +Content-Type: application/encoded +Content-Transfer-Encoding: base64 -{"username":"usernameofchoice","password":"theuserpassword","host":"yourserverorvhostaddress","ip":"theremoteaddroftheuser"} +eyJ1c2VybmFtZSI6InVzZXJuYW1lb2ZjaG9pY2UiLCJwYXNzd29yZCI6InRoZXVzZXJwYXNzd29yZCIsImlwIjoidGhlcmVtb3RlYWRkcm9mdGhldXNlciIsIm1haWwiOiJ1c2VybWFpbEB1c2VybWFpbGRvbWFpbi50bGQiLCJhdXRoX3Rva2VuIjoieW91cmF1dGh0b2tlbm9mY2hvaWNlIn0= }}} -It will require a server admin (of the given host) to provide valid credentials to submit data via Basic HTTP auth first. +Where the encoded content is this (example) JSON Array: + + +{"username":"usernameofchoice","password":"theuserpassword","ip":"theremoteaddroftheuser","mail":"usermail@usermaildomain.tld","auth_token":"yourauthtokenofchoice"} + -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. +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. + +The module for now stores a hash of the user's mail address to help slow down duplicated registrations. + +It's strongly encouraged to have the web server communicate with the servlet via https. = Usage = Copy the module file into your prosody modules directory. -Load the module in your configuration file's global section, that would suffice to run it. +Add the module your vhost of choice modules_enabled. Hint: pairing with mod_register_url is helpful, to allow server registrations only via your webform. Optional configuration directives: -reg_servlet_base = "/base-path/" -- Base path of the plugin -reg_servlet_realm = "Your Realm Name of choice" -- Modifies the name of the authentication realm. +reg_servlet_base = "/base-path/" -- Base path of the plugin (default is register_account) +reg_servlet_secure = true -- Have the plugin only process requests on https (default is true) reg_servlet_ttime = seconds -- Specifies the time (in seconds) between each request coming from the same remote address. 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. reg_servlet_wl = { "1.2.3.4", "4.3.2.1" } -- The ip addresses in this list will be ignored by the throttling. +reg_servlet_filtered_mails = { ".*banneddomain.tld", ".*deamailprovider.tld" } -- allows filtering of mail addresses via Lua patterns. -= Info = += Compatibility = - * This is only compatible with 0.9, please look at the 0.8-diverge branch for older versions + * 0.9 \ No newline at end of file