mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-10 17:43:23 +01:00
Fixes all those unused import warnings
This commit is contained in:
parent
fbc661f478
commit
26f1de1907
@ -1,14 +1,12 @@
|
||||
use std::pin::Pin;
|
||||
use std::task::{Poll, Context};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Mutex;
|
||||
use std::collections::HashMap;
|
||||
use std::future::Future;
|
||||
|
||||
use smol::Executor;
|
||||
|
||||
use futures::{future::BoxFuture, Stream, StreamExt};
|
||||
use futures::{future::BoxFuture, Stream};
|
||||
use futures::channel::mpsc;
|
||||
use futures_signals::signal::{Signal, MutableSignalCloned, MutableSignal, Mutable};
|
||||
use futures_signals::signal::Signal;
|
||||
|
||||
use crate::db::machine::MachineState;
|
||||
use crate::config::Config;
|
||||
|
@ -1,7 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
use capnp::capability::{Params, Results, Promise};
|
||||
|
||||
use crate::schema::connection_capnp;
|
||||
@ -9,8 +7,6 @@ use crate::connection::Session;
|
||||
|
||||
use crate::db::Databases;
|
||||
|
||||
use crate::builtin;
|
||||
|
||||
use crate::network::Network;
|
||||
|
||||
pub mod auth;
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
use rsasl::{
|
||||
SASL,
|
||||
Property,
|
||||
@ -21,9 +19,6 @@ use serde::{Serialize, Deserialize};
|
||||
|
||||
use capnp::capability::{Params, Results, Promise};
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::config::Settings;
|
||||
|
||||
use crate::api::Session;
|
||||
|
||||
pub use crate::schema::auth_capnp;
|
||||
|
@ -7,7 +7,6 @@ use crate::schema::api_capnp::machines;
|
||||
use crate::connection::Session;
|
||||
|
||||
use crate::db::Databases;
|
||||
use crate::db::machine::uuid_from_api;
|
||||
|
||||
use crate::network::Network;
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use crate::db::access::{
|
||||
Permission,
|
||||
PermissionBuf,
|
||||
PermRule,
|
||||
RoleIdentifier,
|
||||
Role,
|
||||
};
|
||||
use crate::db::access::Permission;
|
||||
|
||||
lazy_static! {
|
||||
static ref AUTH_PERM: &'static Permission = Permission::new("bffh.auth");
|
||||
|
@ -1,8 +1,5 @@
|
||||
use std::default::Default;
|
||||
use std::str::FromStr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::io::Read;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
@ -6,8 +6,7 @@ use slog::Logger;
|
||||
|
||||
use smol::net::TcpStream;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
use crate::api::auth;
|
||||
use crate::error::Result;
|
||||
use crate::api::Bootstrap;
|
||||
|
||||
use capnp_rpc::{twoparty, rpc_twoparty_capnp};
|
||||
@ -17,7 +16,6 @@ use crate::schema::connection_capnp;
|
||||
use crate::db::Databases;
|
||||
use crate::db::access::{AccessControl, Permission};
|
||||
use crate::db::user::User;
|
||||
use crate::builtin;
|
||||
use crate::network::Network;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -5,7 +5,7 @@ use std::str::FromStr;
|
||||
use slog::Logger;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::config::Settings;
|
||||
use crate::config::Config;
|
||||
|
||||
/// (Hashed) password database
|
||||
pub mod pass;
|
||||
@ -34,7 +34,7 @@ pub struct Databases {
|
||||
const LMDB_MAX_DB: u32 = 16;
|
||||
|
||||
impl Databases {
|
||||
pub fn new(log: &Logger, config: &Settings) -> Result<Self> {
|
||||
pub fn new(log: &Logger, config: &Config) -> Result<Self> {
|
||||
|
||||
// Initialize the LMDB environment. This blocks until the mmap() finishes
|
||||
info!(log, "LMDB env");
|
||||
|
@ -2,29 +2,15 @@
|
||||
//!
|
||||
|
||||
use std::fmt;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::HashMap;
|
||||
use std::cmp::Ordering;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::sync::Arc;
|
||||
use std::iter::FromIterator;
|
||||
use std::convert::{TryFrom, Into};
|
||||
|
||||
use flexbuffers;
|
||||
use serde::{
|
||||
Serialize,
|
||||
Serializer,
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
Deserialize,
|
||||
Deserializer,
|
||||
};
|
||||
|
||||
use slog::Logger;
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor};
|
||||
|
||||
use crate::config::Settings;
|
||||
use crate::error::Result;
|
||||
|
||||
pub mod internal;
|
||||
@ -77,7 +63,7 @@ impl fmt::Debug for AccessControl {
|
||||
pub trait RoleDB {
|
||||
fn get_type_name(&self) -> &'static str;
|
||||
|
||||
fn get_role(&self, roleID: &RoleIdentifier) -> Result<Option<Role>>;
|
||||
fn get_role(&self, role_id: &RoleIdentifier) -> Result<Option<Role>>;
|
||||
|
||||
/// Check if a given user has the given permission
|
||||
///
|
||||
@ -95,8 +81,8 @@ pub trait RoleDB {
|
||||
fn check_roles(&self, roles: &[RoleIdentifier], perm: &Permission) -> Result<bool> {
|
||||
// Tally all roles. Makes dependent roles easier
|
||||
let mut roleset = HashMap::new();
|
||||
for roleID in roles {
|
||||
self.tally_role(&mut roleset, roleID)?;
|
||||
for role_id in roles {
|
||||
self.tally_role(&mut roleset, role_id)?;
|
||||
}
|
||||
|
||||
// Iter all unique role->permissions we've found and early return on match.
|
||||
@ -115,16 +101,16 @@ pub trait RoleDB {
|
||||
///
|
||||
/// A Default implementation exists which adapter may overwrite with more efficient
|
||||
/// implementations.
|
||||
fn tally_role(&self, roles: &mut HashMap<RoleIdentifier, Role>, roleID: &RoleIdentifier) -> Result<()> {
|
||||
if let Some(role) = self.get_role(roleID)? {
|
||||
fn tally_role(&self, roles: &mut HashMap<RoleIdentifier, Role>, role_id: &RoleIdentifier) -> Result<()> {
|
||||
if let Some(role) = self.get_role(role_id)? {
|
||||
// Only check and tally parents of a role at the role itself if it's the first time we
|
||||
// see it
|
||||
if !roles.contains_key(&roleID) {
|
||||
if !roles.contains_key(&role_id) {
|
||||
for parent in role.parents.iter() {
|
||||
self.tally_role(roles, parent)?;
|
||||
}
|
||||
|
||||
roles.insert(roleID.clone(), role);
|
||||
roles.insert(role_id.clone(), role);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,18 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use flexbuffers;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use slog::Logger;
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor, Iter};
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor};
|
||||
|
||||
use crate::config::Settings;
|
||||
use crate::error::Result;
|
||||
|
||||
use crate::db::access::{Permission, Role, RoleIdentifier, RoleDB};
|
||||
use crate::db::user::{User, UserData};
|
||||
use crate::db::user::UserData;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Internal {
|
||||
@ -39,9 +34,9 @@ impl Internal {
|
||||
debug!(self.log, "Checking user {:?} for permission {:?}", user, perm.as_ref());
|
||||
// Tally all roles. Makes dependent roles easier
|
||||
let mut roles = HashMap::new();
|
||||
for roleID in user.roles.iter() {
|
||||
debug!(self.log, "Tallying role {} for its parents", roleID);
|
||||
self._tally_role(txn, &mut roles, roleID)?;
|
||||
for role_id in user.roles.iter() {
|
||||
debug!(self.log, "Tallying role {} for its parents", role_id);
|
||||
self._tally_role(txn, &mut roles, role_id)?;
|
||||
}
|
||||
|
||||
// Iter all unique role->permissions we've found and early return on match.
|
||||
@ -62,26 +57,26 @@ impl Internal {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
fn _tally_role<T: Transaction>(&self, txn: &T, roles: &mut HashMap<RoleIdentifier, Role>, roleID: &RoleIdentifier) -> Result<()> {
|
||||
if let Some(role) = self._get_role(txn, roleID)? {
|
||||
fn _tally_role<T: Transaction>(&self, txn: &T, roles: &mut HashMap<RoleIdentifier, Role>, role_id: &RoleIdentifier) -> Result<()> {
|
||||
if let Some(role) = self._get_role(txn, role_id)? {
|
||||
// Only check and tally parents of a role at the role itself if it's the first time we
|
||||
// see it
|
||||
if !roles.contains_key(&roleID) {
|
||||
if !roles.contains_key(&role_id) {
|
||||
for parent in role.parents.iter() {
|
||||
self._tally_role(txn, roles, parent)?;
|
||||
}
|
||||
|
||||
roles.insert(roleID.clone(), role);
|
||||
roles.insert(role_id.clone(), role);
|
||||
}
|
||||
} else {
|
||||
info!(self.log, "Did not find role {} while trying to tally", roleID);
|
||||
info!(self.log, "Did not find role {} while trying to tally", role_id);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn _get_role<'txn, T: Transaction>(&self, txn: &'txn T, roleID: &RoleIdentifier) -> Result<Option<Role>> {
|
||||
let string = format!("{}", roleID);
|
||||
pub fn _get_role<'txn, T: Transaction>(&self, txn: &'txn T, role_id: &RoleIdentifier) -> Result<Option<Role>> {
|
||||
let string = format!("{}", role_id);
|
||||
match txn.get(self.roledb, &string.as_bytes()) {
|
||||
Ok(bytes) => {
|
||||
Ok(Some(flexbuffers::from_slice(bytes)?))
|
||||
@ -91,9 +86,9 @@ impl Internal {
|
||||
}
|
||||
}
|
||||
|
||||
fn put_role(&self, txn: &mut RwTransaction, roleID: &RoleIdentifier, role: Role) -> Result<()> {
|
||||
fn put_role(&self, txn: &mut RwTransaction, role_id: &RoleIdentifier, role: Role) -> Result<()> {
|
||||
let bytes = flexbuffers::to_vec(role)?;
|
||||
let string = format!("{}", roleID);
|
||||
let string = format!("{}", role_id);
|
||||
txn.put(self.roledb, &string.as_bytes(), &bytes, lmdb::WriteFlags::empty())?;
|
||||
|
||||
Ok(())
|
||||
@ -154,14 +149,14 @@ impl RoleDB for Internal {
|
||||
self._check(&txn, user, &perm)
|
||||
}
|
||||
|
||||
fn get_role(&self, roleID: &RoleIdentifier) -> Result<Option<Role>> {
|
||||
fn get_role(&self, role_id: &RoleIdentifier) -> Result<Option<Role>> {
|
||||
let txn = self.env.begin_ro_txn()?;
|
||||
self._get_role(&txn, roleID)
|
||||
self._get_role(&txn, role_id)
|
||||
}
|
||||
|
||||
fn tally_role(&self, roles: &mut HashMap<RoleIdentifier, Role>, roleID: &RoleIdentifier) -> Result<()> {
|
||||
fn tally_role(&self, roles: &mut HashMap<RoleIdentifier, Role>, role_id: &RoleIdentifier) -> Result<()> {
|
||||
let txn = self.env.begin_ro_txn()?;
|
||||
self._tally_role(&txn, roles, roleID)
|
||||
self._tally_role(&txn, roles, role_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,34 +1,14 @@
|
||||
use std::str::FromStr;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use std::sync::Arc;
|
||||
use smol::lock::RwLock;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::config::Settings;
|
||||
use crate::db::access;
|
||||
|
||||
use capnp::Error;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use lmdb::{Transaction, RwTransaction, Cursor};
|
||||
|
||||
use smol::channel::{Receiver, Sender};
|
||||
|
||||
use futures::{Future, Stream, StreamExt};
|
||||
use futures_signals::signal::*;
|
||||
|
||||
use crate::machine::MachineDescription;
|
||||
|
||||
use crate::db::user::UserId;
|
||||
|
||||
pub mod internal;
|
||||
|
@ -1,21 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::str::FromStr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use slog::Logger;
|
||||
use uuid::Uuid;
|
||||
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor};
|
||||
|
||||
use futures::{Future, Stream, StreamExt};
|
||||
use futures::stream;
|
||||
use futures::future::Ready;
|
||||
use futures::stream::Iter;
|
||||
|
||||
use super::{MachineIdentifier, MachineState};
|
||||
use crate::machine::MachineDescription;
|
||||
use crate::error::Result;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use argon2;
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor};
|
||||
use rand::prelude::*;
|
||||
use lmdb::{Environment, Transaction, RwTransaction};
|
||||
use slog::Logger;
|
||||
|
||||
use crate::error::Result;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use slog::Logger;
|
||||
use lmdb::{Environment, Transaction, RwTransaction, Cursor};
|
||||
use lmdb::{Environment, Cursor, Transaction, RwTransaction};
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
|
@ -3,17 +3,14 @@ use std::task::{Poll, Context};
|
||||
use std::future::Future;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use smol::{Task, Timer};
|
||||
use smol::Timer;
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
use paho_mqtt::AsyncClient;
|
||||
|
||||
use futures::FutureExt;
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
use genawaiter::{sync::{Gen, GenBoxed, Co}, GeneratorState};
|
||||
|
||||
use futures_signals::signal::{Signal, Mutable, MutableSignalCloned};
|
||||
use crate::machine::{Machine, ReturnToken};
|
||||
use crate::db::machine::MachineState;
|
||||
|
@ -1,7 +1,6 @@
|
||||
use slog::{Drain, Logger};
|
||||
use slog_async;
|
||||
use slog_term::{TermDecorator, FullFormat};
|
||||
use crate::config::Settings;
|
||||
|
||||
pub fn init() -> Logger {
|
||||
let decorator = TermDecorator::new().build();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ops::Deref;
|
||||
use std::iter::FromIterator;
|
||||
use std::sync::Arc;
|
||||
use futures_util::lock::Mutex;
|
||||
@ -18,12 +18,10 @@ use futures_signals::signal::Signal;
|
||||
use futures_signals::signal::SignalExt;
|
||||
use futures_signals::signal::{Mutable, ReadOnlyMutable};
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::error::{Result, Error};
|
||||
|
||||
use crate::db::access;
|
||||
use crate::db::machine::{MachineIdentifier, Status, MachineState};
|
||||
use crate::db::machine::{MachineIdentifier, MachineState};
|
||||
use crate::db::user::{User, UserData};
|
||||
|
||||
use crate::network::MachineMap;
|
||||
|
@ -24,12 +24,6 @@ mod initiator;
|
||||
|
||||
use clap::{App, Arg};
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::executor::{LocalPool, ThreadPool};
|
||||
use futures::compat::Stream01CompatExt;
|
||||
use futures::join;
|
||||
use futures::task::LocalSpawn;
|
||||
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
@ -37,9 +31,6 @@ use std::str::FromStr;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use lmdb::Transaction;
|
||||
use smol::net::TcpListener;
|
||||
|
||||
use smol::Executor;
|
||||
|
||||
use error::Error;
|
||||
|
@ -5,13 +5,5 @@
|
||||
//! Additionally, FFI modules to other languages (Python/Lua/...) make the most sense in here as
|
||||
//! well.
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
mod shelly;
|
||||
pub use shelly::Shelly;
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::task::Spawn;
|
||||
|
||||
use crate::config::Settings;
|
||||
use crate::error::Result;
|
||||
|
@ -1,17 +1,9 @@
|
||||
use slog::Logger;
|
||||
|
||||
use crate::config::Settings;
|
||||
use crate::error::Result;
|
||||
use crate::db::machine::Status;
|
||||
|
||||
use std::pin::Pin;
|
||||
use futures::prelude::*;
|
||||
use futures::channel::mpsc;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::ready;
|
||||
use futures::task::{Poll, Context, Waker, Spawn, FutureObj};
|
||||
use futures::StreamExt;
|
||||
use futures_signals::signal::Signal;
|
||||
|
||||
use crate::actor::Actuator;
|
||||
use crate::db::machine::MachineState;
|
||||
|
@ -1,17 +1,13 @@
|
||||
use std::fmt;
|
||||
|
||||
use std::sync::{Arc, Mutex, MutexGuard, TryLockResult};
|
||||
use std::sync::Mutex;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use smol::Executor;
|
||||
|
||||
use futures::channel::mpsc;
|
||||
use futures_signals::signal::{Signal, MutableSignalCloned, Mutable};
|
||||
use futures_signals::signal::Mutable;
|
||||
|
||||
use crate::machine::Machine;
|
||||
use crate::actor::{Actor, ActorSignal};
|
||||
use crate::initiator::Initiator;
|
||||
use crate::db::machine::MachineState;
|
||||
use crate::actor::ActorSignal;
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
|
@ -9,18 +9,9 @@ use smol::net::TcpListener;
|
||||
use smol::net::unix::UnixStream;
|
||||
use smol::LocalExecutor;
|
||||
|
||||
use clap::{App, Arg};
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::executor::{LocalPool, ThreadPool};
|
||||
use futures::compat::Stream01CompatExt;
|
||||
use futures::join;
|
||||
use futures::task::LocalSpawn;
|
||||
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user