Crates.io | password-as-service |
lib.rs | password-as-service |
version | 0.1.4 |
source | src |
created_at | 2019-05-07 21:58:19.962016 |
updated_at | 2019-05-10 19:48:43.317633 |
description | a very poorly considered http/rest service |
homepage | |
repository | https://gitlab.com/efronlicht/passwd-as-service |
max_upload_size | |
id | 132701 |
size | 9,490,587 |
Passwd-as-service is a webservice that provides a query API into the /etc/passwd
and /etc/group
files. It's not meant to be a 'real' service; it's a didactic coding sample meant for potential employers, based off a coding challenge from Brain Corp. See the file api.pdf for details on the exact challenge.
Clone the source and run cargo doc --open
, or visit the docs on docs.rs
rustup install nightly
cargo +nightly install password-as-service
Alternatively, prebuilt binaries for 64-bit OSX, Windows, and Linux Ubuntu/Debianare available in [./bin].
[ROCKET_PORT=PORT] passwd-as-service [PATH_TO_USERS] [PATH_TO_GROUPS]
ROCKET_PORT is the port to serve from. This can also be set as an environment variable.
PATH_TO_USERS is the location of the users file: defaults to "/etc/passwd"
.
PATH_TO_GROUPS is the location of the users file: defaults to "/etc/group"
You must use both of PATH_TO_USERS and PATH_TO_GROUPS, or neither.
Clone the repository
cd ~/rust
git clone gitlab.com/efronlicht/passwd-as-service
Navigate to the project directory
cd ~/rust/passwd-ass-service
Cargo
cargo test
Test Coverage (Ubuntu/Debian)
Install Tarpaulin:
# install the lib-ssl development libraries
apt-get install libssl-dev pkg-config cmake zlib1g-dev
# set cargo to use rust's `nightly` toolchain
rustup default nightly
# OR:
rustup override set nightly
# install tarpaulin
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
Get Coverage
$ cargo tarpaulin
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
[INFO tarpaulin] Launching test
[INFO tarpaulin] running /home/efron/rust/passwd-as-service/target/debug/deps/bin-f54ce995ec16a011
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
[INFO tarpaulin] Launching test
[INFO tarpaulin] running /home/efron/rust/passwd-as-service/target/debug/deps/lib-1087fab0c4512719
running 6 tests
......
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
[INFO tarpaulin] Coverage Results:
|| Tested/Total Lines:
|| src/api/mod.rs: 14/14
|| src/api/tests.rs: 84/86
|| src/lib.rs: 6/20
|| src/main.rs: 0/3
|| src/model/group.rs: 11/18
|| src/model/user.rs: 24/26
||
83.23% coverage, 139/167 lines covered
This is a toy project, dealing with very small amounts of data. Even the largest linux system is unlikely to have more than ten thousand users or groups; we simply don't need a relational database to query this kind of data. We have a single source of truth (the flat files /etc/passwd/
and /etc/group
themselves.
Relational databasses like PostgreSQL and MYSQL are pretty much made for this kind of query.
If the project expands we'll probably need to use a database eventually.
Reinventing the wheel.
Rocket is an extremely exciting framework for writing servers in Rust.
Immature.
Requires nightly rust.
Changes to Rust could leave the Rocket stranded.
Must be recompiled every time, unlike interpreted languages.
Larger than using dynamic links.