Mercurial > prosody-hg
comparison plugins/mod_tokenauth.lua @ 13074:794a5ad5495e
mod_tokenauth: Fix parsing binary part of tokens
Fixes parsing of tokens that happen to have a `;` in their secret part,
otherwise it splits there and the later bit goes into the username and
hitting the "Invalid token in storage" condition.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 12 Apr 2023 11:43:32 +0200 |
| parents | 9e5802b45b9e |
| children | 65d2ff6e674e |
comparison
equal
deleted
inserted
replaced
| 13073:9e5802b45b9e | 13074:794a5ad5495e |
|---|---|
| 118 if not encoded_token then return nil; end | 118 if not encoded_token then return nil; end |
| 119 local encoded_data = encoded_token:match("^secret%-token:(.+)$"); | 119 local encoded_data = encoded_token:match("^secret%-token:(.+)$"); |
| 120 if not encoded_data then return nil; end | 120 if not encoded_data then return nil; end |
| 121 local token = base64.decode(encoded_data); | 121 local token = base64.decode(encoded_data); |
| 122 if not token then return nil; end | 122 if not token then return nil; end |
| 123 local token_id, token_secret, token_jid = token:match("^2;([^;]+);([^;]+);(.+)$"); | 123 local token_id, token_secret, token_jid = token:match("^2;([^;]+);(..................);(.+)$"); |
| 124 if not token_id then return nil; end | 124 if not token_id then return nil; end |
| 125 local token_user, token_host = jid.split(token_jid); | 125 local token_user, token_host = jid.split(token_jid); |
| 126 return token_id, token_user, token_host, token_secret; | 126 return token_id, token_user, token_host, token_secret; |
| 127 end | 127 end |
| 128 | 128 |
