mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
Update async-imap to fix Oauth2
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -165,9 +165,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-imap"
|
name = "async-imap"
|
||||||
version = "0.3.3"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c082ecb52ec3af0aa61d4314750086134ef9c7521edb41f7981c0f45650c0c7b"
|
checksum = "caadebe62f5ad78d6418a47a86b5b84439a52bdd5c893e55a5c81974da111455"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-native-tls",
|
"async-native-tls",
|
||||||
"async-std",
|
"async-std",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ num-traits = "0.2.6"
|
|||||||
async-smtp = "0.3"
|
async-smtp = "0.3"
|
||||||
email = { git = "https://github.com/deltachat/rust-email", branch = "master" }
|
email = { git = "https://github.com/deltachat/rust-email", branch = "master" }
|
||||||
lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" }
|
lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" }
|
||||||
async-imap = "0.3.1"
|
async-imap = "0.4.0"
|
||||||
async-native-tls = { version = "0.3.3" }
|
async-native-tls = { version = "0.3.3" }
|
||||||
async-std = { version = "1.6.1", features = ["unstable"] }
|
async-std = { version = "1.6.1", features = ["unstable"] }
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ impl Client {
|
|||||||
pub async fn authenticate<A: async_imap::Authenticator, S: AsRef<str>>(
|
pub async fn authenticate<A: async_imap::Authenticator, S: AsRef<str>>(
|
||||||
self,
|
self,
|
||||||
auth_type: S,
|
auth_type: S,
|
||||||
authenticator: &A,
|
authenticator: A,
|
||||||
) -> std::result::Result<Session, (ImapError, Self)> {
|
) -> std::result::Result<Session, (ImapError, Self)> {
|
||||||
let Client { inner, is_secure } = self;
|
let Client { inner, is_secure } = self;
|
||||||
let session =
|
let session =
|
||||||
@@ -85,9 +85,6 @@ impl Client {
|
|||||||
let tls_stream: Box<dyn SessionStream> =
|
let tls_stream: Box<dyn SessionStream> =
|
||||||
Box::new(tls.connect(domain.as_ref(), stream).await?);
|
Box::new(tls.connect(domain.as_ref(), stream).await?);
|
||||||
let mut client = ImapClient::new(tls_stream);
|
let mut client = ImapClient::new(tls_stream);
|
||||||
if std::env::var(crate::DCC_IMAP_DEBUG).is_ok() {
|
|
||||||
client.debug = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let _greeting = client
|
let _greeting = client
|
||||||
.read_response()
|
.read_response()
|
||||||
@@ -104,9 +101,6 @@ impl Client {
|
|||||||
let stream: Box<dyn SessionStream> = Box::new(TcpStream::connect(addr).await?);
|
let stream: Box<dyn SessionStream> = Box::new(TcpStream::connect(addr).await?);
|
||||||
|
|
||||||
let mut client = ImapClient::new(stream);
|
let mut client = ImapClient::new(stream);
|
||||||
if std::env::var(crate::DCC_IMAP_DEBUG).is_ok() {
|
|
||||||
client.debug = true;
|
|
||||||
}
|
|
||||||
let _greeting = client
|
let _greeting = client
|
||||||
.read_response()
|
.read_response()
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ struct OAuth2 {
|
|||||||
impl async_imap::Authenticator for OAuth2 {
|
impl async_imap::Authenticator for OAuth2 {
|
||||||
type Response = String;
|
type Response = String;
|
||||||
|
|
||||||
fn process(&self, _data: &[u8]) -> Self::Response {
|
fn process(&mut self, _data: &[u8]) -> Self::Response {
|
||||||
format!(
|
format!(
|
||||||
"user={}\x01auth=Bearer {}\x01\x01",
|
"user={}\x01auth=Bearer {}\x01\x01",
|
||||||
self.user, self.access_token
|
self.user, self.access_token
|
||||||
@@ -262,7 +262,7 @@ impl Imap {
|
|||||||
user: imap_user.into(),
|
user: imap_user.into(),
|
||||||
access_token: token,
|
access_token: token,
|
||||||
};
|
};
|
||||||
client.authenticate("XOAUTH2", &auth).await
|
client.authenticate("XOAUTH2", auth).await
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::OauthError);
|
return Err(Error::OauthError);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user