File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,18 @@ module Main (R : Mirage_random.S) (Clock: Mirage_clock.PCLOCK) (_ : sig end) (KE
4747
4848 let get_user_from_auth = function
4949 | None -> None
50- | Some v -> match Astring.String. cut ~sep: " Basic " v with
51- | Some ("" , b64 ) ->
52- begin match Base64. decode b64 with
53- | Error _ -> Some " bad b64 encoding"
54- | Ok data -> match Astring.String. cut ~sep: " :" data with
55- | Some (user , _ ) -> Some user
56- | None -> Some " no : between user and password"
57- end
58- | _ -> Some " not basic"
50+ | Some v ->
51+ let basic = " Basic " in
52+ let blen = String. length basic
53+ and vlen = String. length v
54+ in
55+ if vlen > = blen && String. (equal (sub v 0 blen) basic) then
56+ let b64 = String. sub v blen (vlen - blen) in
57+ match Base64. decode b64 with
58+ | Error _ -> Some " bad b64 encoding"
59+ | Ok data -> Some (List. hd (String. split_on_char ':' data))
60+ else
61+ Some " not basic"
5962
6063 let serve (author_k , user_agent_k , request_k ) callback =
6164 let callback (_ , cid ) request body =
You can’t perform that action at this time.
0 commit comments