aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-06-10 02:03:01 +0200
committerClombrong <cromblong@egregore.fun>2025-06-10 02:03:01 +0200
commitaf41ba0181d0f23591d7b82d3425c419c8ba73da (patch)
tree18bbdd8190c04dd88a04f950ee5b6d7f4a1f32ab /lib
parent1767babf41d81cce5df7a4e221983cf99c850b44 (diff)
feat(auth): wrap plain auth in <auth> stanza
Diffstat (limited to 'lib')
-rw-r--r--lib/auth.ml9
-rw-r--r--lib/dune3
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/auth.ml b/lib/auth.ml
index dfe5cfb..3287f91 100644
--- a/lib/auth.ml
+++ b/lib/auth.ml
@@ -3,4 +3,11 @@ type auth_mechanism = PLAIN [@@deriving show { with_path = false }]
let send_auth_stanza (_stream, _push) jid pass mechanism =
let gen_auth = function
| PLAIN -> Base64.encode_exn ("\x00" ^ jid ^ "\x00" ^ pass)
- in gen_auth mechanism
+ in let xmlns = "urn:ietf:params:xml:ns:xmpp-sasl" in
+ let stanza_list = [`Start_element
+ ((xmlns, "auth"),
+ [(("", "xmlns"), xmlns);
+ (("", "mechanism"), show_auth_mechanism mechanism)]);
+ `Text [gen_auth mechanism];
+ `End_element]
+ in Markup.(stanza_list |> of_list |> write_xml |> to_string)
diff --git a/lib/dune b/lib/dune
index 645b8b9..15220c8 100644
--- a/lib/dune
+++ b/lib/dune
@@ -3,5 +3,6 @@
(libraries
lwt
base64
- portal)
+ portal
+ markup)
(preprocess (pps ppx_deriving.show)))