Skip to content

Commit 8353f2a

Browse files
progvalspb
authored andcommitted
Reply with RPL_SASLFAIL instead of NOTICE on invalid base64
This is consistent with Ergo, InspIRCd, Solanum, UnrealIRCd
1 parent 8154447 commit 8353f2a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

sable_ircd/src/command/handlers/services/sasl.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use sable_network::{
66
use super::*;
77
use base64::prelude::*;
88

9+
const DEFAULT_SASL_FAIL: &str = "SASL authentication failed";
10+
911
#[command_handler("AUTHENTICATE")]
1012
async fn handle_authenticate(
1113
source: PreClientSource,
@@ -22,7 +24,7 @@ async fn handle_authenticate(
2224
RemoteServicesServerRequestType::AbortAuthenticate(*session)
2325
} else {
2426
let Ok(data) = BASE64_STANDARD.decode(text) else {
25-
response.notice("Invalid base64");
27+
response.numeric(make_numeric!(SaslFail, "Invalid Base64"));
2628
return Ok(());
2729
};
2830

@@ -39,7 +41,7 @@ async fn handle_authenticate(
3941

4042
for ban in net.network_bans().find_pre_sasl(&user_details) {
4143
if let NetworkBanAction::DenySasl = ban.action {
42-
response.numeric(make_numeric!(SaslFail));
44+
response.numeric(make_numeric!(SaslFail, DEFAULT_SASL_FAIL));
4345
return Ok(());
4446
}
4547
}
@@ -88,7 +90,7 @@ async fn handle_authenticate(
8890
response.numeric(make_numeric!(SaslSuccess));
8991
}
9092
Fail => {
91-
response.numeric(make_numeric!(SaslFail));
93+
response.numeric(make_numeric!(SaslFail, DEFAULT_SASL_FAIL));
9294
}
9395
Aborted => {
9496
response.numeric(make_numeric!(SaslAborted));
@@ -116,6 +118,6 @@ fn do_sasl_external(
116118
}
117119
}
118120

119-
response.numeric(make_numeric!(SaslFail));
121+
response.numeric(make_numeric!(SaslFail, DEFAULT_SASL_FAIL));
120122
Ok(())
121123
}

sable_ircd/src/messages/numeric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ define_messages! {
138138

139139
900(LoggedIn) => { (account: &Nickname) => "* {account} :You are now logged in as {account}" }, // TODO: <nick>!<ident>@<host> instead of *
140140
903(SaslSuccess) => { () => ":SASL authentication successful" },
141-
904(SaslFail) => { () => ":SASL authentication failed" },
141+
904(SaslFail) => { (reason: &str) => ":{reason}" },
142142
906(SaslAborted) => { () => ":SASL authentication aborted" }
143143
}

0 commit comments

Comments
 (0)