Add copyright comments

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/13/head
trivernis 4 years ago
parent 21995588dc
commit 7f4e89caf2
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Run audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

@ -13,16 +13,13 @@ jobs:
- name: Copy Repo Files
uses: actions/checkout@master
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
@ -36,8 +33,7 @@ jobs:
username: ${{ secrets.PORTUS_USERNAME }}
password: ${{ secrets.PORTUS_PASSWORD }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .

@ -15,20 +15,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache build data
uses: actions/cache@v2
with:
path: |
target
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v2
- name: Cache build data
uses: actions/cache@v2
with:
path: |
target
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

@ -12,10 +12,10 @@ msgrpc = "0.1.0"
postgres = "0.17.5"
serde_postgres = "0.2.0"
dotenv = "0.15.0"
serde = {version = "1.0.115", features = ["serde_derive"]}
serde = { version = "1.0.115", features = ["serde_derive"] }
rand = "0.7.3"
bcrypt = "0.8.2"
zeroize = {version = "1.1.0", features = ["zeroize_derive"]}
zeroize = { version = "1.1.0", features = ["zeroize_derive"] }
byteorder = "1.3.4"
rmp-serde = "0.14.4"
rmp = "0.8.9"

@ -1,3 +1,12 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use dotenv;
use postgres::NoTls;
use r2d2::Pool;
use r2d2_postgres::PostgresConnectionManager;
use crate::database::models::CreatePermissionsEntry;
use crate::database::permissions::{Permissions, DEFAULT_PERMISSIONS};
use crate::database::role_permissions::RolePermissions;
@ -5,10 +14,6 @@ use crate::database::roles::Roles;
use crate::database::user_roles::UserRoles;
use crate::database::users::Users;
use crate::utils::error::DatabaseResult;
use dotenv;
use postgres::NoTls;
use r2d2::Pool;
use r2d2_postgres::PostgresConnectionManager;
pub mod models;
pub mod permissions;

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use postgres::Row;
use serde::{Deserialize, Serialize};
use zeroize::Zeroize;

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use crate::database::models::{CreatePermissionsEntry, Permission};
use crate::database::{DatabaseResult, PostgresPool, Table, ADMIN_ROLE_NAME};

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use crate::database::models::Permission;
use crate::database::{DatabaseResult, PostgresPool, Table};
use crate::utils::error::DBError;
@ -34,7 +38,7 @@ impl RolePermissions {
pub fn by_role(&self, role_id: i32) -> DatabaseResult<Vec<Permission>> {
let mut connection = self.pool.get()?;
let rows = connection.query(
"SELECT * FROM role_permissions, permissions WHERE role_id = $1 AND role_permissions.permission_id = permissions.id",
"SELECT * FROM role_permissions, permissions WHERE role_id = $1 AND role_permissions.permission_id = permissions.id",
&[&role_id])?;
serde_postgres::from_rows(&rows).map_err(DBError::from)

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use crate::database::models::Role;
use crate::database::role_permissions::RolePermissions;
use crate::database::{DatabaseResult, PostgresPool, Table, DEFAULT_ADMIN_EMAIL, ENV_ADMIN_EMAIL};

@ -1,10 +1,16 @@
use crate::utils::{create_user_token, get_user_id_from_token, TOKEN_LENGTH};
use serde::Serialize;
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::cmp::{max, min};
use std::collections::HashMap;
use std::time::Instant;
use serde::Serialize;
use zeroize::Zeroize;
use crate::utils::{create_user_token, get_user_id_from_token, TOKEN_LENGTH};
const REQUEST_TOKEN_EXPIRE_SECONDS: u32 = 60 * 10;
const REFRESH_TOKEN_EXPIRE_SECONDS: u32 = 60 * 60 * 24;

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use crate::database::models::Role;
use crate::database::{DatabaseResult, PostgresPool, Table};
use crate::utils::error::DBError;

@ -1,3 +1,12 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::sync::Arc;
use parking_lot::Mutex;
use zeroize::{Zeroize, Zeroizing};
use crate::database::models::UserRecord;
use crate::database::tokens::{SessionTokens, TokenStore};
use crate::database::user_roles::UserRoles;
@ -5,10 +14,6 @@ use crate::database::{DatabaseResult, PostgresPool, Table};
use crate::utils::error::DBError;
use crate::utils::{create_salt, hash_password};
use parking_lot::Mutex;
use std::sync::Arc;
use zeroize::{Zeroize, Zeroizing};
/// Table that stores users with their email addresses and hashed passwords
#[derive(Clone)]
pub struct Users {

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
#[macro_use]
extern crate rouille;

@ -1,13 +1,19 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::thread;
use std::thread::Builder;
use chrono::Local;
use colored::Colorize;
use crossbeam_utils::sync::WaitGroup;
use env_logger::Env;
use log::Level;
use flotte_user_management::database::Database;
use flotte_user_management::server::http_server::UserHttpServer;
use flotte_user_management::server::user_rpc::UserRpcServer;
use log::Level;
use std::thread;
use std::thread::Builder;
fn main() {
init_logger();

@ -1,3 +1,16 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::error::Error;
use std::fmt::{self, Display};
use std::io::Read;
use regex::Regex;
use rouille::{Request, Response, Server};
use serde::export::Formatter;
use serde::Serialize;
use crate::database::permissions::{CREATE_ROLE_PERMISSION, VIEW_ROLE_PERMISSION};
use crate::database::Database;
use crate::server::messages::{
@ -5,13 +18,6 @@ use crate::server::messages::{
};
use crate::utils::error::DBError;
use crate::utils::get_user_id_from_token;
use regex::Regex;
use rouille::{Request, Response, Server};
use serde::export::Formatter;
use serde::Serialize;
use std::error::Error;
use std::fmt::{self, Display};
use std::io::Read;
macro_rules! require_permission {
($database:expr,$request:expr,$permission:expr) => {
@ -43,6 +49,7 @@ impl Display for HTTPError {
write!(f, "{}", self.message)
}
}
impl Error for HTTPError {}
impl From<DBError> for HTTPError {

@ -1,12 +1,18 @@
use crate::database::models::{CreatePermissionsEntry, Permission};
use crate::utils::error::DBError;
use serde::export::Formatter;
use serde::{Deserialize, Serialize};
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::error::Error;
use std::fmt;
use std::fmt::Display;
use serde::export::Formatter;
use serde::{Deserialize, Serialize};
use zeroize::Zeroize;
use crate::database::models::{CreatePermissionsEntry, Permission};
use crate::utils::error::DBError;
#[derive(Deserialize)]
pub struct TokenRequest {
pub token: String,
@ -28,6 +34,7 @@ impl Display for ErrorMessage {
write!(f, "{}", self.message)
}
}
impl Error for ErrorMessage {}
impl From<DBError> for ErrorMessage {

@ -1,3 +1,7 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
pub mod http_server;
pub mod messages;
pub mod rpc_methods;

@ -1,4 +1,9 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
#![allow(dead_code)]
pub(crate) const NULL: [u8; 4] = [0x00, 0x00, 0x00, 0x00];
pub(crate) const ERROR: [u8; 4] = [0x0F, 0x0F, 0x0F, 0x0F];
pub(crate) const INFO: [u8; 4] = [0x49, 0x4e, 0x46, 0x4f];

@ -1,18 +1,25 @@
use super::rpc_methods::*;
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::collections::HashMap;
use std::sync::Arc;
use std::thread::Builder;
use msgrpc::message::Message;
use msgrpc::server::RpcServer;
use rmp_serde::Deserializer;
use scheduled_thread_pool::ScheduledThreadPool;
use serde::Deserialize;
use crate::database::Database;
use crate::server::messages::{
CreatePermissionsRequest, CreateRoleRequest, ErrorMessage, GetPermissionsRequest, InfoEntry,
TokenRequest,
};
use crate::utils::get_user_id_from_token;
use msgrpc::message::Message;
use msgrpc::server::RpcServer;
use rmp_serde::Deserializer;
use scheduled_thread_pool::ScheduledThreadPool;
use serde::Deserialize;
use std::collections::HashMap;
use std::sync::Arc;
use std::thread::Builder;
use super::rpc_methods::*;
const RPC_SERVER_ADDRESS: &str = "RPC_SERVER_ADDRESS";
const DEFAULT_SERVER_ADDRESS: &str = "127.0.0.1:5555";

@ -1,8 +1,13 @@
use r2d2::Error;
use serde_postgres::DeError;
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::error;
use std::fmt::{self, Display, Formatter};
use r2d2::Error;
use serde_postgres::DeError;
#[derive(Debug)]
pub enum DBError {
Postgres(PostgresError),

@ -1,7 +1,12 @@
// flotte-user-management server for managing users, roles and permissions
// Copyright (C) 2020 trivernis
// See LICENSE for more information
use std::panic;
use bcrypt::DEFAULT_COST;
use byteorder::{BigEndian, ByteOrder};
use rand::Rng;
use std::panic;
pub mod error;

Loading…
Cancel
Save