Skip to content

Commit 35fe035

Browse files
progvalspb
authored andcommitted
Use default failure message even for invalid base64
A future commit will make SaslFail round-trip through services, which makes it not work as-is; and base64 issues should be pretty rare so they are not worth bothering
1 parent 8353f2a commit 35fe035

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

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

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

9-
const DEFAULT_SASL_FAIL: &str = "SASL authentication failed";
10-
119
#[command_handler("AUTHENTICATE")]
1210
async fn handle_authenticate(
1311
source: PreClientSource,
@@ -24,7 +22,7 @@ async fn handle_authenticate(
2422
RemoteServicesServerRequestType::AbortAuthenticate(*session)
2523
} else {
2624
let Ok(data) = BASE64_STANDARD.decode(text) else {
27-
response.numeric(make_numeric!(SaslFail, "Invalid Base64"));
25+
response.numeric(make_numeric!(SaslFail));
2826
return Ok(());
2927
};
3028

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

4240
for ban in net.network_bans().find_pre_sasl(&user_details) {
4341
if let NetworkBanAction::DenySasl = ban.action {
44-
response.numeric(make_numeric!(SaslFail, DEFAULT_SASL_FAIL));
42+
response.numeric(make_numeric!(SaslFail));
4543
return Ok(());
4644
}
4745
}
@@ -90,7 +88,7 @@ async fn handle_authenticate(
9088
response.numeric(make_numeric!(SaslSuccess));
9189
}
9290
Fail => {
93-
response.numeric(make_numeric!(SaslFail, DEFAULT_SASL_FAIL));
91+
response.numeric(make_numeric!(SaslFail));
9492
}
9593
Aborted => {
9694
response.numeric(make_numeric!(SaslAborted));
@@ -118,6 +116,6 @@ fn do_sasl_external(
118116
}
119117
}
120118

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

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) => { (reason: &str) => ":{reason}" },
141+
904(SaslFail) => { () => ":SASL authentication failed" },
142142
906(SaslAborted) => { () => ":SASL authentication aborted" }
143143
}

0 commit comments

Comments
 (0)