Software / code / prosody
Comparison
plugins/mod_auth_insecure.lua @ 9275:db137a87511b
mod_auth_insecure: Accept any username/password (import of mod_auth_any from prosody-modules)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 07 Sep 2018 10:46:30 +0100 |
| child | 9292:d5f798efb1ba |
comparison
equal
deleted
inserted
replaced
| 9274:1712e366b081 | 9275:db137a87511b |
|---|---|
| 1 -- Prosody IM | |
| 2 -- Copyright (C) 2008-2010 Matthew Wild | |
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | |
| 4 -- | |
| 5 -- This project is MIT/X11 licensed. Please see the | |
| 6 -- COPYING file in the source package for more information. | |
| 7 -- | |
| 8 -- luacheck: ignore 212 | |
| 9 | |
| 10 local datamanager = require "util.datamanager"; | |
| 11 local new_sasl = require "util.sasl".new; | |
| 12 | |
| 13 local host = module.host; | |
| 14 local provider = { name = "any" }; | |
| 15 | |
| 16 assert(module:get_option_string("insecure_open_authentication") == "Yes please, I know what I'm doing!"); | |
| 17 | |
| 18 function provider.test_password(username, password) | |
| 19 return true; | |
| 20 end | |
| 21 | |
| 22 function provider.set_password(username, password) | |
| 23 local account = datamanager.load(username, host, "accounts"); | |
| 24 if account then | |
| 25 account.password = password; | |
| 26 return datamanager.store(username, host, "accounts", account); | |
| 27 end | |
| 28 return nil, "Account not available."; | |
| 29 end | |
| 30 | |
| 31 function provider.user_exists(username) | |
| 32 return true; | |
| 33 end | |
| 34 | |
| 35 function provider.create_user(username, password) | |
| 36 return datamanager.store(username, host, "accounts", {password = password}); | |
| 37 end | |
| 38 | |
| 39 function provider.delete_user(username) | |
| 40 return datamanager.store(username, host, "accounts", nil); | |
| 41 end | |
| 42 | |
| 43 function provider.get_sasl_handler() | |
| 44 local getpass_authentication_profile = { | |
| 45 plain_test = function(sasl, username, password, realm) | |
| 46 return true, true; | |
| 47 end | |
| 48 }; | |
| 49 return new_sasl(module.host, getpass_authentication_profile); | |
| 50 end | |
| 51 | |
| 52 module:add_item("auth-provider", provider); | |
| 53 |