1use std::sync::Arc;
2use thiserror::Error;
3
4#[derive(Debug, Clone, Error)]
5pub enum OAuthError {
6 #[error("User cancelled authorization")]
7 UserCancelled,
8
9 #[error("OAuth credential storage error: {0}")]
10 CredentialStore(String),
11
12 #[error("rmcp auth error: {0}")]
13 Rmcp(String),
14
15 #[error("IO error: {0}")]
16 Io(Arc<std::io::Error>),
17
18 #[error("Invalid OAuth callback: {0}")]
19 InvalidCallback(String),
20
21 #[error("Invalid JWT: {0}")]
22 InvalidJwt(String),
23
24 #[error("Token exchange failed: {0}")]
25 TokenExchange(String),
26
27 #[error("OAuth state mismatch — possible CSRF attack")]
28 StateMismatch,
29
30 #[error("No credentials found: {0}")]
31 NoCredentials(String),
32}
33
34impl From<std::io::Error> for OAuthError {
35 fn from(error: std::io::Error) -> Self {
36 Self::Io(Arc::new(error))
37 }
38}