distant_auth/handler/methods.rs
1use std::io;
2
3use async_trait::async_trait;
4
5use crate::msg::{Challenge, ChallengeResponse, Error, Info, Verification, VerificationResponse};
6
7/// Interface for a handler of authentication requests for a specific authentication method.
8#[async_trait]
9pub trait AuthMethodHandler: Send {
10 /// Callback when a challenge is received, returning answers to the given questions.
11 async fn on_challenge(&mut self, challenge: Challenge) -> io::Result<ChallengeResponse>;
12
13 /// Callback when a verification request is received, returning true if approvided or false if
14 /// unapproved.
15 async fn on_verification(
16 &mut self,
17 verification: Verification,
18 ) -> io::Result<VerificationResponse>;
19
20 /// Callback when information is received. To fail, return an error from this function.
21 async fn on_info(&mut self, info: Info) -> io::Result<()>;
22
23 /// Callback when an error is received. Regardless of the result returned, this will terminate
24 /// the authenticator. In the situation where a custom error would be preferred, have this
25 /// callback return an error.
26 async fn on_error(&mut self, error: Error) -> io::Result<()>;
27}
28
29mod prompt;
30pub use prompt::*;
31
32mod static_key;
33pub use static_key::*;