Skip to content

Commit

Permalink
feat: Add AuthMechanism::ScramSha{1,256}{,Plus}
Browse files Browse the repository at this point in the history
  • Loading branch information
duesee committed Dec 19, 2023
1 parent b699de4 commit 91c801e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions imap-types/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ pub enum AuthMechanism<'a> {
/// * <https://developers.google.com/gmail/imap/xoauth2-protocol>
XOAuth2,

/// SCRAM-SHA-1
///
/// # Reference(s):
///
/// * https://datatracker.ietf.org/doc/html/rfc5802
ScramSha1,

/// SCRAM-SHA-1-PLUS
///
/// # Reference(s):
///
/// * https://datatracker.ietf.org/doc/html/rfc5802
ScramSha1Plus,

/// SCRAM-SHA-256
///
/// # Reference(s):
///
/// * https://datatracker.ietf.org/doc/html/rfc7677
ScramSha256,

/// SCRAM-SHA-256-PLUS
///
/// # Reference(s):
///
/// * https://datatracker.ietf.org/doc/html/rfc7677
ScramSha256Plus,

/// Some other (unknown) mechanism.
Other(AuthMechanismOther<'a>),
}
Expand All @@ -85,6 +113,10 @@ impl<'a> From<Atom<'a>> for AuthMechanism<'a> {
"PLAIN" => Self::Plain,
"LOGIN" => Self::Login,
"XOAUTH2" => Self::XOAuth2,
"SCRAM-SHA-1" => Self::ScramSha1,
"SCRAM-SHA-1-PLUS" => Self::ScramSha1Plus,
"SCRAM-SHA-256" => Self::ScramSha256,
"SCRAM-SHA-256-PLUS" => Self::ScramSha256Plus,
_ => Self::Other(AuthMechanismOther(atom)),
}
}
Expand All @@ -102,6 +134,10 @@ impl<'a> AsRef<str> for AuthMechanism<'a> {
Self::Plain => "PLAIN",
Self::Login => "LOGIN",
Self::XOAuth2 => "XOAUTH2",
Self::ScramSha1 => "SCRAM-SHA-1",
Self::ScramSha1Plus => "SCRAM-SHA-1-PLUS",
Self::ScramSha256 => "SCRAM-SHA-256",
Self::ScramSha256Plus => "SCRAM-SHA-256-PLUS",
Self::Other(other) => other.0.as_ref(),
}
}
Expand Down

4 comments on commit 91c801e

@Neustradamus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duesee: Very good job!
Important: The order has changed, please look the link after!
I will do some tickets ^^

Linked to:

@duesee
Copy link
Owner Author

@duesee duesee commented on 91c801e Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Neustradamus! Thanks! :-)

Can you elaborate what you mean with "The order has changed"?

@Neustradamus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duesee: Can you look the beginning part here:

@duesee
Copy link
Owner Author

@duesee duesee commented on 91c801e Dec 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the recommended order? I.e., ...

- EXTERNAL
- SCRAM-SHA-256-PLUS
- SCRAM-SHA-1-PLUS
- SCRAM-SHA-256
- SCRAM-SHA-1
- PLAIN

... ? This is not relevant here as it's only an enum definition. imap-flow will do.

Please sign in to comment.