Mercurial > prosody-modules
comparison mod_sasl2_bind2/mod_sasl2_bind2.lua @ 5650:0eb2d5ea2428
merge
| author | Stephen Paul Weber <singpolyma@singpolyma.net> |
|---|---|
| date | Sat, 06 May 2023 19:40:23 -0500 |
| parents | 6361afcda1a3 |
| children |
comparison
equal
deleted
inserted
replaced
| 5649:2c69577b28c2 | 5650:0eb2d5ea2428 |
|---|---|
| 22 end, 1); | 22 end, 1); |
| 23 | 23 |
| 24 -- Helper to actually bind a resource to a session | 24 -- Helper to actually bind a resource to a session |
| 25 | 25 |
| 26 local function do_bind(session, bind_request) | 26 local function do_bind(session, bind_request) |
| 27 local resource; | 27 local resource = session.sasl_handler.resource; |
| 28 | 28 |
| 29 local client_name_tag = bind_request:get_child_text("tag"); | 29 if not resource then |
| 30 if client_name_tag then | 30 local client_name_tag = bind_request:get_child_text("tag"); |
| 31 local client_id = session.client_id; | 31 if client_name_tag then |
| 32 local tag_suffix = client_id and base64.encode(sha1(client_id):sub(1, 9)) or id.medium(); | 32 local client_id = session.client_id; |
| 33 resource = ("%s~%s"):format(client_name_tag, tag_suffix); | 33 local tag_suffix = client_id and base64.encode(sha1(client_id):sub(1, 9)) or id.medium(); |
| 34 resource = ("%s~%s"):format(client_name_tag, tag_suffix); | |
| 35 end | |
| 34 end | 36 end |
| 35 | 37 |
| 36 local success, err_type, err, err_msg = sm_bind_resource(session, resource); | 38 local success, err_type, err, err_msg = sm_bind_resource(session, resource); |
| 37 if not success then | 39 if not success then |
| 38 session.log("debug", "Resource bind failed: %s", err_msg or err); | 40 session.log("debug", "Resource bind failed: %s", err_msg or err); |
