21 lines
879 B
Bash
21 lines
879 B
Bash
|
|
#!/bin/bash
|
||
|
|
# Fix 2: Lägg till RBAC på oskyddade endpoints i index.mjs
|
||
|
|
|
||
|
|
FILE="/opt/amos/services/aamos-ledger/index.mjs"
|
||
|
|
BAK="${FILE}.bak-rbac-$(date +%s)"
|
||
|
|
|
||
|
|
# Skapa backup
|
||
|
|
cp "$FILE" "$BAK"
|
||
|
|
|
||
|
|
# Lägg till requireRole på customers POST
|
||
|
|
sed -i 's/app.post('\''\/api\/ledger\/customers'\''/app.post('\''\/api\/ledger\/customers'\'', requireRole(ROLES.ADMIN, ROLES.ACCOUNTANT)/' "$FILE"
|
||
|
|
|
||
|
|
# Lägg till requireRole på upload POST
|
||
|
|
sed -i 's/app.post('\''\/api\/ledger\/journal\/:id\/upload'\''/app.post('\''\/api\/ledger\/journal\/:id\/upload'\'', requireRole(ROLES.ADMIN, ROLES.ACCOUNTANT)/' "$FILE"
|
||
|
|
|
||
|
|
# Lägg till requireRole på receipt POST
|
||
|
|
sed -i 's/app.post('\''\/api\/ledger\/journal\/:id\/receipt'\''/app.post('\''\/api\/ledger\/journal\/:id\/receipt'\'', requireRole(ROLES.ADMIN, ROLES.ACCOUNTANT)/' "$FILE"
|
||
|
|
|
||
|
|
echo "Backup: $BAK"
|
||
|
|
echo "RBAC fixar applicerade på index.mjs"
|