Skip to content

Commit

Permalink
Use ERR_SASLFAIL instead of ERR_SASLABORTED on failure
Browse files Browse the repository at this point in the history
> ERR_SASLABORTED is sent when the SASL authentication is aborted because
> the client sent an AUTHENTICATE command with * as the parameter

-- https://ircv3.net/specs/extensions/sasl-3.1
  • Loading branch information
progval authored and spb committed Sep 17, 2023
1 parent e80d611 commit 373debb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sable_services/src/server/command/sasl_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use RemoteServerResponse::Authenticate;
impl<DB: DatabaseConnection> ServicesServer<DB> {
pub fn begin_authenticate(&self, session: SaslSessionId, mechanism: String) -> CommandResult {
if self.sasl_sessions.contains_key(&session) {
return Ok(Authenticate(Aborted));
return Ok(Authenticate(Fail));
}

if !self.sasl_mechanisms.contains_key(&mechanism) {
return Ok(Authenticate(Aborted));
return Ok(Authenticate(Fail));
}

self.sasl_sessions.insert(
Expand All @@ -24,12 +24,12 @@ impl<DB: DatabaseConnection> ServicesServer<DB> {

pub fn authenticate(&self, session_id: SaslSessionId, data: Vec<u8>) -> CommandResult {
let Some(session) = self.sasl_sessions.get(&session_id) else {
return Ok(Authenticate(Aborted));
return Ok(Authenticate(Fail));
};

let Some(mechanism) = self.sasl_mechanisms.get(&session.mechanism) else {
self.sasl_sessions.remove(&session_id);
return Ok(Authenticate(Aborted));
return Ok(Authenticate(Fail));
};

let response = mechanism.step(self, &session, data)?;
Expand Down

0 comments on commit 373debb

Please sign in to comment.