enum AuthState {
None { euid: Euid },
Superuser { euid: Euid, auth: AuthorisationSuperuser },
- Ssh { id: sshkeys::Id, nonce: sshkeys::Nonce,
- auth: Authorisation<(sshkeys::Id, sshkeys::Nonce)>, },
+ Ssh { key: sshkeys::KeySpec, auth: Authorisation<sshkeys::KeySpec> },
}
#[derive(Debug,Clone)]
}
Fine
},
- MC::SetRestrictedSshScope { id, nonce } => {
+ MC::SetRestrictedSshScope { key } => {
let good_uid = Some(config().ssh_proxy_uid);
let auth = cs.authorised_uid(good_uid, Some("SetRestrictedScope"))
.map_err(|_| ME::AuthorisationError)?;
let auth = auth.therefore_ok();
- cs.authstate = AuthState::Ssh { id, nonce, auth };
+ cs.authstate = AuthState::Ssh { key, auth };
Fine
},
match &cs.authstate {
&AuthState::Superuser { auth, .. } => return auth.into(),
- &AuthState::Ssh { id: sshkey_id, ref nonce, auth } => {
+ &AuthState::Ssh { ref key, auth } => {
let wanted_base_account = AccountName {
scope: wanted.clone(),
subaccount: default(),
if let Ok::<_,AccountNotFound>
((record, _acctid)) = ag.lookup(&wanted_base_account);
if let
- Some(auth) = record.ssh_keys.check(ag, sshkey_id, &nonce, auth);
+ Some(auth) = record.ssh_keys.check(ag, &key, auth);
then { return Ok(auth) }
else { throw!(AuthorisationError("ssh key not authorised".into())); }
}
pub enum MgmtCommand {
Noop,
SetSuperuser(bool),
- SetRestrictedSshScope { id: sshkeys::Id, nonce: sshkeys::Nonce },
+ SetRestrictedSshScope { key: sshkeys::KeySpec },
CreateAccount(AccountDetails),
UpdateAccount(AccountDetails),
comment: Comment,
}
+#[derive(Debug,Clone,Serialize,Deserialize)]
+pub struct KeySpec {
+ id: sshkeys::Id,
+ nonce: sshkeys::Nonce,
+}
+
mod veneer {
// openssh_keys's API is a little odd. We make our own mini-API.
use crate::prelude::*;
}
impl PerScope {
- pub fn check(&self, ag: &AccountsGuard, id: Id, nonce: &Nonce,
- auth_in: Authorisation<(Id, Nonce)>)
+ pub fn check(&self, ag: &AccountsGuard, authed_key: &KeySpec,
+ auth_in: Authorisation<KeySpec>)
-> Option<Authorisation<AccountScope>> {
let gl = &ag.get().ssh_keys;
for sk in &self.authorised {
if_chain!{
if let Some(sk) = sk;
- if sk.id == id;
- if let Some(key) = gl.keys.get(sk.id);
- if &key.nonce == nonce;
+ if sk.id == authed_key.id;
+ if let Some(want_key) = gl.keys.get(sk.id);
+ if &want_key.nonce == &authed_key.nonce;
then {
// We have checked id and nonce, against those allowed
let auth = auth_in.therefore_ok();