@@ -8,11 +8,11 @@ exception NotFoundError of (string * string)
88
99exception Redirect of string
1010
11- (* HTTP 400, { error: "use_dpop_nonce " } — https://datatracker.ietf.org/doc/html/rfc9449#section-8 *)
12- exception UseDpopNonceAuthError
11+ (* HTTP 400, { error: "... " } — https://datatracker.ietf.org/doc/html/rfc9449#section-8 *)
12+ exception DpopAuthError of string
1313
14- (* HTTP 401, WWW-Authenticate — https://datatracker.ietf.org/doc/html/rfc9449#section-9 *)
15- exception UseDpopNonceResourceError
14+ (* HTTP 401, WWW-Authenticate=DPoP error="..." — https://datatracker.ietf.org/doc/html/rfc9449#section-9 *)
15+ exception DpopResourceError of string
1616
1717let is_xrpc_error = function
1818 | InvalidRequestError _
@@ -34,9 +34,9 @@ let auth_required ?(name = "AuthRequired") msg = raise (AuthError (name, msg))
3434
3535let not_found ?(name = " NotFound" ) msg = raise (NotFoundError (name, msg))
3636
37- let use_dpop_nonce_auth () = raise UseDpopNonceAuthError
37+ let dpop_auth error = raise ( DpopAuthError error)
3838
39- let use_dpop_nonce_resource () = raise UseDpopNonceResourceError
39+ let dpop_resource error = raise ( DpopResourceError error)
4040
4141let printer = function
4242 | InvalidRequestError (error , message ) ->
@@ -47,10 +47,10 @@ let printer = function
4747 Some (Printf. sprintf " Auth error (%s): %s" error message)
4848 | NotFoundError (error , message ) ->
4949 Some (Printf. sprintf " Not found (%s): %s" error message)
50- | UseDpopNonceAuthError ->
51- Some " Use DPoP nonce "
52- | UseDpopNonceResourceError ->
53- Some " Use DPoP nonce "
50+ | DpopAuthError error ->
51+ Some ( Printf. sprintf " DPoP auth error (%s) " error)
52+ | DpopResourceError error ->
53+ Some ( Printf. sprintf " DPoP resource error (%s) " error)
5454 | _ ->
5555 None
5656
@@ -72,18 +72,18 @@ let exn_to_response exn =
7272 | NotFoundError (error , message ) ->
7373 Log. debug (fun log -> log " not found error: %s - %s" error message) ;
7474 format_response error message `Not_Found
75- | UseDpopNonceAuthError ->
76- Log. debug (fun log -> log " use_dpop_nonce auth error" ) ;
75+ | DpopAuthError e ->
76+ Log. debug (fun log -> log " dpop auth error" ) ;
7777 Dream. json ~status: `Bad_Request
7878 ~headers: [(" Access-Control-Expose-Headers" , " DPoP-Nonce" )]
79- {| { " error" : " use_dpop_nonce " }| }
80- | UseDpopNonceResourceError ->
81- Log. debug (fun log -> log " use_dpop_nonce resource error" ) ;
79+ ( Format. sprintf {| { " error" : " %s " }| } e)
80+ | DpopResourceError e ->
81+ Log. debug (fun log -> log " dpop resource error" ) ;
8282 Dream. json ~status: `Unauthorized
8383 ~headers:
84- [ (" WWW-Authenticate" , {| DPoP error= " use_dpop_nonce " | })
84+ [ (" WWW-Authenticate" , Format. sprintf {| DPoP error= " %s " | } e )
8585 ; (" Access-Control-Expose-Headers" , " DPoP-Nonce, WWW-Authenticate" ) ]
86- {| { " error" : " use_dpop_nonce " }| }
86+ ( Format. sprintf {| { " error" : " %s " }| } e)
8787 | e ->
8888 Log. warn (fun log ->
8989 log " unexpected internal error: %s" (Printexc. to_string e) ) ;
0 commit comments