Move backend source to server/ subpackage

To clarify the organization.
This commit is contained in:
Valentin Tolmer 2021-08-31 16:46:31 +02:00 committed by nitnelave
parent 3eb53ba5bf
commit d8df47b35d
30 changed files with 93 additions and 88 deletions

View File

@ -3,6 +3,7 @@
# Don't track cargo generated files
target/*
server/target/*
app/target/*
auth/target/*

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/target
/serve/target/
/app/target
/app/pkg
/auth/target

View File

@ -1,78 +1,6 @@
[workspace]
members = [".", "auth", "app"]
[package]
authors = ["Valentin Tolmer <valentin@tolmer.fr>", "Steve Barrau <steve.barrau@gmail.com>", "Thomas Wickham <mackwic@gmail.com>"]
edition = "2018"
name = "lldap"
version = "0.1.0"
[dependencies]
actix = "0.12"
actix-files = "0.6.0-beta.6"
actix-http = "3.0.0-beta.9"
actix-rt = "2.2.0"
actix-server = "2.0.0-beta.5"
actix-service = "2.0.0"
actix-web = "4.0.0-beta.8"
actix-web-httpauth = "0.6.0-beta.2"
anyhow = "*"
async-trait = "0.1"
base64 = "0.13"
bincode = "1.3"
chrono = { version = "*", features = [ "serde" ]}
clap = "3.0.0-beta.2"
cron = "*"
derive_builder = "0.10.2"
futures = "*"
futures-util = "*"
hmac = "0.10"
http = "*"
jwt = "0.13"
ldap3_server = "*"
lldap_auth = { path = "auth" }
log = "*"
orion = "0.16"
serde = "*"
serde_json = "1"
sha2 = "0.9"
sqlx-core = "=0.5.1"
thiserror = "*"
time = "0.2"
tokio = { version = "1.2.0", features = ["full"] }
tokio-util = "0.6.3"
tracing = "*"
tracing-actix-web = "0.4.0-beta.7"
tracing-log = "*"
tracing-subscriber = "*"
rand = { version = "0.8", features = ["small_rng", "getrandom"] }
juniper_actix = "0.4.0"
juniper = "0.15.6"
# TODO: update to 0.6 when out.
[dependencies.opaque-ke]
git = "https://github.com/novifinancial/opaque-ke"
rev = "eb59676a940b15f77871aefe1e46d7b5bf85f40a"
[dependencies.sqlx]
version = "0.5.1"
features = [
"any",
"chrono",
"macros",
"mysql",
"postgres",
"runtime-actix-native-tls",
"sqlite",
members = [
"server",
"auth",
"app"
]
[dependencies.sea-query]
version = "0.9.4"
features = ["with-chrono"]
[dependencies.figment]
features = ["env", "toml"]
version = "*"
[dev-dependencies]
mockall = "0.9.1"

View File

@ -12,7 +12,7 @@ RUN set -x \
app
RUN set -x \
# Install required packages
&& apk add npm openssl-dev musl-dev
&& apk add npm openssl-dev musl-dev make perl
USER app
WORKDIR /app
RUN set -x \
@ -21,7 +21,7 @@ RUN set -x \
&& npm install rollup
# Build
COPY --chown=app:app . /app
RUN cargo build --release
RUN cargo build --release -p lldap
# TODO: release mode.
RUN ./app/build.sh

View File

@ -28,7 +28,8 @@ Backend:
* Only a small, read-only subset of the LDAP protocol is supported.
* Listens on another port for HTTP traffic.
* The authentication API, based on JWTs, is under "/auth".
* The user management API is under "/api" (POST requests only).
* The user management API is a GraphQL API under "/api/graphql". The schema
is defined in `schema.graphql`.
* The static frontend files are served by this port too.
Note that secure protocols (LDAPS, HTTPS) are currently not supported. This can
@ -53,9 +54,9 @@ Data storage:
interface between front and back-end. In particular, it contains the OPAQUE
structures and the JWT format.
* `app/`: The frontend.
* `src/`: The backend.
* `domain/`: Domain-specific logic: users, groups, checking passwords...
* `infra/`: API, both GraphQL and LDAP
* `server/`: The backend.
* `src/domain/`: Domain-specific logic: users, groups, checking passwords...
* `src/infra/`: API, both GraphQL and LDAP
## Authentication
@ -98,8 +99,7 @@ Contributions are welcome! Just fork and open a PR. Or just file a bug.
We don't have a code of conduct, just be respectful and remember that it's just
normal people doing this for free on their free time.
Make sure that you run `cargo fmt` in each crate that you modified (top-level,
`app/` and `auth/`) before creating the PR.
Make sure that you run `cargo fmt` from the root before creating the PR.
### Setup

75
server/Cargo.toml Normal file
View File

@ -0,0 +1,75 @@
[package]
authors = ["Valentin Tolmer <valentin@tolmer.fr>", "Steve Barrau <steve.barrau@gmail.com>", "Thomas Wickham <mackwic@gmail.com>"]
edition = "2018"
name = "lldap"
version = "0.1.0"
[dependencies]
actix = "0.12"
actix-files = "0.6.0-beta.6"
actix-http = "3.0.0-beta.9"
actix-rt = "2.2.0"
actix-server = "2.0.0-beta.5"
actix-service = "2.0.0"
actix-web = "4.0.0-beta.8"
actix-web-httpauth = "0.6.0-beta.2"
anyhow = "*"
async-trait = "0.1"
base64 = "0.13"
bincode = "1.3"
chrono = { version = "*", features = [ "serde" ]}
clap = "3.0.0-beta.2"
cron = "*"
derive_builder = "0.10.2"
futures = "*"
futures-util = "*"
hmac = "0.10"
http = "*"
jwt = "0.13"
ldap3_server = "*"
lldap_auth = { path = "../auth" }
log = "*"
orion = "0.16"
serde = "*"
serde_json = "1"
sha2 = "0.9"
sqlx-core = "=0.5.1"
thiserror = "*"
time = "0.2"
tokio = { version = "1.2.0", features = ["full"] }
tokio-util = "0.6.3"
tracing = "*"
tracing-actix-web = "0.4.0-beta.7"
tracing-log = "*"
tracing-subscriber = "*"
rand = { version = "0.8", features = ["small_rng", "getrandom"] }
juniper_actix = "0.4.0"
juniper = "0.15.6"
# TODO: update to 0.6 when out.
[dependencies.opaque-ke]
git = "https://github.com/novifinancial/opaque-ke"
rev = "eb59676a940b15f77871aefe1e46d7b5bf85f40a"
[dependencies.sqlx]
version = "0.5.1"
features = [
"any",
"chrono",
"macros",
"mysql",
"postgres",
"runtime-actix-native-tls",
"sqlite",
]
[dependencies.sea-query]
version = "0.9.4"
features = ["with-chrono"]
[dependencies.figment]
features = ["env", "toml"]
version = "*"
[dev-dependencies]
mockall = "0.9.1"

View File

@ -20,7 +20,7 @@ use std::sync::RwLock;
async fn index(req: HttpRequest) -> actix_web::Result<NamedFile> {
let mut path = PathBuf::new();
path.push("app");
path.push("../app");
let file = req.match_info().query("filename");
path.push(if file.is_empty() { "index.html" } else { file });
Ok(NamedFile::open(path)?)
@ -120,7 +120,7 @@ mod tests {
async fn test_index_ok() {
let req = TestRequest::default().to_http_request();
let resp = index(req).await.unwrap();
assert_eq!(resp.path(), Path::new("app/index.html"));
assert_eq!(resp.path(), Path::new("../app/index.html"));
}
#[actix_rt::test]
@ -129,6 +129,6 @@ mod tests {
.param("filename", "main.js")
.to_http_request();
let resp = index(req).await.unwrap();
assert_eq!(resp.path(), Path::new("app/main.js"));
assert_eq!(resp.path(), Path::new("../app/main.js"));
}
}