mirror of
https://github.com/ViViDboarder/bitwarden_rs_ldap.git
synced 2024-11-24 04:06:26 +00:00
Update compose to mostly work
Untested since latest bitwarden_rs image doesn't have new endpoints
This commit is contained in:
parent
d373a99211
commit
8171464c49
15
Dockerfile
15
Dockerfile
@ -1,8 +1,19 @@
|
||||
FROM rust:1.33
|
||||
|
||||
WORKDIR /usr/src/myapp
|
||||
COPY . .
|
||||
WORKDIR /usr/src/
|
||||
RUN USER=root cargo new --bin bitwarden_rs_ldap
|
||||
WORKDIR /usr/src/bitwarden_rs_ldap
|
||||
|
||||
# Compile dependencies
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
COPY ./Cargo.lock ./Cargo.lock
|
||||
RUN cargo build --release
|
||||
# Remove temp src
|
||||
RUN rm src/*.rs
|
||||
|
||||
# Copy source and install
|
||||
COPY ./src ./src
|
||||
RUN rm ./target/release/deps/bitwarden_rs_ldap*
|
||||
RUN cargo install --path .
|
||||
|
||||
CMD ["bitwarden_rs_ldap"]
|
||||
|
@ -1,29 +0,0 @@
|
||||
version: '3'
|
||||
services:
|
||||
ldap:
|
||||
image: osixia/openldap
|
||||
ports:
|
||||
- 389:389
|
||||
- 636:636
|
||||
volumes:
|
||||
- /var/lib/ldap
|
||||
- /etc/ldap/slapd.d
|
||||
environment:
|
||||
LDAP_READONLY_USER: 'true'
|
||||
LDAP_READONLY_USER_USERNAME: readonly
|
||||
LDAP_READONLY_USER_PASSWORD: readonly
|
||||
admin:
|
||||
image: osixia/phpldapadmin
|
||||
ports:
|
||||
- 8001:80
|
||||
environment:
|
||||
PHPLDAPADMIN_HTTPS: 'false'
|
||||
PHPLDAPADMIN_LDAP_HOSTS: ldap
|
||||
admin-host:
|
||||
image: osixia/phpldapadmin
|
||||
ports:
|
||||
- 80:80
|
||||
network_mode: "host"
|
||||
environment:
|
||||
PHPLDAPADMIN_HTTPS: 'false'
|
||||
PHPLDAPADMIN_LDAP_HOSTS: 0.0.0.0
|
@ -2,9 +2,16 @@ version: '3'
|
||||
services:
|
||||
ldap_sync:
|
||||
build: .
|
||||
volumes:
|
||||
- ./example.config.toml:/usr/src/bitwarden_rs_ldap/config.toml:ro
|
||||
restart: always
|
||||
|
||||
bitwarden:
|
||||
image: mprasil/bitwarden_rs
|
||||
image: mprasil/bitwarden
|
||||
ports:
|
||||
- 8000:80
|
||||
environment:
|
||||
ADMIN_TOKEN: admin
|
||||
|
||||
ldap:
|
||||
image: osixia/openldap
|
||||
|
8
example.config.toml
Normal file
8
example.config.toml
Normal file
@ -0,0 +1,8 @@
|
||||
bitwarden_url = "http://bitwarden:80"
|
||||
bitwarden_admin_token = "admin"
|
||||
ldap_host = "ldap"
|
||||
ldap_bind_dn = "cn=admin,dc=example,dc=org"
|
||||
ldap_bind_password = "admin"
|
||||
ldap_search_base_dn = "dc=example,dc=org"
|
||||
ldap_search_filter = "(&(objectClass=*)(uid=*))"
|
||||
ldap_sync_interval_seconds = 10
|
14
src/main.rs
14
src/main.rs
@ -28,8 +28,6 @@ fn invite_users(
|
||||
client: &mut bw_admin::Client,
|
||||
start_loop: bool,
|
||||
) -> Result<(), Box<Error>> {
|
||||
// TODO: Better error handling to differentiate failure to connect to Bitwarden vs LDAP
|
||||
|
||||
if start_loop {
|
||||
start_sync_loop(config, client)?;
|
||||
} else {
|
||||
@ -74,7 +72,7 @@ fn search_entries(config: &config::Config) -> Result<Vec<SearchEntry>, Box<Error
|
||||
);
|
||||
|
||||
if ldap.is_err() {
|
||||
println!("Error: Could not connect to ldap server");
|
||||
println!("Error: Could not bind to ldap server");
|
||||
}
|
||||
|
||||
let mail_field = config.get_ldap_mail_field();
|
||||
@ -105,8 +103,8 @@ fn invite_from_ldap(
|
||||
config: &config::Config,
|
||||
client: &mut bw_admin::Client,
|
||||
) -> Result<(), Box<Error>> {
|
||||
let existing_users = get_existing_users(client)?;
|
||||
|
||||
match get_existing_users(client) {
|
||||
Ok(existing_users) => {
|
||||
let mail_field = config.get_ldap_mail_field();
|
||||
let mut num_users = 0;
|
||||
for ldap_user in search_entries(config)? {
|
||||
@ -124,6 +122,12 @@ fn invite_from_ldap(
|
||||
|
||||
// Maybe think about returning this value for some other use
|
||||
println!("Sent invites to {} user(s).", num_users);
|
||||
},
|
||||
Err(e) => {
|
||||
println!("Error: Failed to get existing users from Bitwarden");
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user