diff --git a/crates/rpc/rpc-builder/src/auth.rs b/crates/rpc/rpc-builder/src/auth.rs index 25626e4f12d3..f22fd554ca6d 100644 --- a/crates/rpc/rpc-builder/src/auth.rs +++ b/crates/rpc/rpc-builder/src/auth.rs @@ -221,6 +221,30 @@ impl AuthRpcModule { self.module_mut().merge(other.into()).map(|_| true) } + /// Removes the method with the given name from the configured authenticated methods. + /// + /// Returns `true` if the method was found and removed, `false` otherwise. + pub fn remove_auth_method(&mut self, method_name: &'static str) -> bool { + self.module_mut().remove_method(method_name).is_some() + } + + /// Removes the given methods from the configured authenticated methods. + pub fn remove_auth_methods(&mut self, methods: impl IntoIterator) { + for name in methods { + self.remove_auth_method(name); + } + } + + /// Replace the given [Methods] in the configured authenticated methods. + pub fn replace_auth_methods( + &mut self, + other: impl Into, + ) -> Result { + let other = other.into(); + self.remove_auth_methods(other.method_names()); + self.merge_auth_methods(other) + } + /// Convenience function for starting a server pub async fn start_server( self,