Mercurial > prosody-hg
annotate spec/util_sasl_spec.lua @ 12659:c0eea4f6c739
usermanager: Add back temporary is_admin to warn about deprecated API usage
Goal: Introduce role-auth with minimal disruption
is_admin() is unsafe in a system with per-session permissions, so it has been
deprecated.
Roll-out approach:
1) First, log a warning when is_admin() is used. It should continue to
function normally, backed by the new role API. Nothing is really using
per-session authz yet, so there is minimal security concern.
The 'strict_deprecate_is_admin' global setting can be set to 'true' to
force a hard failure of is_admin() attempts (it will log an error and
always return false).
2) In some time (at least 1 week), but possibly longer depending on the number
of affected deployments: switch 'strict_deprecate_is_admin' to 'true' by
default. It can still be disabled for systems that need it.
3) Further in the future, before the next release, the option will be removed
and is_admin() will be permanently disabled.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 15 Aug 2022 15:25:07 +0100 |
| parents | f1c0aa521dd5 |
| children | 191fe4866e3e |
| rev | line source |
|---|---|
| 10502 | 1 local sasl = require "util.sasl"; |
| 2 | |
| 3 -- profile * mechanism | |
| 4 -- callbacks could use spies instead | |
| 5 | |
| 6 describe("util.sasl", function () | |
| 7 describe("plain_test profile", function () | |
| 8 local profile = { | |
| 9 plain_test = function (_, username, password, realm) | |
| 10 assert.equals("user", username) | |
| 11 assert.equals("pencil", password) | |
| 12 assert.equals("sasl.test", realm) | |
| 13 return true, true; | |
| 14 end; | |
| 15 }; | |
| 16 it("works with PLAIN", function () | |
| 17 local plain = sasl.new("sasl.test", profile); | |
| 18 assert.truthy(plain:select("PLAIN")); | |
| 19 assert.truthy(plain:process("\000user\000pencil")); | |
| 20 assert.equals("user", plain.username); | |
| 21 end); | |
| 22 end); | |
| 23 | |
| 24 describe("plain profile", function () | |
| 25 local profile = { | |
| 26 plain = function (_, username, realm) | |
| 27 assert.equals("user", username) | |
| 28 assert.equals("sasl.test", realm) | |
| 29 return "pencil", true; | |
| 30 end; | |
| 31 }; | |
| 32 | |
| 33 it("works with PLAIN", function () | |
| 34 local plain = sasl.new("sasl.test", profile); | |
| 35 assert.truthy(plain:select("PLAIN")); | |
| 36 assert.truthy(plain:process("\000user\000pencil")); | |
| 37 assert.equals("user", plain.username); | |
| 38 end); | |
| 39 | |
| 40 -- TODO SCRAM | |
| 41 end); | |
| 42 end); | |
| 43 |
