git_diff.txt 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. diff --git a/.gitignore b/.gitignore
  2. index 8994b5d..a054b2f 100644
  3. --- a/.gitignore
  4. +++ b/.gitignore
  5. @@ -1,3 +1,4 @@
  6. data/
  7. config/credentials
  8. config/nextcloud/
  9. +scripts/setup/paperless/node_modules
  10. \ No newline at end of file
  11. diff --git a/ansible/roles/services/defaults/main.yml b/ansible/roles/services/defaults/main.yml
  12. index 3555dd9..168ea0f 100644
  13. --- a/ansible/roles/services/defaults/main.yml
  14. +++ b/ansible/roles/services/defaults/main.yml
  15. @@ -20,4 +20,13 @@ sso_config:
  16. nextcloud-youpi: "youpi"
  17. # Default paths and settings
  18. -nextcloud_data_dir: "/var/www/html/data"
  19. \ No newline at end of file
  20. +nextcloud_data_dir: "/var/www/html/data"
  21. +
  22. +# ansible/roles/services/defaults/main.yml
  23. +paperless_oidc:
  24. + client_id: paperless
  25. + provider_url: "https://{{ keycloak_host }}"
  26. + realm: "{{ keycloak_realm }}"
  27. + sign_algo: "RS256"
  28. + verify_ssl: false
  29. + scopes: "openid profile email"
  30. \ No newline at end of file
  31. diff --git a/ansible/roles/services/tasks/main.yml b/ansible/roles/services/tasks/main.yml
  32. index c6f13f1..c64d421 100644
  33. --- a/ansible/roles/services/tasks/main.yml
  34. +++ b/ansible/roles/services/tasks/main.yml
  35. @@ -120,4 +120,15 @@
  36. - name: "Display SSO configuration"
  37. debug:
  38. - var: sso_config_verification.stdout
  39. \ No newline at end of file
  40. + var: sso_config_verification.stdout
  41. +
  42. +# ansible/roles/services/tasks/main.yml
  43. +- name: Configure Paperless
  44. + block:
  45. + - name: Setup Paperless Django settings
  46. + template:
  47. + src: paperless_django_settings.j2
  48. + dest: "{{ paperless_config_dir }}/django/settings.py"
  49. + tags:
  50. + - paperless
  51. + - paperless-config
  52. \ No newline at end of file
  53. diff --git a/ansible/vars/defaults/main.yml b/ansible/vars/defaults/main.yml
  54. index 93934a6..e14a77f 100644
  55. --- a/ansible/vars/defaults/main.yml
  56. +++ b/ansible/vars/defaults/main.yml
  57. @@ -19,3 +19,9 @@ nodered_port: 1880
  58. # Docker-Konfiguration
  59. docker_compose_version: "2.21.0"
  60. +
  61. +# Paperless Variables
  62. +paperless_base_dir: /path/to/your/paperless
  63. +paperless_oidc_client_id: paperless
  64. +keycloak_host: auth.mrx8086.com
  65. +keycloak_realm: office-automation
  66. \ No newline at end of file
  67. diff --git a/config/nginx/sites-available/keycloak b/config/nginx/sites-available/keycloak
  68. index cf437a2..a24450e 100644
  69. --- a/config/nginx/sites-available/keycloak
  70. +++ b/config/nginx/sites-available/keycloak
  71. @@ -1,5 +1,5 @@
  72. upstream keycloak_upstream {
  73. - server 172.18.0.3:8080;
  74. + server 172.19.0.3:8080;
  75. }
  76. server {
  77. diff --git a/config/nginx/sites-available/nextcloud b/config/nginx/sites-available/nextcloud
  78. index 8357df3..3c24334 100644
  79. --- a/config/nginx/sites-available/nextcloud
  80. +++ b/config/nginx/sites-available/nextcloud
  81. @@ -1,5 +1,5 @@
  82. upstream nextcloud_upstream {
  83. - server 172.19.0.3:80; # SICHERSTELLEN, DASS DIES DIE KORREKTE IP IST
  84. + server 172.20.0.3:80; # SICHERSTELLEN, DASS DIES DIE KORREKTE IP IST
  85. }
  86. server {
  87. diff --git a/config/nginx/sites-available/paperless b/config/nginx/sites-available/paperless
  88. index 6a7b80c..41563c5 100644
  89. --- a/config/nginx/sites-available/paperless
  90. +++ b/config/nginx/sites-available/paperless
  91. @@ -1,41 +1,61 @@
  92. -# HTTP-Weiterleitung auf HTTPS
  93. +upstream paperless_upstream {
  94. + server 172.18.0.4:8000; # SICHERSTELLEN, DASS DIES DIE KORREKTE IP UND DER PORT IST
  95. +}
  96. +
  97. server {
  98. listen 80;
  99. server_name docs.mrx8086.com;
  100. -
  101. - # Weiterleitung von HTTP zu HTTPS
  102. return 301 https://$host$request_uri;
  103. }
  104. -# HTTPS-Server
  105. server {
  106. listen 443 ssl;
  107. server_name docs.mrx8086.com;
  108. - # SSL-Zertifikate einbinden
  109. + # SSL Configuration
  110. ssl_certificate /etc/nginx/ssl/mrx8086.com/fullchain.pem;
  111. ssl_certificate_key /etc/nginx/ssl/mrx8086.com/privkey.pem;
  112. - # Empfohlene SSL-Einstellungen (optional)
  113. ssl_protocols TLSv1.2 TLSv1.3;
  114. ssl_prefer_server_ciphers on;
  115. - ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
  116. - ssl_session_cache shared:SSL:10m;
  117. - ssl_session_timeout 10m;
  118. + ssl_ciphers 'TLS-CHACHA20-POLY1305-SHA256:TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305';
  119. + ssl_session_timeout 1d;
  120. + ssl_session_cache shared:MozSSL:10m;
  121. + ssl_session_tickets off;
  122. + # Security headers
  123. + add_header X-Content-Type-Options nosniff always;
  124. + add_header X-XSS-Protection "1; mode=block" always;
  125. + add_header X-Frame-Options SAMEORIGIN always;
  126. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  127. - add_header X-Content-Type-Options nosniff;
  128. - add_header X-Frame-Options DENY;
  129. - add_header X-XSS-Protection "1; mode=block";
  130. + add_header Content-Security-Policy "frame-ancestors 'self'; default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; media-src 'self';" always;
  131. +
  132. + # Proxy settings
  133. + proxy_set_header X-Real-IP $remote_addr;
  134. + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  135. + proxy_set_header X-Forwarded-Proto $scheme;
  136. + proxy_set_header X-Forwarded-Host $host;
  137. + proxy_set_header X-Forwarded-Port 443;
  138. + proxy_set_header Host $host;
  139. + proxy_http_version 1.1;
  140. - # Paperless-NGX Konfiguration
  141. + # Paperless specific settings
  142. + client_max_body_size 512M;
  143. + fastcgi_buffers 64 4K;
  144. +
  145. + # Root location
  146. location / {
  147. - proxy_pass http://127.0.0.1:8000; # Paperless läuft auf Port 8000 innerhalb des Docker-Containers
  148. - proxy_set_header Host $host;
  149. - proxy_set_header X-Real-IP $remote_addr;
  150. - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  151. - proxy_set_header X-Forwarded-Proto https;
  152. - proxy_set_header X-Forwarded-Port 443;
  153. + proxy_pass http://paperless_upstream;
  154. + proxy_set_header Upgrade $http_upgrade;
  155. + proxy_set_header Connection "upgrade";
  156. + proxy_connect_timeout 60s;
  157. + proxy_send_timeout 60s;
  158. + proxy_read_timeout 60s;
  159. }
  160. -}
  161. + # Deny access to hidden files
  162. + location ~ /\. {
  163. + deny all;
  164. + return 404;
  165. + }
  166. +}
  167. \ No newline at end of file
  168. diff --git a/docker/.env b/docker/.env
  169. index 2a7c926..0993b0b 100644
  170. --- a/docker/.env
  171. +++ b/docker/.env
  172. @@ -11,4 +11,49 @@ NEXTCLOUD_DB_USER=nextcloud
  173. NEXTCLOUD_DB_PASSWORD=YeTn4f1IIM9a7I3Q7oZNaEhs
  174. NEXTCLOUD_DB_ROOT_PASSWORD=rY26aXw9uMOqz2BjtevQ4oKB
  175. NEXTCLOUD_ADMIN_USER=admin
  176. -NEXTCLOUD_ADMIN_PASSWORD=jTjRBEJb2ZSAH0iJoqeZijYL
  177. \ No newline at end of file
  178. +NEXTCLOUD_ADMIN_PASSWORD=jTjRBEJb2ZSAH0iJoqeZijYL
  179. +
  180. +
  181. +
  182. +# ==============================================================================
  183. +# Paperless Environment Variables
  184. +# ==============================================================================
  185. +
  186. +# Datenbank-Konfiguration
  187. +# ------------------------------------------------------------------------------
  188. +# Benutzername für die Paperless-Datenbank
  189. +PAPERLESS_DB_USER=paperless
  190. +
  191. +# Passwort für die Paperless-Datenbank
  192. +PAPERLESS_DB_PASSWORD=sq812ylB1Lfk49xbP8xxNSDA
  193. +
  194. +# Datenbank Name
  195. +PAPERLESS_DB_NAME=paperless
  196. +
  197. +# Paperless Admin User
  198. +# ------------------------------------------------------------------------------
  199. +# Benutzername für den Paperless Admin Account
  200. +PAPERLESS_ADMIN_USER=admin
  201. +
  202. +# Passwort für den Paperless Admin Account
  203. +PAPERLESS_ADMIN_PASSWORD=GRnrM1lrMl63E16HgZk8PBXU
  204. +
  205. +# Paperless Secret Key
  206. +# ------------------------------------------------------------------------------
  207. +# Geheimer Schlüssel für Paperless (wird für Django benötigt)
  208. +# Sollte ein zufälliger, sicherer String sein
  209. +PAPERLESS_SECRET_KEY=qfQ7MeGB79F6nbTgFk99K2Nx
  210. +
  211. +# Paperless OpenID Connect (Keycloak) Konfiguration
  212. +# ------------------------------------------------------------------------------
  213. +# Client ID für Paperless in Keycloak
  214. +PAPERLESS_CLIENT_ID=paperless
  215. +
  216. +# Client Secret für Paperless in Keycloak
  217. +PAPERLESS_CLIENT_SECRET=CSbw9ldbZBUGGQSJoAUEg10QKgjdb6Tq
  218. +
  219. +# Die URL von Paperless
  220. +PAPERLESS_URL=https://docs.mrx8086.com
  221. +
  222. +# Erlaubte Hosts für Paperless
  223. +PAPERLESS_ALLOWED_HOSTS=docs.mrx8086.com
  224. \ No newline at end of file
  225. diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
  226. index ccbcd3b..d3bf016 100644
  227. --- a/docker/docker-compose.yml
  228. +++ b/docker/docker-compose.yml
  229. @@ -117,8 +117,102 @@ services:
  230. networks:
  231. - nextcloud-network
  232. + paperless:
  233. + image: ghcr.io/paperless-ngx/paperless-ngx:latest
  234. + container_name: paperless
  235. + restart: unless-stopped
  236. + ports:
  237. + - "8000:8000"
  238. + volumes:
  239. + - ../data/paperless:/usr/src/paperless/data
  240. + - ../config/paperless/media:/usr/src/paperless/media
  241. + - ../config/paperless/export:/usr/src/paperless/export
  242. + - ../config/paperless/consume:/usr/src/paperless/consume
  243. + environment:
  244. + # Basis-Konfiguration
  245. + - PAPERLESS_ADMIN_USER=${PAPERLESS_ADMIN_USER}
  246. + - PAPERLESS_ADMIN_PASSWORD=${PAPERLESS_ADMIN_PASSWORD}
  247. + - PAPERLESS_SECRET_KEY=${PAPERLESS_SECRET_KEY}
  248. + - PAPERLESS_URL=https://docs.mrx8086.com
  249. + - PAPERLESS_ALLOWED_HOSTS=docs.mrx8086.com
  250. + - PAPERLESS_REDIS=redis://paperless-redis:6379
  251. + - PAPERLESS_LOGGING_DIR=/dev/stdout
  252. + - PAPERLESS_LOGGING_LEVEL=DEBUG
  253. + - DJANGO_LOG_LEVEL=DEBUG
  254. +
  255. + # OIDC Basis-Einstellungen
  256. + - PAPERLESS_ENABLE_OIDC=true
  257. + - PAPERLESS_OIDC_RP_PROVIDER_URL=https://auth.mrx8086.com/realms/office-automation
  258. + - PAPERLESS_OIDC_RP_CLIENT_ID=paperless
  259. + - PAPERLESS_OIDC_RP_CLIENT_SECRET=${PAPERLESS_CLIENT_SECRET}
  260. +
  261. + # OIDC Endpoints
  262. + - PAPERLESS_OIDC_AUTH_ENDPOINT=https://auth.mrx8086.com/realms/office-automation/protocol/openid-connect/auth
  263. + - PAPERLESS_OIDC_TOKEN_ENDPOINT=https://auth.mrx8086.com/realms/office-automation/protocol/openid-connect/token
  264. + - PAPERLESS_OIDC_USERINFO_ENDPOINT=https://auth.mrx8086.com/realms/office-automation/protocol/openid-connect/userinfo
  265. + - PAPERLESS_OIDC_JWKS_ENDPOINT=https://auth.mrx8086.com/realms/office-automation/protocol/openid-connect/certs
  266. +
  267. + # OIDC Claims und Scopes
  268. + - PAPERLESS_OIDC_RP_SCOPE=openid profile email
  269. + - PAPERLESS_OIDC_RP_USERNAME_CLAIM=preferred_username
  270. + - PAPERLESS_OIDC_RP_NAME_CLAIM=name
  271. + - PAPERLESS_OIDC_RP_EMAIL_CLAIM=email
  272. +
  273. + # OIDC Sicherheitseinstellungen
  274. + - PAPERLESS_OIDC_RP_SIGN_ALGO=RS256
  275. + - PAPERLESS_OIDC_RP_VERIFY_SSL=false
  276. + - PAPERLESS_OIDC_USE_PKCE=true
  277. +
  278. + # OIDC Token-Management
  279. + - PAPERLESS_OIDC_RP_RENEW_TOKEN_BEFORE_EXPIRY=true
  280. +
  281. + depends_on:
  282. + - paperless-db
  283. + - paperless-redis
  284. + networks:
  285. + - paperless-network
  286. + extra_hosts:
  287. + - "auth.mrx8086.com:172.23.171.133"
  288. + healthcheck:
  289. + test: ["CMD", "curl", "-f", "http://localhost:8000/"]
  290. + interval: 30s
  291. + timeout: 10s
  292. + retries: 3
  293. +
  294. + paperless-db:
  295. + image: postgres:15
  296. + container_name: paperless-db
  297. + restart: unless-stopped
  298. + environment:
  299. + POSTGRES_USER: ${PAPERLESS_DB_USER}
  300. + POSTGRES_PASSWORD: ${PAPERLESS_DB_PASSWORD}
  301. + POSTGRES_DB: paperless
  302. + volumes:
  303. + - ../data/paperless-db:/var/lib/postgresql/data
  304. + networks:
  305. + - paperless-network
  306. + healthcheck:
  307. + test: ["CMD-SHELL", "pg_isready -U ${PAPERLESS_DB_USER} -d paperless"]
  308. + interval: 10s
  309. + timeout: 5s
  310. + retries: 5
  311. +
  312. + paperless-redis:
  313. + image: redis:7
  314. + container_name: paperless-redis
  315. + restart: unless-stopped
  316. + networks:
  317. + - paperless-network
  318. + healthcheck:
  319. + test: ["CMD", "redis-cli", "ping"]
  320. + interval: 10s
  321. + timeout: 5s
  322. + retries: 5
  323. +
  324. networks:
  325. keycloak-network:
  326. driver: bridge
  327. nextcloud-network:
  328. + driver: bridge
  329. + paperless-network:
  330. driver: bridge
  331. \ No newline at end of file
  332. diff --git a/docs/context/configuration/docker-compose.yml b/docs/context/configuration/docker-compose.yml
  333. index 86b29d1..d36b088 100644
  334. --- a/docs/context/configuration/docker-compose.yml
  335. +++ b/docs/context/configuration/docker-compose.yml
  336. @@ -100,8 +100,66 @@ services:
  337. networks:
  338. - nextcloud-network
  339. + paperless:
  340. + image: ghcr.io/paperless-ngx/paperless-ngx:latest
  341. + container_name: paperless
  342. + restart: unless-stopped
  343. + ports:
  344. + - "8000:8000"
  345. + volumes:
  346. + - ../data/paperless:/usr/src/paperless/data
  347. + - ../config/paperless/media:/usr/src/paperless/media
  348. + - ../config/paperless/export:/usr/src/paperless/export
  349. + - ../config/paperless/consume:/usr/src/paperless/consume
  350. + environment:
  351. + - PAPERLESS_ADMIN_USER=${PAPERLESS_ADMIN_USER}
  352. + - PAPERLESS_ADMIN_PASSWORD=${PAPERLESS_ADMIN_PASSWORD}
  353. + - PAPERLESS_SECRET_KEY=${PAPERLESS_SECRET_KEY}
  354. + - PAPERLESS_URL=https://docs.mrx8086.com
  355. + - PAPERLESS_ALLOWED_HOSTS=docs.mrx8086.com
  356. + - PAPERLESS_ENABLE_OIDC=true
  357. + - PAPERLESS_OIDC_RP_CLIENT_ID=${PAPERLESS_CLIENT_ID}
  358. + - PAPERLESS_OIDC_RP_CLIENT_SECRET=${PAPERLESS_CLIENT_SECRET}
  359. + - PAPERLESS_OIDC_RP_PROVIDER_URL=https://auth.mrx8086.com/realms/office-automation
  360. + - PAPERLESS_OIDC_RP_USERNAME_CLAIM=preferred_username
  361. + - PAPERLESS_OIDC_RP_NAME_CLAIM=name
  362. + - PAPERLESS_OIDC_RP_EMAIL_CLAIM=email
  363. + - PAPERLESS_OIDC_RP_RENEW_TOKEN_BEFORE_EXPIRY=true
  364. + - PAPERLESS_OIDC_RP_VERIFY_SSL=false
  365. + depends_on:
  366. + - paperless-db
  367. + networks:
  368. + - paperless-network
  369. + extra_hosts:
  370. + - "auth.mrx8086.com:172.23.171.133"
  371. + healthcheck:
  372. + test: ["CMD", "curl", "-f", "http://localhost:8000/"]
  373. + interval: 30s
  374. + timeout: 10s
  375. + retries: 3
  376. +
  377. + paperless-db:
  378. + image: postgres:15
  379. + container_name: paperless-db
  380. + restart: unless-stopped
  381. + environment:
  382. + POSTGRES_USER: ${PAPERLESS_DB_USER}
  383. + POSTGRES_PASSWORD: ${PAPERLESS_DB_PASSWORD}
  384. + POSTGRES_DB: paperless
  385. + volumes:
  386. + - ../data/paperless-db:/var/lib/postgresql/data
  387. + networks:
  388. + - paperless-network
  389. + healthcheck:
  390. + test: ["CMD-SHELL", "pg_isready -U ${PAPERLESS_DB_USER} -d paperless"]
  391. + interval: 10s
  392. + timeout: 5s
  393. + retries: 5
  394. +
  395. networks:
  396. keycloak-network:
  397. driver: bridge
  398. nextcloud-network:
  399. + driver: bridge
  400. + paperless-network:
  401. driver: bridge
  402. \ No newline at end of file
  403. diff --git a/git_diff.txt b/git_diff.txt
  404. index bfb2d94..2f87fcb 100644
  405. --- a/git_diff.txt
  406. +++ b/git_diff.txt
  407. @@ -1,823 +0,0 @@
  408. -Vielen Dank für die Bereitstellung der Dateien. Ich habe alle notwendigen Informationen, um die Dokumentation zu erstellen. Hier ist der Inhalt der finalen Dokumentationsdateien:
  409. -
  410. -```markdown
  411. -# Automatisiertes Büro 2.0 - Projektdokumentation
  412. -
  413. -## Inhaltsverzeichnis
  414. -1. [Projektübersicht](#projektübersicht)
  415. -2. [Systemarchitektur](#systemarchitektur)
  416. -3. [Entwicklungsumgebung](#entwicklungsumgebung)
  417. -4. [Konfigurationen](#konfigurationen)
  418. -5. [Installationsanleitung](#installationsanleitung)
  419. -6. [Workflows](#workflows)
  420. -7. [Sicherheitskonzept](#sicherheitskonzept)
  421. -8. [Wartung und Monitoring](#wartung-und-monitoring)
  422. -9. [Troubleshooting](#troubleshooting)
  423. -
  424. -## Projektübersicht
  425. -
  426. -### Projektziele
  427. -- Vollständige Automatisierung administrativer und kaufmännischer Prozesse
  428. -- Kostensenkung durch lokale Open-Source-Lösungen
  429. -- Unabhängigkeit von externen Diensten
  430. -- Zentralisierte Verwaltung aller Geschäftsprozesse
  431. -
  432. -### Projektumfang
  433. -- Integration aller Kommunikationskanäle
  434. -- Automatisierte Dokumentenverarbeitung
  435. -- Prozessautomatisierung
  436. -- Zentrale Authentifizierung
  437. -- KI-gestützte Korrespondenz
  438. -
  439. -#### Keycloak-Rolle
  440. -Keycloak spielt eine zentrale Rolle als Authentifizierungsstelle. Es stellt die Single-Sign-On (SSO) Funktionalität für alle Dienste der zentralen Plattform bereit und sichert somit den Zugriff auf die verschiedenen Anwendungen.
  441. -
  442. -## Systemarchitektur
  443. -
  444. -#### Architekturübersicht
  445. -
  446. -```mermaid
  447. -graph TB
  448. - subgraph Eingangssysteme
  449. - Email[E-Mail]
  450. - WhatsApp[WhatsApp]
  451. - Post[Physische Post]
  452. - Teams[Teams/Webex]
  453. - end
  454. -
  455. - subgraph Zentrale_Plattform
  456. - NC[Nextcloud - Dokumentenverwaltung]
  457. - PL[Paperless - Dokumentenmanagement]
  458. - NR[Node-RED - Prozessautomatisierung]
  459. - KC[Keycloak - SSO]
  460. - OUI[OpenWebUI - KI-Korrespondenz]
  461. - KI[Kimai - Zeiterfassung]
  462. - end
  463. -
  464. - subgraph Monitoring_Analytics
  465. - ELK[ELK Stack - Logging & Analyse]
  466. - end
  467. -
  468. - subgraph Geschäftsprozesse
  469. - TP[Task-Priorisierung]
  470. - subgraph Finanzen
  471. - RE[Rechnungserstellung]
  472. - ZA[Zahlungsabwicklung]
  473. - BA[Banken-API]
  474. - end
  475. - subgraph Verwaltung
  476. - KV[Kundenverwaltung]
  477. - ZE[Zeiterfassung]
  478. - DO[Dokumentenarchiv]
  479. - end
  480. - end
  481. -
  482. - Email --> NC
  483. - WhatsApp --> NC
  484. - Post --> PL
  485. - Teams --> NC
  486. -
  487. - NC --> NR
  488. - PL --> NR
  489. - NR --> TP
  490. - KI --> TP
  491. -
  492. - TP --> RE
  493. - TP --> ZA
  494. - TP --> KV
  495. - TP --> ZE
  496. - TP --> DO
  497. -
  498. - ZA <--> BA
  499. -
  500. - KC -.->|Authentifizierung| NC
  501. - KC -.->|Authentifizierung| PL
  502. - KC -.->|Authentifizierung| NR
  503. - KC -.->|Authentifizierung| OUI
  504. - KC -.->|Authentifizierung| KI
  505. -
  506. - NR --> ELK
  507. - OUI --> NR
  508. -
  509. - classDef container fill:#e1f5fe,stroke:#01579b
  510. - classDef process fill:#e8f5e9,stroke:#2e7d32
  511. - classDef auth fill:#fff3e0,stroke:#ef6c00
  512. - classDef monitoring fill:#fce4ec,stroke:#c2185b
  513. -
  514. - class NC,PL,NR,KI container
  515. - class TP,RE,ZA,KV,ZE,DO process
  516. - class KC auth
  517. - class ELK monitoring
  518. -```
  519. -
  520. -#### Beschreibung der Architekturkomponenten
  521. -
  522. -Die Systemarchitektur ist in vier Hauptbereiche gegliedert:
  523. -
  524. -1. **Eingangssysteme:**
  525. - - Erfassen verschiedene Kommunikationskanäle zentral.
  526. - - Sorgen für eine einheitliche Weiterverarbeitung aller Eingänge.
  527. -
  528. -2. **Zentrale Plattform:**
  529. - - **Nextcloud (NC):** Dient als zentraler Hub für die Dateiverwaltung und Kollaboration.
  530. - - **Paperless (PL):** Zuständig für das Dokumentenmanagement und die optische Zeichenerkennung (OCR).
  531. - - **Node-RED (NR):** Automatisierung von Workflows und Geschäftsprozessen.
  532. - - **Keycloak (KC):** Bereitstellung von Single-Sign-On (SSO) und Identitätsmanagement.
  533. - - Keycloak wird als zentrale Authentifizierungsstelle für alle Dienste der zentralen Plattform verwendet, wodurch ein sicherer und zentralisierter Zugriff gewährleistet wird.
  534. - - **OpenWebUI (OUI):** KI-gestützte Kommunikation und Integration in die Workflow-Automatisierung
  535. - - **Kimai (KI):** Zeiterfassungslösung zur Verwaltung von Arbeitszeiten und Projekten.
  536. -
  537. -3. **Geschäftsprozesse:**
  538. - - Automatisierte Task-Priorisierung (TP) für eine effiziente Aufgabenverteilung.
  539. - - Integrierte Finanzprozesse mit Bankenanbindung (RE, ZA, BA).
  540. - - Zentralisierte Verwaltungsprozesse (KV, ZE, DO).
  541. -
  542. -4. **Monitoring & Analytics:**
  543. - - **ELK Stack (ELK):** Ermöglicht umfassendes Logging und Analyse in Echtzeit zur Überwachung aller Systeme.
  544. -
  545. -#### Containerstruktur
  546. -- Docker als Containerisierungsplattform
  547. -- Microservices-Architektur
  548. -- Interne Netzwerkkonfiguration
  549. -
  550. -### Komponenten
  551. -#### Nextcloud
  552. -- Funktion: Zentrale Dateiverwaltung und Kollaboration
  553. -- Version: `[VERSION]`
  554. -- Besondere Konfigurationen:
  555. - - [Wird ergänzt]
  556. -
  557. -#### Paperless
  558. -- Funktion: Dokumentenmanagement und OCR
  559. -- Version: `[VERSION]`
  560. -- Besondere Konfigurationen:
  561. - - [Wird ergänzt]
  562. -
  563. -#### Keycloak
  564. -- Funktion: Single-Sign-On und Identitätsmanagement
  565. -- Version: `[VERSION]`
  566. -- Besondere Konfigurationen:
  567. - - [Wird ergänzt]
  568. -
  569. -#### Node-RED
  570. -- Funktion: Workflow-Automatisierung
  571. -- Version: `[VERSION]`
  572. -- Implementierte Flows:
  573. - - [Wird ergänzt]
  574. -
  575. -#### ELK Stack
  576. -- Funktion: Logging und Monitoring
  577. -- Version: `[VERSION]`
  578. -- Besondere Konfigurationen:
  579. - - [Wird ergänzt]
  580. -
  581. -#### OpenWebUI
  582. -- Funktion: KI-gestützte Kommunikation
  583. -- Version: `[VERSION]`
  584. -- Integrationen:
  585. - - [Wird ergänzt]
  586. -
  587. -#### Kimai
  588. -- Funktion: Zeiterfassung
  589. -- Version: `[VERSION]`
  590. -- Besondere Konfigurationen:
  591. - - [Wird ergänzt]
  592. -
  593. -## Entwicklungsumgebung
  594. -
  595. -### Systemvoraussetzungen
  596. -- Windows mit WSL (Windows Subsystem for Linux)
  597. -- Visual Studio Code
  598. -- Docker Desktop
  599. -- NGINX Proxy Manager (läuft in WSL)
  600. -
  601. -#### Domain-Konfiguration
  602. -Die Entwicklungsumgebung nutzt die Domain `mrx8086.com` mit verschiedenen Subdomains für die einzelnen Services. Diese werden lokal über die Windows-Hosts-Datei (`C:\Windows\System32\drivers\etc\hosts`) aufgelöst.
  603. -
  604. -```plaintext
  605. -# Development Environment Host Entries
  606. -127.0.0.1 mrx8086.com
  607. -127.0.0.1 proxy.mrx8086.com # NGINX Proxy Manager
  608. -172.23.171.133 auth.mrx8086.com # Keycloak
  609. -127.0.0.1 cloud.mrx8086.com # Nextcloud
  610. -127.0.0.1 docs.mrx8086.com # Paperless
  611. -127.0.0.1 time.mrx8086.com # Kimai
  612. -127.0.0.1 automate.mrx8086.com # n8n
  613. -```
  614. -
  615. -#### Service-Übersicht
  616. -| Subdomain | Service | Beschreibung |
  617. -|-----------|---------|--------------|
  618. -| proxy.mrx8086.com | NGINX Proxy Manager | Reverse Proxy und SSL-Management (lokal in der Development Umgebung) |
  619. -| auth.mrx8086.com | Keycloak | Zentrale Authentifizierung |
  620. -| cloud.mrx8086.com | Nextcloud | Dokumentenverwaltung |
  621. -| docs.mrx8086.com | Paperless | Dokumentenmanagement |
  622. -| time.mrx8086.com | Kimai | Zeiterfassung |
  623. -| automate.mrx8086.com | n8n | Workflow-Automatisierung |
  624. -
  625. -#### WSL-Konfiguration
  626. -- NGINX Proxy Manager läuft in WSL
  627. -- IP-Adresse des WSL-Systems: 172.23.171.133 (Beispiel, kann sich ändern)
  628. -- Alle Docker-Container werden innerhalb von WSL betrieben
  629. -
  630. -#### `setup_realm.js`
  631. -Dieses Skript wird verwendet, um den Keycloak-Realm, die zugehörigen Clients und Testbenutzer automatisiert zu erstellen. Es verwendet eine `.env`-Datei zur Konfiguration.
  632. -
  633. -#### Verwendung von .env
  634. -Die Konfigurationen für das setup_realm.js Script werden in einer .env Datei gespeichert. Die benötigten Umgebungsvariablen sind unten aufgelistet:
  635. -- `KEYCLOAK_URL`: Die URL zum Keycloak Server (z.B. https://auth.mrx8086.com)
  636. -- `KEYCLOAK_ADMIN_USER`: Der Benutzername des Keycloak Administrators (z.B. admin).
  637. -- `KEYCLOAK_ADMIN_PASSWORD`: Das Passwort des Keycloak Administrators.
  638. -- `NEXTCLOUD_CLIENT_ID`: Die Client ID für Nextcloud. (z.B. nextcloud)
  639. -- `PAPERLESS_CLIENT_ID`: Die Client ID für Paperless (z.B. paperless).
  640. -- `NODERED_CLIENT_ID`: Die Client ID für Node-RED (z.B. nodered).
  641. -- `TESTADMIN_PASSWORD`: Das Passwort für den Testadmin User.
  642. -- `TESTUSER_PASSWORD`: Das Passwort für den Testuser User.
  643. -- `TESTSERVICEUSER_PASSWORD`: Das Passwort für den Testserviceuser User.
  644. -- `KEYCLOAK_NEXTCLOUD_CLIENT_SECRET`: Das Client Secret für Nextcloud.
  645. -- `NEXTCLOUD_URL`: Die URL zur Nextcloud Instanz (z.B. https://cloud.mrx8086.com).
  646. -
  647. -#### NGINX-Konfigurationen
  648. -Für jeden Service existiert eine dedizierte NGINX-Konfiguration. In der Development Umgebung wird der **NGINX Proxy Manager** verwendet. Für **Staging** und **Production** werden die entsprechenden NGINX Konfigurationsdateien in `/config/nginx` abgelegt.
  649. -
  650. -## Konfigurationen
  651. -
  652. -### Netzwerkkonfiguration
  653. -- Interne Netzwerkstruktur (noch zu definieren)
  654. -- Reverse Proxy Konfiguration über den Nginx Proxy Manager in der Development Umgebung, und Nginx Server Config in Staging und Production.
  655. -- SSL/TLS-Setup: Selbsignierte Zertifikate in der Development Umgebung, Letsencrypt in Staging und Production.
  656. -- Konfigurationsdateien für NGINX Server Config sind unter `/config/nginx/sites-available/` zu finden.
  657. -- Für die Entwicklungsumgebung werden die Konfigurationen über den Nginx Proxy Manager konfiguriert.
  658. -- Die SSL Zertifikate für die Development Umgebung werden als selbsignierte Zertifikate generiert und in `/config/nginx/ssl/mrx8086.com/` abgelegt.
  659. -- In der Staging und Production Umgebung werden die Zertifikate über Let's Encrypt oder eine andere Zertifizierungsstelle verwaltet.
  660. -
  661. -#### Umgebungsvariablen
  662. -Es werden zwei `.env`-Dateien verwendet:
  663. -Eine im `docker/` Verzeichnis für die Docker-Konfiguration und eine im `scripts/setup/keycloak/` für das `setup_realm.js`-Skript.
  664. -
  665. -**`docker/.env`:**
  666. -```env
  667. -# Generated on 2024-12-12_18-12-36
  668. -# Keycloak Admin
  669. -KEYCLOAK_ADMIN_PASSWORD=9aD5Fddh457QqmvQqr6Rb8bu
  670. -
  671. -# Keycloak Database
  672. -KC_DB_USERNAME=keycloak
  673. -KC_DB_PASSWORD=p47616y763z101f3
  674. -```
  675. -
  676. -**`scripts/setup/keycloak/.env`:**
  677. -```env
  678. -KEYCLOAK_URL=https://auth.mrx8086.com
  679. -KEYCLOAK_ADMIN_USER=admin
  680. -KEYCLOAK_ADMIN_PASSWORD=9aD5Fddh457QqmvQqr6Rb8bu
  681. -NEXTCLOUD_CLIENT_ID=nextcloud
  682. -PAPERLESS_CLIENT_ID=paperless
  683. -NODERED_CLIENT_ID=nodered
  684. -TESTADMIN_PASSWORD=TestAdminPwd
  685. -TESTUSER_PASSWORD=TestUserPwd
  686. -TESTSERVICEUSER_PASSWORD=TestServiceUserPwd
  687. -KEYCLOAK_NEXTCLOUD_CLIENT_SECRET=OSbJ08zyjBWChwBR7S6c1q4sU0d8zvEK
  688. -NEXTCLOUD_URL=https://cloud.mrx8086.com
  689. -```
  690. -
  691. -Die Passwörter in der `.env` Datei im `scripts/setup/keycloak` werden vom `setup_environment.sh` Skript generiert.
  692. -
  693. -#### Keycloak-Konfiguration
  694. -
  695. -Keycloak ist als zentrale Authentifizierungsstelle konfiguriert. Die Realm-Konfiguration, Clients und Benutzer werden über das `setup_realm.js` Skript definiert, die Konfiguration wird über die `.env` Datei im `/scripts/setup/keycloak` Verzeichnis angepasst.
  696. -
  697. -##### Realm-Konfiguration
  698. -- **Realm-Name:** `office-automation`
  699. -- **Anzeige Name:** `Office Automation`
  700. -- **SSL ist erforderlich**: `external`
  701. -- **Registrierung ist nicht erlaubt**: `false`
  702. -- **Login mit Email ist erlaubt**: `true`
  703. -- **Doppelte Email ist nicht erlaubt**: `false`
  704. -- **Passwort Reset ist erlaubt**: `true`
  705. -- **Username Bearbeitung ist nicht erlaubt**: `false`
  706. -- **Brute Force Schutz ist aktiviert**: `true`
  707. -- **Permanente Sperrung ist nicht aktiviert**: `false`
  708. -- **Standard Signature Algorithm**: `RS256`
  709. -- **WebAuthn Policy Signatur Algorithmen**: `ES256`
  710. -- **WebAuthn Policy Attestation Conveyance Preference**: `none`
  711. -- **WebAuthn Policy Authenticator Attachment**: `cross-platform`
  712. -- **WebAuthn Policy Require Resident Key**: `not specified`
  713. -- **WebAuthn Policy User Verification Requirement**: `preferred`
  714. -- **WebAuthn Policy Create Timeout**: `0`
  715. -- **WebAuthn Policy Avoid Same Authenticator Register**: `false`
  716. -- **Default Default Client Scopes**: `email`, `profile`, `roles`, `web-origins`
  717. -- **Default Optional Client Scopes**: `address`, `phone`, `offline_access`, `microprofile-jwt`
  718. -
  719. -##### Clients
  720. -Die folgenden Clients werden über das Skript konfiguriert:
  721. -- **Nextcloud:**
  722. - - **Client ID:** `nextcloud`
  723. - - **Name:** `Nextcloud`
  724. - - **Redirect URIs:**
  725. - - `https://cloud.mrx8086.com/apps/sociallogin/custom_oidc/keycloak`
  726. - - `https://cloud.mrx8086.com/apps/user_oidc/code`
  727. - - **Post Logout Redirect URIs:** `https://cloud.mrx8086.com/*`
  728. -- **Paperless:**
  729. - - **Client ID:** `paperless`
  730. - - **Name:** `Paperless`
  731. - - **Redirect URIs:** `https://docs.mrx8086.com/*`
  732. -- **Node-RED:**
  733. - - **Client ID:** `nodered`
  734. - - **Name:** `Node-RED`
  735. - - **Redirect URIs:** `https://automate.mrx8086.com/*`
  736. -
  737. -##### Gruppen
  738. -- **nextcloud-admins:** Gruppe für Nextcloud Benutzer mit Admin Rechten.
  739. -- **nextcloud-users:** Gruppe für reguläre Nextcloud Benutzer.
  740. -- **nextcloud-youpi:** Gruppe für Nextcloud Youpi Benutzer.
  741. -- **nextcloud-service:** Gruppe für Nextcloud Service Benutzer.
  742. -
  743. -##### Benutzer
  744. -- **testadmin:**
  745. - - Benutzername: `testadmin`
  746. - - Passwort: wird entweder aus der Umgebungsvariable `TESTADMIN_PASSWORD` gelesen oder standardmäßig `initial123!` gesetzt.
  747. - - Gruppen: `nextcloud-admins`,`nextcloud-users`
  748. -- **testuser:**
  749. - - Benutzername: `testuser`
  750. - - Passwort: wird entweder aus der Umgebungsvariable `TESTUSER_PASSWORD` gelesen oder standardmäßig `initial123!` gesetzt.
  751. - - Gruppen: `nextcloud-users`,`nextcloud-youpi`
  752. -- **testserviceuser:**
  753. - - Benutzername: `testserviceuser`
  754. - - Passwort: wird entweder aus der Umgebungsvariable `TESTSERVICEUSER_PASSWORD` gelesen oder standardmäßig `initial123!` gesetzt.
  755. - - Gruppen: `nextcloud-service`
  756. -
  757. -#### SSL/TLS-Setup
  758. -- **Entwicklungsumgebung (`dev`):** Für lokale Entwicklung werden selbsignierte SSL-Zertifikate verwendet.
  759. -- **Staging/Produktionsumgebung (`staging`, `production`):** Hier werden SSL-Zertifikate über Let's Encrypt oder eine ähnliche Zertifizierungsstelle verwaltet.
  760. -
  761. -## Installationsanleitung
  762. -#### Voraussetzungen
  763. -- Docker Version: `[VERSION]`
  764. -- Minimal Systemanforderungen:
  765. - - CPU: `[ANFORDERUNG]`
  766. - - RAM: `[ANFORDERUNG]`
  767. - - Speicher: `[ANFORDERUNG]`
  768. -- Für die Ausführung des `setup_realm.js` Skriptes wird `Node.js` benötigt
  769. -- Die genaue Version von `Node.js` wird zu einem späteren Zeitpunkt dokumentiert.
  770. -- Vor dem starten müssen die Passwörter generiert und die `.env` Dateien erstellt werden. Hierzu wird das `setup_environment.sh` verwendet. Dieses Skript sollte **nicht in der Produktionsumgebung** verwendet werden.
  771. -- Das Skript erstellt die benötigten Verzeichnisse, generiert zufällige Passwörter, speichert diese verschlüsselt ab, und erstellt die benötigten `.env` Dateien.
  772. -- Für die Ausführung des `setup_realm.js` Skriptes wird `Node.js` und `npm` benötigt
  773. -- Die benötigten Node Module `dotenv` und `axios` können mit `npm install dotenv axios` installiert werden.
  774. -- Die `.env` Dateien werden im `/docker` und im `/scripts/setup/keycloak` Verzeichnis abgelegt.
  775. -
  776. -#### Keycloak-Installation
  777. -1. Führe das `setup_environment.sh` Skript aus, um die .env Dateien, die Passwörter zu generieren und die Credentials zu verschlüsseln.
  778. -2. Kopiere die `docker-compose.yml` Datei in das `docker/` Verzeichnis.
  779. -3. Kopiere die `.env` Datei in das `docker/` Verzeichnis.
  780. -4. Führe `docker-compose up -d` im `docker/` Verzeichnis aus um Keycloak zu starten.
  781. -
  782. -#### Ausführen von `setup_realm.js`
  783. -1. Stelle sicher, dass Node.js und npm installiert sind.
  784. -2. Wechsle in das `/scripts/setup/keycloak` Verzeichnis.
  785. -3. Installiere die benötigten npm Pakete mit `npm install dotenv axios`.
  786. -4. Führe das Skript mit `node setup_realm.js` aus. Dies erstellt den Keycloak-Realm, die Clients und die Testbenutzer.
  787. - * Das Script befindet sich im `/scripts/setup/keycloak` Verzeichnis
  788. -
  789. -## Workflows
  790. -#### Dokumentenverarbeitung
  791. -- Eingangsverarbeitung
  792. -- OCR-Prozess
  793. -- Kategorisierung
  794. -- Archivierung
  795. -
  796. -#### Geschäftsprozesse
  797. -- Rechnungsstellung
  798. -- Zahlungsabwicklung
  799. -- Kundenmanagement
  800. -- Zeiterfassung
  801. -
  802. -#### Authentifizierungsflow
  803. -Die Authentifizierung der Benutzer für alle Dienste wird über Keycloak abgewickelt. Details zu den Authentifizierungsabläufen werden in einem späteren Schritt dokumentiert.
  804. -
  805. -## Sicherheitskonzept
  806. -#### Zugriffsmanagement
  807. -- Rollenkonzept (wird in späteren schritten dokumentiert)
  808. -- Berechtigungsmatrix (wird in späteren schritten dokumentiert)
  809. -- Authentifizierungsflows (siehe Workflows)
  810. -- Keycloak wird als zentrale Authentifizierungsstelle verwendet, Passwortrichtlinien werden in Keycloak definiert.
  811. -
  812. -#### Datensicherheit
  813. -- Verschlüsselung (wird in späteren schritten dokumentiert)
  814. -- Backup-Strategie (wird in späteren schritten dokumentiert)
  815. -- Notfallwiederherstellung (wird in späteren schritten dokumentiert)
  816. -
  817. -## Wartung und Monitoring
  818. -#### Regelmäßige Wartungsaufgaben
  819. -- Backup-Überprüfung
  820. -- Updates
  821. -- Performance-Monitoring
  822. -
  823. -Details zur Wartung und dem Monitoring werden in späteren Schritten dokumentiert.
  824. -
  825. -## Troubleshooting
  826. -#### Bekannte Probleme
  827. -- [Wird ergänzt mit auftretenden Problemen]
  828. -
  829. -#### Debugging
  830. -- Log-Analyse
  831. -- Fehlerbehandlung
  832. -- Support-Prozesse
  833. -Details zu bekannten Problemen und zur Fehlerbehandlung werden in späteren Schritten dokumentiert.
  834. -```
  835. -```markdown
  836. -# Automated Office 2.0 - Current Project State
  837. -
  838. -## Overview
  839. -Project to automate all administrative and commercial processes within the company, using open-source solutions.
  840. -
  841. -## Current Implementation Status
  842. -
  843. -### 1. Project Structure
  844. -- Basic directory structure created
  845. -- Ansible roles established (common, docker, nginx, services)
  846. -- Configuration directories set up for all services
  847. -- Documentation structure established
  848. -
  849. -### 2. Environment Setup
  850. -- Development environment using WSL
  851. -- NGINX running in WSL for development using NGINX Proxy Manager
  852. -- Docker environment being set up
  853. -- SSL certificates in place for development (self-signed)
  854. -- Staging and Production environment will use NGINX Server Configs and letsencrypt SSL certificates
  855. -
  856. -### 3. Service Status
  857. -
  858. -#### Keycloak (auth.mrx8086.com)
  859. -- NGINX configuration complete
  860. -- Docker setup complete
  861. -- Keycloak is running behind a reverse proxy
  862. -- Implemented setup_realm.js script for automated realm, client and user setup
  863. -- SSL certificates configured (self-signed)
  864. -- `setup_realm.js` configures the `office-automation` realm, `nextcloud`, `paperless`, and `nodered` clients.
  865. -- Test users `testadmin`, `testuser` and `testserviceuser` are also created.
  866. -- Client Scopes for `openid`, `profile` and `groups-nextcloud` are added to the nextcloud client.
  867. -- Groups `nextcloud-admins`, `nextcloud-users`, `nextcloud-youpi` and `nextcloud-service` are created.
  868. -
  869. -#### Nextcloud (cloud.mrx8086.com)
  870. -- NGINX configuration complete
  871. -- Docker setup complete
  872. -- SSL certificates configured
  873. -- Nextcloud is configured to use Keycloak for authentication
  874. -
  875. -#### Paperless (docs.mrx8086.com)
  876. -- NGINX configuration complete
  877. -- Docker setup pending
  878. -- SSL certificates configured
  879. -
  880. -#### Node-RED (automate.mrx8086.com)
  881. -- NGINX configuration complete
  882. -- Docker setup pending
  883. -- SSL certificates configured
  884. -- Chosen over n8n for better open-source compatibility
  885. -
  886. -### 4. Security
  887. -- Automated password generation implemented
  888. -- Encrypted credentials storage system in place
  889. -- SSL certificates managed and deployed
  890. -
  891. -### 5. Development Decisions
  892. -- Using WSL for development environment
  893. -- NGINX running directly in WSL for development
  894. -- Docker containers for all services
  895. -- Focusing on completely open-source solutions
  896. -- Development environment uses Nginx Proxy Manager
  897. -- Staging and Production will use Nginx Server Config files
  898. -
  899. -## Next Steps
  900. -1. Complete Paperless and Node-RED docker setup
  901. -2. Test Paperless and Node-RED authentication against Keycloak
  902. -3. Proceed with remaining service deployments
  903. -4. Setup Letsencrypt SSL Certificates in the Staging Environment
  904. -
  905. -## Important Files Location
  906. -- NGINX configs: /config/nginx/sites-available/
  907. -- SSL certificates: /config/nginx/ssl/mrx8086.com/
  908. -- Docker compose: /docker/docker-compose.yml
  909. -- Environment variables: /config/.env
  910. -- Encrypted credentials: /config/credentials/
  911. -- Keycloak setup script: /scripts/install/setup_realm.js
  912. -
  913. -## Development Environment
  914. -- Domain: mrx8086.com
  915. -- SSL certificates in place (self-signed)
  916. -- NGINX running in WSL
  917. -- Docker running in WSL
  918. -```
  919. -```markdown
  920. -# Ansible Setup Documentation
  921. -
  922. -## Overview
  923. -Ansible wird für das automatisierte Deployment des Automated Office Systems verwendet.
  924. -
  925. -## Roles Structure
  926. -
  927. -### Common Role
  928. -- Basis-Systemkonfiguration
  929. -- Sicherheitseinstellungen (fail2ban, UFW)
  930. -- Grundlegende Systempakete
  931. -
  932. -```yaml
  933. -# Standardvariablen
  934. -timezone: "Europe/Berlin"
  935. -fail2ban_bantime: 600
  936. -fail2ban_findtime: 600
  937. -fail2ban_maxretry: 3
  938. -```
  939. -
  940. -### Docker Role
  941. -- Docker Installation und Konfiguration
  942. -- Docker Compose Setup
  943. -- Docker Netzwerk-Konfiguration
  944. -
  945. -```yaml
  946. -# Docker Standardvariablen
  947. -docker_version: "latest"
  948. -docker_compose_version: "2.21.0"
  949. -docker_users: ["{{ ansible_user }}"]
  950. -```
  951. -
  952. -### NGINX Role
  953. -- NGINX Installation
  954. -- SSL/TLS Setup
  955. -- Virtual Host Konfiguration
  956. -
  957. -```yaml
  958. -# NGINX Standardvariablen
  959. -nginx_worker_processes: auto
  960. -nginx_worker_connections: 1024
  961. -nginx_client_max_body_size: "100M"
  962. -```
  963. -
  964. -### Services Role
  965. -- Deployment der Docker-Container
  966. -- Service-spezifische Konfigurationen
  967. -- Datenpersistenz-Setup
  968. -
  969. -## Inventory Structure
  970. -```plaintext
  971. -inventory/
  972. -├── production/
  973. -└── staging/
  974. - └── hosts
  975. -```
  976. -
  977. -## Variables
  978. -```yaml
  979. -# vars/defaults/main.yml
  980. -base_domain: "example.com"
  981. -ssl_email: "admin@example.com"
  982. -
  983. -services:
  984. - keycloak: true
  985. - nextcloud: true
  986. - paperless: true
  987. - nodered: true
  988. -```
  989. -```yaml
  990. -# ansible/roles/common/defaults/main.yml
  991. ----
  992. -# System
  993. -timezone: "Europe/Berlin"
  994. -
  995. -# Security
  996. -fail2ban_bantime: 600
  997. -fail2ban_findtime: 600
  998. -fail2ban_maxretry: 3
  999. -
  1000. -# Firewall ports to open
  1001. -ufw_allowed_ports:
  1002. - - { port: 22, proto: tcp } # SSH
  1003. - - { port: 80, proto: tcp } # HTTP
  1004. - - { port: 443, proto: tcp } # HTTPS
  1005. -```
  1006. -```yaml
  1007. -# ansible/roles/docker/defaults/main.yml
  1008. ----
  1009. -# Docker Standardvariablen
  1010. -docker_version: "latest"
  1011. -docker_compose_version: "2.21.0"
  1012. -docker_users: ["{{ ansible_user }}"]
  1013. -```
  1014. -```yaml
  1015. -# ansible/roles/nginx/defaults/main.yml
  1016. ----
  1017. -# NGINX Standardvariablen
  1018. -nginx_worker_processes: auto
  1019. -nginx_worker_connections: 1024
  1020. -nginx_client_max_body_size: "100M"
  1021. -```
  1022. -```yaml
  1023. -# ansible/vars/defaults/main.yml
  1024. ----
  1025. -# Domain-Konfiguration
  1026. -base_domain: "example.com"
  1027. -ssl_email: "admin@example.com"
  1028. -
  1029. -# Aktivierte Services
  1030. -services:
  1031. - keycloak: true
  1032. - nextcloud: true
  1033. - paperless: true
  1034. - nodered: true
  1035. -
  1036. -# Ports
  1037. -keycloak_port: 8080
  1038. -nextcloud_port: 8081
  1039. -paperless_port: 8000
  1040. -nodered_port: 1880
  1041. -
  1042. -# Docker-Konfiguration
  1043. -docker_compose_version: "2.21.0"
  1044. -```
  1045. -## Deployment Flow
  1046. -1. Common Role: Systemvorbereitung
  1047. -2. Docker Role: Container-Runtime
  1048. -3. NGINX Role: Reverse Proxy
  1049. -4. Services Role: Anwendungen
  1050. -
  1051. -## Wichtige Befehle
  1052. -```bash
  1053. -# Staging Deployment
  1054. -ansible-playbook -i inventory/staging site.yml
  1055. -
  1056. -# Production Deployment
  1057. -ansible-playbook -i inventory/production site.yml
  1058. -```
  1059. -
  1060. -## Sicherheitsaspekte
  1061. -- Automatische Passwortverwaltung
  1062. -- SSL/TLS-Konfiguration
  1063. -- Firewall-Einstellungen
  1064. -- Fail2ban-Integration
  1065. -
  1066. -## Entwicklungshinweise
  1067. -- Lokales Testing über WSL
  1068. -- Staging-Umgebung für Tests
  1069. -- Produktionsumgebung für finale Deployments
  1070. -
  1071. -## Updates und Wartung
  1072. -- Regelmäßige Updates über Ansible
  1073. -- Backup-Integration
  1074. -- Monitoring-Setup
  1075. -```
  1076. -```bash
  1077. -#!/bin/bash
  1078. -set -e
  1079. -
  1080. -# Ensure we're in the project root directory
  1081. -PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
  1082. -
  1083. -# Define directories relative to project root
  1084. -CREDENTIALS_DIR="${PROJECT_ROOT}/config/credentials"
  1085. -DOCKER_DIR="${PROJECT_ROOT}/docker"
  1086. -KEYCLOAK_SETUP_DIR="${PROJECT_ROOT}/scripts/setup/keycloak"
  1087. -ANSIBLE_PLAYBOOK="${PROJECT_ROOT}/ansible/site.yml"
  1088. -ANSIBLE_INVENTORY="${PROJECT_ROOT}/ansible/inventory/staging/hosts"
  1089. -NEXTCLOUD_DATA_DIR="${PROJECT_ROOT}/data/nextcloud/data"
  1090. -TEMP_FILE=$(mktemp)
  1091. -KEYCLOAK_DB_DIR="${PROJECT_ROOT}/data/keycloak-db"
  1092. -
  1093. -# Create necessary directories
  1094. -sudo mkdir -p "${CREDENTIALS_DIR}"
  1095. -sudo mkdir -p "${DOCKER_DIR}"
  1096. -sudo mkdir -p "${KEYCLOAK_SETUP_DIR}"
  1097. -
  1098. -# Initialize password variables
  1099. -KEYCLOAK_ADMIN_PASSWORD=""
  1100. -KC_DB_PASSWORD=""
  1101. -TESTADMIN_PASSWORD=""
  1102. -TESTUSER_PASSWORD=""
  1103. -TESTSERVICEUSER_PASSWORD=""
  1104. -KEYCLOAK_NEXTCLOUD_CLIENT_SECRET=""
  1105. -
  1106. -# Function to read a password from a .env file
  1107. -read_password_from_env() {
  1108. - local env_file="$1"
  1109. - local variable_name="$2"
  1110. - if [ -f "$env_file" ]; then
  1111. - grep "^${variable_name}=" "$env_file" | cut -d '=' -f2
  1112. - fi
  1113. -}
  1114. -
  1115. -# Function to generate secure passwords
  1116. -generate_password() {
  1117. - openssl rand -base64 32
  1118. -}
  1119. -
  1120. -# Function to generate password if empty
  1121. -generate_password_if_empty() {
  1122. - local variable_name="$1"
  1123. - eval "local value=\$$variable_name"
  1124. - if [ -z "$value" ]; then
  1125. - eval "$variable_name=\"$(generate_password)\""
  1126. - echo ">>> Generiertes Passwort für: $variable_name"
  1127. - fi
  1128. -}
  1129. -
  1130. -# Function to create .env file
  1131. -create_env_file() {
  1132. - local env_file="$1"
  1133. - local content="$2"
  1134. - if [ ! -f "$env_file" ]; then
  1135. - echo "$content" > "$env_file"
  1136. - echo ">>> .env file created: $env_file"
  1137. - else
  1138. - echo ">>> .env file already exists: $env_file"
  1139. - fi
  1140. -}
  1141. -
  1142. -echo ">>> Überprüfe bestehende .env Dateien und lese Passwörter..."
  1143. -
  1144. -# Try reading passwords from existing .env files
  1145. -if [ -f "$DOCKER_DIR/.env" ]; then
  1146. - KC_DB_PASSWORD=$(read_password_from_env "$DOCKER_DIR/.env" "KC_DB_PASSWORD")
  1147. - KEYCLOAK_ADMIN_PASSWORD=$(read_password_from_env "$DOCKER_DIR/.env" "KEYCLOAK_ADMIN_PASSWORD")
  1148. -fi
  1149. -
  1150. -if [ -f "$KEYCLOAK_SETUP_DIR/.env" ]; then
  1151. - KEYCLOAK_ADMIN_PASSWORD=$(read_password_from_env "$KEYCLOAK_SETUP_DIR/.env" "KEYCLOAK_ADMIN_PASSWORD") # Überschreibt ggf. den Wert aus docker/.env
  1152. - TESTADMIN_PASSWORD=$(read_password_from_env "$KEYCLOAK_SETUP_DIR/.env" "TESTADMIN_PASSWORD")
  1153. - TESTUSER_PASSWORD=$(read_password_from_env "$KEYCLOAK_SETUP_DIR/.env" "TESTUSER_PASSWORD")
  1154. - TESTSERVICEUSER_PASSWORD=$(read_password_from_env "$KEYCLOAK_SETUP_DIR/.env" "TESTSERVICEUSER_PASSWORD")
  1155. - KEYCLOAK_NEXTCLOUD_CLIENT_SECRET=$(read_password_from_env "$KEYCLOAK_SETUP_DIR/.env" "KEYCLOAK_NEXTCLOUD_CLIENT_SECRET")
  1156. -fi
  1157. -
  1158. -echo ">>> Generiere neue Passwörter für fehlende Werte..."
  1159. -
  1160. -# Generate passwords if they are still empty
  1161. -generate_password_if_empty KEYCLOAK_ADMIN_PASSWORD
  1162. -generate_password_if_empty KC_DB_PASSWORD
  1163. -generate_password_if_empty TESTADMIN_PASSWORD
  1164. -generate_password_if_empty TESTUSER_PASSWORD
  1165. -generate_password_if_empty TESTSERVICEUSER_PASSWORD
  1166. -generate_password_if_empty KEYCLOAK_NEXTCLOUD_CLIENT_SECRET
  1167. -
  1168. -# Date for documentation
  1169. -SETUP_DATE=$(date '+%Y-%m-%d_%H-%M-%S')
  1170. -
  1171. -# Create credentials content
  1172. -CREDENTIALS_CONTENT=$(cat <<EOL
  1173. -Setup Date: ${SETUP_DATE}
  1174. -
  1175. -Keycloak Admin Credentials:
  1176. -Username: admin
  1177. -Password: ${KEYCLOAK_ADMIN_PASSWORD}
  1178. -
  1179. -Keycloak Database Credentials:
  1180. -Username: keycloak
  1181. -Password: ${KC_DB_PASSWORD}
  1182. -
  1183. -Test User Credentials:
  1184. -Admin Password: ${TESTADMIN_PASSWORD}
  1185. -User Password: ${TESTUSER_PASSWORD}
  1186. -Service User Password: ${TESTSERVICEUSER_PASSWORD}
  1187. -Nextcloud Client Secret: ${KEYCLOAK_NEXTCLOUD_CLIENT_SECRET}
  1188. -
  1189. -EOL
  1190. -)
  1191. -
  1192. -# Store credentials hash
  1193. -CREDENTIALS_HASH=$(echo "$CREDENTIALS_CONTENT" | sha256sum | awk '{print $1}')
  1194. -echo "$CREDENTIALS_HASH" > "${CREDENTIALS_DIR}/credentials_hash.txt"
  1195. -echo ">>> Credentials hash stored in: ${CREDENTIALS_DIR}/credentials_hash.txt"
  1196. -
  1197. -# Set GPG PASSPHRASE
  1198. -export GPG_PASSPHRASE=$(generate_password)
  1199. -# Set GPG agent environment variable
  1200. -export GPG_TTY=$(tty)
  1201. -
  1202. -echo ">>> Trying openssl encryption first"
  1203. -# Alternative Verschlüsselung mit Openssl
  1204. -echo "$CREDENTIALS_CONTENT" > "$TEMP_FILE"
  1205. - if openssl enc -aes-256-cbc -pbkdf2 -salt -in "$TEMP_FILE" -out "${CREDENTIALS_DIR}/credentials_${SETUP_DATE}.txt.enc" -k "$GPG_PASSPHRASE" ; then
  1206. - echo ">>> Credentials encrypted successfully using openssl"
  1207. - mv "${CREDENTIALS_DIR}/credentials_${SETUP_DATE}.txt.enc" "${CREDENTIALS_DIR}/credentials_${SETUP_DATE}.txt.gpg"
  1208. - else
  1209. - echo ">>> Openssl encryption failed, trying gpg"
  1210. -
  1211. - # Attempt to kill existing gpg agent
  1212. - gpgconf --kill gpg-agent 2>/dev/null
  1213. - echo ">>> Attempting to manually start gpg-agent with pinentry-curses"
  1214. - gpg-agent --daemon --pinentry-program /usr/bin/pinentry-curses
  1215. - gpg-connect-agent /bye 2>/dev/null
  1216. - eval $(gpg-agent --daemon)
  1217. - gpg-connect-agent updatestartuptty /bye 2>/dev/null
  1218. -
  1219. - # Attempt to encrypt credentials using GPG with error handling
  1220. - if echo "$CREDENTIALS_CONTENT" | gpg --symmetric --cipher-algo AES256 -vvv -o "${CREDENTIALS_DIR}/credentials_${SETUP_DATE}.txt.gpg" ; then
  1221. - echo ">>> Credentials encrypted successfully using gpg."
  1222. - else
  1223. - echo
  1224. -
  1225. -
  1226. -
  1227. -
  1228. -
  1229. -
  1230. - ```
  1231. \ No newline at end of file