···2020 (fun _ expires_at -> if expires_at > now then Some expires_at else None)
2121 jti_cache
22222323+let revocation_cache : (string, int) Hashtbl.t = Hashtbl.create 1000
2424+2525+let cleanup_revocation_cache () =
2626+ let now_s = int_of_float (Unix.gettimeofday ()) in
2727+ let max_token_age_s = Constants.access_token_expiry_ms / 1000 in
2828+ Hashtbl.filter_map_inplace
2929+ (fun _ revoked_at ->
3030+ if now_s - revoked_at < max_token_age_s then Some revoked_at else None )
3131+ revocation_cache
3232+3333+let revoke_tokens_for_did did =
3434+ let now_s = int_of_float (Unix.gettimeofday ()) in
3535+ Hashtbl.replace revocation_cache did now_s ;
3636+ if Hashtbl.length revocation_cache mod 50 = 0 then cleanup_revocation_cache ()
3737+3838+let is_token_revoked ~did ~iat =
3939+ match Hashtbl.find_opt revocation_cache did with
4040+ | Some revoked_at ->
4141+ iat < revoked_at
4242+ | None ->
4343+ false
4444+2345let compute_nonce secret counter =
2446 let data = Bytes.create 8 in
2547 Bytes.set_int64_be data 0 (Int64.of_int counter) ;
+3-3
pegasus/lib/xrpc.ml
···108108 in
109109 let () =
110110 let to_expose =
111111- (* see comments on UseDpopNonce____Error in errors.ml *)
111111+ (* see comments on Dpop____Error in errors.ml *)
112112 if Dream.status res = `Unauthorized then "DPoP-Nonce, WWW-Authenticate"
113113 else if Dream.status res = `Bad_Request then "DPoP-Nonce"
114114 else ""
···146146 let%lwt res = exn_to_response e in
147147 Lwt.return
148148 ( match e with
149149- | UseDpopNonceAuthError | UseDpopNonceResourceError ->
149149+ | DpopAuthError _ | DpopResourceError _ ->
150150 add_dpop_nonce_if_needed res
151151 | _ ->
152152 res )
···155155 Dream.redirect init.req r
156156 | Rate_limiter.Rate_limit_exceeded status ->
157157 rate_limit_response status
158158- | (UseDpopNonceAuthError | UseDpopNonceResourceError) as e ->
158158+ | (DpopAuthError _ | DpopResourceError _) as e ->
159159 let%lwt res = exn_to_response e in
160160 Lwt.return (add_dpop_nonce_if_needed res)
161161 | e ->