- Quick start — run locally
- Docker — build and run
- CI tip
- Environment variables reference
- Behavior & notes
- Troubleshooting
- Testing
This document walks through the common commands for running and building Goberus locally.
-
Prerequisites
- Go 1.21+
- Network access to your Active Directory on LDAPS (TCP 636)
-
Set environment variables (example)
export BIND_ADDR="8080"
export LDAP_ADDR="ad.example.local:636" # host:port for LDAPS
export LDAP_BASE_DN="DC=example,DC=local"
export LDAP_BIND_DN="CN=svc-goberus,OU=svc,DC=example,DC=local"
export LDAP_BIND_PASSWORD="supersecret"
export LDAP_SKIP_VERIFY="false" # set true only for dev testing
# Or better: provide CA cert that signed the AD server cert:
# export LDAP_CA_CERT="/path/to/ca.pem"- Build and run
go mod tidy
# Option 1: Run directly
go run ./cmd/goberus
# Option 2: Build then run
go build -o goberus ./cmd/goberus
./goberus- Query the service
# Health endpoints
curl http://localhost:8080/livez # Liveness check (always returns 200)
curl http://localhost:8080/readyz # Readiness check (verifies LDAP connectivity)
# Business endpoints
curl 'http://localhost:8080/v1/member?username=jdoe' | jq .
# or with UPN:
curl 'http://localhost:8080/v1/member?username=jdoe@example.local' | jq .
curl --header "Content-Type: application/json" \
--request POST \
--data '{"username":"testuser","password":"S3cureP@ss"}' \
http://localhost:8080/v1/member | jq .
# Test request ID correlation (server echoes back X-Request-ID)
curl -H "X-Request-ID: my-test-id-123" http://localhost:8080/livez -vThe Dockerfile uses a multi-stage build to produce a minimal runtime image.
Build:
docker build -t lugatuic/goberus:latest .Run (example):
docker run --rm -p 8080:8080 \
-e BIND_ADDR=":8080" \
-e LDAP_ADDR="ad.example.local:636" \
-e LDAP_BASE_DN="DC=example,DC=local" \
-e LDAP_BIND_DN="CN=svc-goberus,OU=svc,DC=example,DC=local" \
-e LDAP_BIND_PASSWORD="supersecret" \
-e LDAP_SKIP_VERIFY="false" \
lugatuic/goberus:latestTo provide a CA certificate file inside the container, mount it and set LDAP_CA_CERT:
docker run --rm -p 8080:8080 \
-v /local/path/ca.pem:/etc/ssl/certs/goberus-ca.pem:ro \
-e LDAP_CA_CERT="/etc/ssl/certs/goberus-ca.pem" \
... lugatuic/goberus:latestIf you store your CA PEM in a GitHub Actions secret (recommended for private/internal CAs), write it to ad_chain.pem during the workflow and build the image. The Dockerfile copies that file to /etc/ssl/certs/goberus-ca.pem and sets LDAP_CA_CERT.
Example step:
- name: Build image (write CA from secret)
run: |
echo "$GOBERUS_CA_PEM" > ad_chain.pem
docker build --build-arg TARGETARCH=amd64 --build-arg TARGETOS=linux -t lugatuic/goberus:latest .
env:
GOBERUS_CA_PEM: ${{ secrets.GOBERUS_CA_PEM }}Notes
- Do NOT commit
ad_chain.pemto the repository — it is ignored by.gitignore.- The workflow writes the secret only during the run and uses it to build the image, keeping sensitive data out of the repo.
- If you prefer not to bake the CA into the image, mount it at runtime instead (see previous section).
BIND_ADDR— HTTP listen address (default:8080)LDAP_ADDR— LDAPS address, host:port (required)LDAP_BASE_DN— base DN for searches (required)LDAP_BIND_DN— optional service DN used for searches/modify (recommended)LDAP_BIND_PASSWORD— password forLDAP_BIND_DNLDAP_SKIP_VERIFY— set totrueto skip TLS verification (development only)LDAP_CA_CERT— path to a CA PEM file used to verify the LDAPS server cert
- Authentication: the current implementation prefers bind-as-user for authentication; only the read/search endpoint (
/v1/member) and the POST/v1/memberuser creation endpoint are exposed. - Active Directory password operations run over LDAPS using AD's
unicodePwdbehavior when creating users (ldaps.AddUsernow callssetUnicodePwdandenableAccount). - TLS: do not use
LDAP_SKIP_VERIFY=truein production. Provide a CA viaLDAP_CA_CERTor trust a CA that already exists in the container.
x509: certificate signed by unknown authority: provideLDAP_CA_CERTor ensure the CA is trusted.Bind failed: ensureLDAP_BIND_DNis a full DN and the password is correct; validate withldapsearchif necessary.- No entries found: verify
LDAP_BASE_DNand try searching by different username formats (sAMAccountName, UPN).
go test ./tests/server -run TestHandleGetMembergo test ./tests/server -run TestHandleCreateMembergo test ./tests/server -run TestSanitizeUserIntegrationgo test ./...