From af41ba0181d0f23591d7b82d3425c419c8ba73da Mon Sep 17 00:00:00 2001 From: Clombrong Date: Tue, 10 Jun 2025 02:03:01 +0200 Subject: feat(auth): wrap plain auth in stanza --- lib/auth.ml | 9 ++++++++- lib/dune | 3 ++- 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))) -- cgit v1.2.3