Skip to content

Commit 4ec8130

Browse files
committed
Don't fail on unsupported auth methods
1 parent 970b5f6 commit 4ec8130

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ use std::rt::io::net::ip::SocketAddr;
1919
use std::rt::io::net::tcp::TcpStream;
2020

2121
use message::{BackendMessage,
22+
AuthenticationOk,
23+
AuthenticationKerberosV5,
2224
AuthenticationCleartextPassword,
2325
AuthenticationMD5Password,
24-
AuthenticationOk,
26+
AuthenticationSCMCredential,
27+
AuthenticationGSS,
28+
AuthenticationSSPI,
2529
BackendKeyData,
2630
BindComplete,
2731
CommandComplete,
@@ -180,7 +184,8 @@ impl PostgresConnection {
180184
let conn = PostgresConnection {
181185
stream: Cell::new(stream),
182186
next_stmt_id: Cell::new(0),
183-
notice_handler: Cell::new(~DefaultNoticeHandler as ~PostgresNoticeHandler)
187+
notice_handler: Cell::new(~DefaultNoticeHandler
188+
as ~PostgresNoticeHandler)
184189
};
185190

186191
args.push((~"client_encoding", ~"UTF8"));
@@ -299,6 +304,10 @@ impl PostgresConnection {
299304
password: output.as_slice()
300305
});
301306
}
307+
AuthenticationKerberosV5
308+
| AuthenticationSCMCredential
309+
| AuthenticationGSS
310+
| AuthenticationSSPI => return Some(UnsupportedAuthentication),
302311
_ => fail!()
303312
}
304313

src/message.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ pub static PROTOCOL_VERSION: i32 = 0x0003_0000;
1212

1313
#[deriving(ToStr)]
1414
pub enum BackendMessage {
15+
AuthenticationOk,
16+
AuthenticationKerberosV5,
1517
AuthenticationCleartextPassword,
1618
AuthenticationMD5Password {
1719
salt: ~[u8]
1820
},
19-
AuthenticationOk,
21+
AuthenticationSCMCredential,
22+
AuthenticationGSS,
23+
AuthenticationSSPI,
2024
BackendKeyData {
2125
process_id: i32,
2226
secret_key: i32
@@ -310,9 +314,13 @@ fn read_data_row(buf: &mut MemReader) -> BackendMessage {
310314
fn read_auth_message(buf: &mut MemReader) -> BackendMessage {
311315
match buf.read_be_i32_() {
312316
0 => AuthenticationOk,
317+
2 => AuthenticationKerberosV5,
313318
3 => AuthenticationCleartextPassword,
314319
5 => AuthenticationMD5Password { salt: buf.read_bytes(4) },
315-
val => fail2!("Unknown Authentication identifier `{}`", val)
320+
6 => AuthenticationSCMCredential,
321+
7 => AuthenticationGSS,
322+
9 => AuthenticationSSPI,
323+
val => fail2!("Invalid authentication identifier `{}`", val)
316324
}
317325
}
318326

0 commit comments

Comments
 (0)