Skip to content

Commit 0d1d073

Browse files
committed
feat(client): support gssapi-with-mic auth
1 parent c4be19f commit 0d1d073

5 files changed

Lines changed: 444 additions & 1 deletion

File tree

russh/src/auth.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub enum MethodKind {
3333
PublicKey,
3434
HostBased,
3535
KeyboardInteractive,
36+
GssapiWithMic,
3637
}
3738

3839
impl From<&MethodKind> for &'static str {
@@ -43,6 +44,7 @@ impl From<&MethodKind> for &'static str {
4344
MethodKind::PublicKey => "publickey",
4445
MethodKind::HostBased => "hostbased",
4546
MethodKind::KeyboardInteractive => "keyboard-interactive",
47+
MethodKind::GssapiWithMic => "gssapi-with-mic",
4648
}
4749
}
4850
}
@@ -55,6 +57,7 @@ impl FromStr for MethodKind {
5557
"publickey" => Ok(MethodKind::PublicKey),
5658
"hostbased" => Ok(MethodKind::HostBased),
5759
"keyboard-interactive" => Ok(MethodKind::KeyboardInteractive),
60+
"gssapi-with-mic" => Ok(MethodKind::GssapiWithMic),
5861
_ => Err(()),
5962
}
6063
}
@@ -119,6 +122,7 @@ impl MethodSet {
119122
MethodKind::PublicKey,
120123
MethodKind::HostBased,
121124
MethodKind::KeyboardInteractive,
125+
MethodKind::GssapiWithMic,
122126
])
123127
}
124128

@@ -164,6 +168,29 @@ pub trait Signer: Sized {
164168
) -> impl Future<Output = Result<Vec<u8>, Self::Error>> + Send;
165169
}
166170

171+
#[derive(Debug, Clone, PartialEq, Eq)]
172+
pub enum GssapiStep {
173+
Continue {
174+
token: Vec<u8>,
175+
},
176+
Complete {
177+
token: Option<Vec<u8>>,
178+
mic: Option<Vec<u8>>,
179+
},
180+
}
181+
182+
#[cfg_attr(feature = "async-trait", async_trait::async_trait)]
183+
pub trait GssapiAuthenticator: Sized {
184+
type Error: From<crate::SendError>;
185+
186+
fn gssapi_step(
187+
&mut self,
188+
selected_mechanism: Vec<u8>,
189+
input_token: Option<Vec<u8>>,
190+
mic_data: Vec<u8>,
191+
) -> impl Future<Output = Result<GssapiStep, Self::Error>> + Send;
192+
}
193+
167194
#[derive(Debug, Error)]
168195
pub enum AgentAuthError {
169196
#[error(transparent)]
@@ -220,6 +247,9 @@ pub enum Method {
220247
KeyboardInteractive {
221248
submethods: String,
222249
},
250+
GssapiWithMic {
251+
mechanism_oids: Vec<Vec<u8>>,
252+
},
223253
// Hostbased,
224254
}
225255

@@ -258,6 +288,7 @@ pub enum CurrentRequest {
258288
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
259289
submethods: String,
260290
},
291+
GssapiWithMic,
261292
}
262293

263294
impl AuthRequest {
@@ -284,6 +315,14 @@ impl AuthRequest {
284315
principal: None,
285316
rejection_count: 0,
286317
},
318+
Method::GssapiWithMic { .. } => Self {
319+
initial_methods: MethodSet::all(),
320+
methods: MethodSet::all(),
321+
partial_success: false,
322+
current: Some(CurrentRequest::GssapiWithMic),
323+
principal: None,
324+
rejection_count: 0,
325+
},
287326
_ => Self {
288327
initial_methods: MethodSet::all(),
289328
methods: MethodSet::all(),

0 commit comments

Comments
 (0)