Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14ca73fa83 | ||
|
|
e76dc49698 | ||
|
|
c17c33b6d8 | ||
|
|
66e93ceaf3 | ||
|
|
fba139fdec | ||
|
|
e0dd0e4348 | ||
|
|
710bdf380a | ||
|
|
7b83f36060 | ||
|
|
2a23956a8b | ||
|
|
9269643c0e | ||
|
|
6c8fe4ebf7 | ||
|
|
037ac76d26 | ||
|
|
9faaefa83a | ||
|
|
85700efcd1 | ||
|
|
91a8c76bdb | ||
|
|
88e2780a54 | ||
|
|
60fcb2e214 | ||
|
|
c8224fd434 | ||
|
|
69433426be | ||
|
|
9015eec558 | ||
|
|
5129853267 | ||
|
|
a669541b13 | ||
|
|
c0c15f8cab | ||
|
|
2e377bde67 | ||
|
|
703bbe1113 | ||
|
|
1347e3607d | ||
|
|
9e2a79d0f2 | ||
|
|
841dd9b948 | ||
|
|
887796c36d | ||
|
|
02c52130bb | ||
|
|
76a9cb8042 | ||
|
|
b5f843e99b | ||
|
|
be21f76688 | ||
|
|
d90dfa7085 | ||
|
|
f7453530f6 |
No files matched your search
@@ -62,7 +62,7 @@ jobs:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
@@ -165,7 +165,7 @@ jobs:
|
||||
exit $FAILED
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
path: |
|
||||
@@ -280,7 +280,7 @@ jobs:
|
||||
'
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -294,7 +294,7 @@ jobs:
|
||||
|
||||
- name: Upload raw coverage data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: api-coverage-${{ matrix.suite }}
|
||||
path: ${{ env.GOCOVERDIR }}
|
||||
@@ -328,7 +328,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -342,7 +342,7 @@ jobs:
|
||||
|
||||
- name: Upload raw coverage data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: api-coverage-cli-${{ matrix.suite }}
|
||||
path: ${{ env.GOCOVERDIR }}
|
||||
@@ -376,7 +376,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -390,7 +390,7 @@ jobs:
|
||||
|
||||
- name: Upload raw coverage data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: api-coverage-ldap-pool-${{ matrix.suite }}
|
||||
path: ${{ env.GOCOVERDIR }}
|
||||
@@ -468,7 +468,7 @@ jobs:
|
||||
'
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -485,7 +485,7 @@ jobs:
|
||||
|
||||
- name: Upload raw coverage data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: api-coverage-core-${{ matrix.suite }}
|
||||
path: ${{ env.GOCOVERDIR }}
|
||||
@@ -534,7 +534,7 @@ jobs:
|
||||
vault_storage: true
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
|
||||
# https://github.com/microsoft/playwright/issues/40724
|
||||
@@ -551,7 +551,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -683,7 +683,7 @@ jobs:
|
||||
|
||||
- name: Upload tracing result
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: playwright-traces-${{ matrix.suite }}-${{ github.run_attempt }}
|
||||
path: web/reports/e2e
|
||||
@@ -691,7 +691,7 @@ jobs:
|
||||
|
||||
- name: Upload a11y result
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: playwright-a11y-result-${{ matrix.suite }}-${{ github.run_attempt }}
|
||||
path: web/reports/e2e/a11y-report.json
|
||||
@@ -712,7 +712,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -737,7 +737,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -762,7 +762,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -787,7 +787,7 @@ jobs:
|
||||
sudo NEEDRESTART_MODE=a apt-get install -y libvips42t64
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: ocis-build-artifacts
|
||||
|
||||
@@ -809,7 +809,7 @@ jobs:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
@@ -842,7 +842,7 @@ jobs:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
@@ -876,7 +876,7 @@ jobs:
|
||||
cache: true
|
||||
|
||||
- name: Download raw coverage data
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: api-coverage-*
|
||||
path: ${{ env.GOCOVERDIR }}
|
||||
|
||||
+109
-7
@@ -447,7 +447,7 @@ jobs:
|
||||
e2e-tests:
|
||||
name: e2e-${{ matrix.suite }}-k8s
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
timeout-minutes: 120
|
||||
|
||||
if: >-
|
||||
github.event_name == 'schedule' ||
|
||||
@@ -459,14 +459,45 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- suite: smoke
|
||||
# - suite: part-1
|
||||
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 1"
|
||||
- suite: part-2
|
||||
args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 2"
|
||||
# - suite: part-3
|
||||
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 3"
|
||||
# - suite: part-4
|
||||
# args: "--type playwright --total-parts 4 --xsuites search,app-provider,ocm,keycloak,mfa,oidc,vault-storage --run-part 4"
|
||||
# - suite: search
|
||||
# args: "--type playwright --suites search"
|
||||
# tika: true
|
||||
# - suite: keycloak
|
||||
# args: "--type playwright --suites journeys,keycloak"
|
||||
# keycloak: true
|
||||
# - suite: mfa
|
||||
# args: "--type playwright --suites mfa"
|
||||
# mfa: true
|
||||
# - suite: oidc
|
||||
# args: "--type playwright specs/oidc/refreshToken.spec.ts"
|
||||
# oidc: true
|
||||
# - suite: oidc-iframe
|
||||
# args: "--type playwright specs/oidc/iframeTokenRenewal.spec.ts"
|
||||
# oidc_iframe: true
|
||||
- suite: app-provider
|
||||
args: "--type playwright --suites app-provider"
|
||||
collaboration: true
|
||||
# - suite: ocm
|
||||
# args: "--type playwright --suites ocm"
|
||||
# federated: true
|
||||
# - suite: vault-storage
|
||||
# args: "--type playwright --suites vault-storage"
|
||||
# vault_storage: true
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
# 24.16.0 breaks playwright install (yauzl zip extraction hangs); pin to last known good.
|
||||
# https://github.com/microsoft/playwright/issues/40724
|
||||
@@ -509,14 +540,84 @@ jobs:
|
||||
run: make -C tests/config/k8s create-cluster
|
||||
|
||||
- name: Prepare Helm Charts
|
||||
env:
|
||||
ENABLE_WOPI: ${{ matrix.suite == 'app-provider' }}
|
||||
run: make -C tests/config/k8s prepare-charts
|
||||
|
||||
- name: Deploy Suite-Specific External Backends
|
||||
run: |
|
||||
if [[ "${{ matrix.suite }}" == "app-provider" ]]; then
|
||||
# Start Collabora
|
||||
docker run -d \
|
||||
--name collabora \
|
||||
--network host \
|
||||
--entrypoint bash \
|
||||
-e DONT_GEN_SSL_CERT=set \
|
||||
-e "extra_params=--o:ssl.enable=true --o:ssl.termination=true --o:welcome.enable=false --o:net.frame_ancestors=https://127.0.0.1:9200" \
|
||||
collabora/code:25.04.7.3.1 \
|
||||
-c "coolconfig generate-proof-key && bash /start-collabora-online.sh"
|
||||
timeout 150 bash -c 'until curl -kfsSL https://localhost:9980/hosting/discovery > /dev/null; do sleep 5; done'
|
||||
echo "collabora ready."
|
||||
|
||||
# Start OnlyOffice
|
||||
docker run -d \
|
||||
--name onlyoffice \
|
||||
-p 7443:443 \
|
||||
--add-host "$TEST_SERVER_DOMAIN:host-gateway" \
|
||||
-e WOPI_ENABLED=true \
|
||||
-e USE_UNAUTHORIZED_STORAGE=true \
|
||||
-v "$(pwd)/tests/config/ci/only-office.json:/tmp/local.json:ro" \
|
||||
--entrypoint /bin/sh \
|
||||
onlyoffice/documentserver:9.2.1 \
|
||||
-c "set -e
|
||||
cp /tmp/local.json /etc/onlyoffice/documentserver/local.json
|
||||
openssl req -x509 -newkey rsa:4096 -keyout onlyoffice.key -out onlyoffice.crt -sha256 -days 365 -batch -nodes
|
||||
mkdir -p /var/www/onlyoffice/Data/certs
|
||||
cp onlyoffice.key /var/www/onlyoffice/Data/certs/
|
||||
cp onlyoffice.crt /var/www/onlyoffice/Data/certs/
|
||||
chmod 400 /var/www/onlyoffice/Data/certs/onlyoffice.key
|
||||
/app/ds/run-document-server.sh"
|
||||
timeout 150 bash -c 'until curl -kfsSL https://localhost:7443/hosting/discovery > /dev/null; do sleep 5; done'
|
||||
echo "onlyoffice ready."
|
||||
|
||||
#Start FakeOffice
|
||||
docker run -d --name fakeoffice --network host \
|
||||
-v "$(pwd):/ocis:ro" \
|
||||
python:3-alpine \
|
||||
python3 -c "
|
||||
import http.server, pathlib
|
||||
body = pathlib.Path('/ocis/tests/config/ci/hosting-discovery.xml').read_bytes()
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'text/xml')
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
def log_message(self, *a): pass
|
||||
http.server.HTTPServer(('', 8080), H).serve_forever()
|
||||
"
|
||||
timeout 60 bash -c 'until curl -fsSL http://localhost:8080/hosting/discovery > /dev/null; do sleep 5; done'
|
||||
echo "fakeoffice ready."
|
||||
|
||||
bash tests/config/k8s/expose-external-svc.sh collabora:9980
|
||||
bash tests/config/k8s/expose-external-svc.sh onlyoffice:7443
|
||||
bash tests/config/k8s/expose-external-svc.sh fakeoffice:8080
|
||||
fi
|
||||
|
||||
- name: Deploy oCIS
|
||||
run: |
|
||||
cd tests/config/k8s
|
||||
kubectl get pods -n "$TEST_SERVER_DOMAIN" -Aw &
|
||||
make deploy-ocis
|
||||
|
||||
- name: Expose node ports
|
||||
if: ${{ matrix.suite == 'app-provider' }}
|
||||
run: |
|
||||
bash tests/config/k8s/expose-nodeports.sh collaboration-collabora 9300 30300
|
||||
bash tests/config/k8s/expose-nodeports.sh collaboration-fakeoffice 9300 30301
|
||||
bash tests/config/k8s/expose-nodeports.sh collaboration-onlyoffice 9300 30302
|
||||
bash tests/config/k8s/expose-nodeports.sh collaboration-fakeoffice 9304 30304
|
||||
|
||||
- name: Wait for oCIS to be ready
|
||||
env:
|
||||
FILE_URL: ${{ env.TEST_SERVER_URL }}/remote.php/dav/files/admin/hello1.txt
|
||||
@@ -584,14 +685,15 @@ jobs:
|
||||
|
||||
- name: Run e2e ${{ matrix.suite }} tests
|
||||
env:
|
||||
E2E_ARGS: "--suites ${{ matrix.suite }}"
|
||||
E2E_ARGS: "${{ matrix.args }}"
|
||||
K8S: ${{ env.K8S }}
|
||||
TEST_SERVER_URL: ${{ env.TEST_SERVER_URL }}
|
||||
COLLABORATION_NEEDED: ${{ matrix.collaboration == true && 'true' || 'false' }}
|
||||
run: python3 tests/acceptance/run-e2e.py
|
||||
|
||||
- name: Upload Playwright traces
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: playwright-traces-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
|
||||
path: web/reports/e2e
|
||||
@@ -599,7 +701,7 @@ jobs:
|
||||
|
||||
- name: Upload a11y result
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: playwright-a11y-result-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
|
||||
path: web/reports/e2e/a11y-report.json
|
||||
@@ -607,7 +709,7 @@ jobs:
|
||||
|
||||
- name: Upload oCIS logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: ocis-logs-${{ matrix.suite }}-k8s-${{ github.run_attempt }}
|
||||
path: tests/config/k8s/logs
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24.15.0
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
+15
-186
@@ -14,9 +14,6 @@ on:
|
||||
default: ''
|
||||
|
||||
env:
|
||||
PRODUCTION_RELEASE_TAGS: '5.0,7,8'
|
||||
DOCKER_REPO_ROLLING: owncloud/ocis-rolling
|
||||
DOCKER_REPO_PRODUCTION: owncloud/ocis
|
||||
NODE_VERSION: '24'
|
||||
PNPM_VERSION: '10.28.1'
|
||||
GOLANG_BUILD_IMAGE: 'golang:1.26.8-alpine3.23@sha256:a8fa79c5bd40d880b52bd3b6d7669ecdcfd00e85facdd427d279efb5ddd79cb1'
|
||||
@@ -27,9 +24,7 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
version: ${{ steps.info.outputs.version }}
|
||||
is_production: ${{ steps.info.outputs.is_production }}
|
||||
is_prerelease: ${{ steps.info.outputs.is_prerelease }}
|
||||
docker_repos: ${{ steps.info.outputs.docker_repos }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
if: ${{ github.ref_type == 'branch' || (github.event_name == 'workflow_dispatch' && inputs.version_override == '') }}
|
||||
@@ -75,23 +70,10 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IS_PRODUCTION=false
|
||||
for TAG in ${PRODUCTION_RELEASE_TAGS//,/ }; do
|
||||
[[ "$VERSION" == "$TAG"* ]] && IS_PRODUCTION=true && break
|
||||
done
|
||||
|
||||
[[ "$VERSION" == *"-"* ]] && IS_PRERELEASE=true || IS_PRERELEASE=false
|
||||
|
||||
if [[ "$IS_PRODUCTION" == "true" && "$IS_PRERELEASE" == "false" ]]; then
|
||||
REPOS=[\"$DOCKER_REPO_ROLLING\",\"$DOCKER_REPO_PRODUCTION\"]
|
||||
else
|
||||
REPOS=[\"$DOCKER_REPO_ROLLING\"]
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "is_production=$IS_PRODUCTION" >> $GITHUB_OUTPUT
|
||||
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
|
||||
echo "docker_repos=$REPOS" >> $GITHUB_OUTPUT
|
||||
|
||||
generate-code:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -102,7 +84,7 @@ jobs:
|
||||
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
- run: npm install --silent -g yarn npx --force
|
||||
@@ -119,7 +101,7 @@ jobs:
|
||||
run: |
|
||||
VERSION="${{ needs.determine-release-type.outputs.version }}"
|
||||
sed -i "s/LatestTag = \".*\"/LatestTag = \"$VERSION\"/" ocis-pkg/version/version.go
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: generated-code
|
||||
path: |
|
||||
@@ -128,159 +110,6 @@ jobs:
|
||||
!web
|
||||
retention-days: 1
|
||||
|
||||
docker-build:
|
||||
if: false
|
||||
name: docker-build (${{ matrix.arch }}, ${{ matrix.repo }})
|
||||
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
|
||||
timeout-minutes: 120
|
||||
needs: [determine-release-type, generate-code, security-scan-trivy]
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, arm64]
|
||||
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: generated-code
|
||||
path: .
|
||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- id: goversion
|
||||
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- run: |
|
||||
ALPINE_VERSION=$(grep '^FROM.*alpine:' ocis/docker/Dockerfile.linux.${{ matrix.arch }} | grep -o 'alpine:[0-9.]*' | cut -d: -f2 | cut -d. -f1,2)
|
||||
docker run --rm \
|
||||
-v "${{ github.workspace }}:/workspace" \
|
||||
-w /workspace \
|
||||
"golang:${{ steps.goversion.outputs.go-version }}-alpine${ALPINE_VERSION}" \
|
||||
sh -c "apk add --no-cache bash gcc musl-dev vips-dev make git && \
|
||||
git config --global --add safe.directory /workspace && \
|
||||
CGO_ENABLED=1 ENABLE_VIPS=true VERSION=${{ needs.determine-release-type.outputs.version }} \
|
||||
make -C ocis release-linux-docker-${{ matrix.arch }}"
|
||||
- id: tags
|
||||
run: |
|
||||
VERSION="${{ needs.determine-release-type.outputs.version }}"
|
||||
REPO="${{ matrix.repo }}"
|
||||
ARCH="${{ matrix.arch }}"
|
||||
printf "tags<<EOF\n%s\nEOF\n" \
|
||||
"${REPO}:${VERSION}-linux-${ARCH}" >> $GITHUB_OUTPUT
|
||||
- id: build
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: ocis
|
||||
file: ocis/docker/Dockerfile.linux.${{ matrix.arch }}
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
load: true
|
||||
push: false
|
||||
provenance: false
|
||||
build-args: |
|
||||
REVISION=${{ github.sha }}
|
||||
VERSION=${{ needs.determine-release-type.outputs.version }}
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
- id: trivy
|
||||
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
image-ref: ${{ steps.tags.outputs.tags }}
|
||||
format: table
|
||||
exit-code: 1
|
||||
severity: HIGH,CRITICAL
|
||||
ignore-unfixed: true
|
||||
skip-files: /usr/bin/gomplate,/usr/bin/wait-for
|
||||
hide-progress: true
|
||||
env:
|
||||
TRIVY_IGNOREFILE: .trivyignore
|
||||
- name: Block on vulnerabilities
|
||||
if: steps.trivy.outcome == 'failure'
|
||||
run: |
|
||||
echo "::error title=Security scan blocked release::Image ${{ steps.tags.outputs.tags }} has HIGH or CRITICAL vulnerabilities (see Trivy report above). Fix all findings before releasing."
|
||||
exit 1
|
||||
- name: push
|
||||
if: steps.trivy.outcome == 'success'
|
||||
run: docker push ${{ steps.tags.outputs.tags }}
|
||||
|
||||
docker-scan:
|
||||
name: docker-scan (${{ matrix.arch }}, ${{ matrix.repo }})
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
needs: [determine-release-type, docker-build]
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64]
|
||||
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
|
||||
id: trivy
|
||||
continue-on-error: true
|
||||
with:
|
||||
image-ref: ${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-${{ matrix.arch }}
|
||||
format: table
|
||||
exit-code: 1
|
||||
severity: HIGH,CRITICAL
|
||||
ignore-unfixed: true
|
||||
skip-files: /usr/bin/gomplate,/usr/bin/wait-for
|
||||
hide-progress: true
|
||||
env:
|
||||
TRIVY_IGNOREFILE: .trivyignore
|
||||
|
||||
- name: Block on vulnerabilities
|
||||
if: steps.trivy.outcome == 'failure'
|
||||
run: |
|
||||
echo "::error title=Security scan blocked release::Image ${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-${{ matrix.arch }} has HIGH or CRITICAL vulnerabilities (see Trivy report above). Fix all findings before releasing."
|
||||
exit 1
|
||||
|
||||
docker-manifest:
|
||||
if: false
|
||||
name: docker-manifest (${{ matrix.repo }})
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
needs: [determine-release-type, docker-build, docker-scan]
|
||||
strategy:
|
||||
matrix:
|
||||
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
|
||||
steps:
|
||||
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- if: ${{ contains(matrix.repo, 'rolling') }}
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
-t "${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}" \
|
||||
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-amd64" \
|
||||
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-arm64"
|
||||
- if: ${{ !contains(matrix.repo, 'rolling') }}
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
-t "${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}" \
|
||||
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-amd64" \
|
||||
"${{ matrix.repo }}:${{ needs.determine-release-type.outputs.version }}-linux-arm64"
|
||||
|
||||
docker-readme:
|
||||
if: false
|
||||
name: docker-readme (${{ matrix.repo }})
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
needs: [determine-release-type, docker-manifest]
|
||||
strategy:
|
||||
matrix:
|
||||
repo: ${{ fromJSON(needs.determine-release-type.outputs.docker_repos) }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ matrix.repo }}
|
||||
readme-filepath: ocis/README.md
|
||||
|
||||
build-binaries:
|
||||
name: build-binaries (${{ matrix.os }})
|
||||
runs-on: ubuntu-latest
|
||||
@@ -291,7 +120,7 @@ jobs:
|
||||
os: [linux, darwin]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: generated-code
|
||||
path: .
|
||||
@@ -304,7 +133,7 @@ jobs:
|
||||
if [[ "${{ matrix.os }}" == "linux" ]]; then
|
||||
cp assets/End-User-License-Agreement-for-ownCloud-Infinite-Scale.pdf ocis/dist/release/
|
||||
fi
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: binaries-${{ matrix.os }}
|
||||
path: ocis/dist/release/*
|
||||
@@ -329,11 +158,11 @@ jobs:
|
||||
needs: [determine-release-type, generate-code]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: generated-code
|
||||
path: .
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||
@@ -347,7 +176,7 @@ jobs:
|
||||
- run: make ci-node-check-licenses && make ci-node-save-licenses
|
||||
- run: make ci-go-check-licenses && make ci-go-save-licenses
|
||||
- run: tar -czf third-party-licenses.tar.gz -C third-party-licenses .
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: third-party-licenses
|
||||
path: third-party-licenses.tar.gz
|
||||
@@ -371,7 +200,7 @@ jobs:
|
||||
if [[ $(wc -l < ocis/dist/CHANGELOG.md) -lt 5 ]]; then
|
||||
echo "Development release — no release notes yet. See [unreleased changes](https://github.com/owncloud/ocis/tree/master/changelog/unreleased/)." > ocis/dist/CHANGELOG.md
|
||||
fi
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: changelog
|
||||
path: ocis/dist/CHANGELOG.md
|
||||
@@ -382,19 +211,19 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
needs: [determine-release-type, build-binaries, license-check, generate-changelog, security-scan-trivy]
|
||||
steps:
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: binaries-linux
|
||||
path: release-assets
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: binaries-darwin
|
||||
path: release-assets
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: third-party-licenses
|
||||
path: release-assets
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: changelog
|
||||
path: .
|
||||
@@ -419,15 +248,15 @@ jobs:
|
||||
- create-github-release
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: binaries-linux
|
||||
path: release-assets
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: binaries-darwin
|
||||
path: release-assets
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: third-party-licenses
|
||||
path: release-assets
|
||||
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
version: 10.33.3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24.15.0
|
||||
cache: pnpm
|
||||
|
||||
@@ -41,6 +41,7 @@ OCIS_MODULES = \
|
||||
services/idm \
|
||||
services/idp \
|
||||
services/invitations \
|
||||
services/llm \
|
||||
services/nats \
|
||||
services/notifications \
|
||||
services/ocdav \
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Bugfix: Fix AuthApp and basic auth requests with custom PROXY_USER_OIDC_CLAIM
|
||||
|
||||
We fixed AuthApp (app password) and HTTP basic auth requests returning an
|
||||
internal server error whenever PROXY_USER_OIDC_CLAIM was set to anything
|
||||
other than its default value. Both authenticators put the already
|
||||
authenticated user directly into the request context instead of faking
|
||||
incomplete claims for the account resolver to re-resolve. We also made sure
|
||||
a user who only ever authenticates this way still gets a default role
|
||||
assigned, and that these requests keep getting rejected on deployments with
|
||||
multiple instances enabled, since neither carries tenant-membership
|
||||
information.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13107
|
||||
@@ -0,0 +1,20 @@
|
||||
Bugfix: Record the acting user in the audit log's User field
|
||||
|
||||
The audit log's `User` field is documented as the UID of the user performing
|
||||
the action, but the file and folder converters filled it from the event's
|
||||
`Owner`, which reva does not set, so the field was empty on every upload,
|
||||
download, move, delete, restore and version restore. Where an event did carry
|
||||
an owner, `User` named the owner rather than the person acting, for example a
|
||||
share recipient uploading into a shared folder. Space, user and group events
|
||||
hard-coded the field to an empty string although every one of those events
|
||||
carries the actor.
|
||||
|
||||
`User` is now taken from the event's `Executant` for all of these events. The
|
||||
`Owner` field of file events is unchanged. The failed public-link access event
|
||||
still has no actor and keeps an empty `User`.
|
||||
|
||||
While adding tests for the user and group events, the group member added and
|
||||
removed messages turned out to pass the user and group ids in the wrong order,
|
||||
naming the group as the user and the user as the group; that is fixed too.
|
||||
|
||||
https://github.com/owncloud/ocis/issues/4789
|
||||
@@ -0,0 +1,9 @@
|
||||
Bugfix: Show image preview for files with spaces in the name on public links
|
||||
|
||||
The preview in the details panel was not shown for files opened via a public
|
||||
link when the file name contained spaces. The preview URL was used unquoted in a
|
||||
CSS `url()`, so the browser dropped it and never requested the thumbnail. The
|
||||
URL is now quoted.
|
||||
|
||||
https://github.com/owncloud/ocis/issues/13137
|
||||
https://github.com/owncloud/ocis/pull/13150
|
||||
@@ -0,0 +1,10 @@
|
||||
Bugfix: Disable rubber-band overscroll of the page in file apps
|
||||
|
||||
Scrolling to the top or bottom of the content in a file app such as
|
||||
OnlyOffice, Collabora or the text editor could make the whole page bounce
|
||||
along with it, including the top bar and the app frame, briefly revealing the
|
||||
blank page background behind them. The vertical elastic overscroll of the page
|
||||
is now disabled while a file is open in one of these apps, so the surrounding
|
||||
layout stays in place.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13140
|
||||
@@ -0,0 +1,11 @@
|
||||
Bugfix: Files no longer stay in processing after upload or copy
|
||||
|
||||
After uploading or copying files, some of them sometimes stayed greyed out as
|
||||
"processing" until the page was reloaded. This happened when processing
|
||||
finished while the file list was still being loaded: the update from the
|
||||
server was ignored and the list then showed the file as still processing.
|
||||
|
||||
Files whose processing has finished are now refreshed automatically when they
|
||||
show up in the file list as processing.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13134
|
||||
@@ -0,0 +1,25 @@
|
||||
Bugfix: Fix the LDAP master-ID filter when the base filter is empty
|
||||
|
||||
The function `EnhanceFilterWithMasterID` in `ocis-pkg/ldap/filter.go` adds a
|
||||
master-ID clause to an LDAP filter with OR. An empty filter means "no
|
||||
restriction". Before this fix, the function replaced an empty filter with a
|
||||
master-ID-only filter. This action restricted an unrestricted search to
|
||||
master-ID users only.
|
||||
|
||||
The bug broke the search for a user on another instance in multi-instance
|
||||
deployments. This search uses the Graph API endpoint `/graph/v1.0/users`.
|
||||
Multi-instance deployments use this search to find a user to share a resource
|
||||
with.
|
||||
|
||||
Now the function keeps an empty filter unchanged. The function still adds a
|
||||
master-ID clause to a filter that is not empty.
|
||||
|
||||
The `graph`, `auth-basic`, `users`, and `groups` services also use this
|
||||
function to compute their default LDAP user filter when
|
||||
`OCIS_MULTI_INSTANCE_MASTER_ID` is set. An empty user filter now means these
|
||||
services resolve or authenticate every user in the shared LDAP directory,
|
||||
not only master-ID users. Each of these services now rejects startup when
|
||||
`OCIS_MULTI_INSTANCE_MASTER_ID` is set and its own user filter is empty.
|
||||
Set an explicit `OCIS_LDAP_USER_FILTER` for every multi-instance deployment.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13100
|
||||
@@ -0,0 +1,8 @@
|
||||
Bugfix: Stop logging "no user in context" for data gateway requests
|
||||
|
||||
The proxy's create-home middleware logged an error for every request that
|
||||
carried a reva token but no user. reva's internal downloads through the data
|
||||
gateway (`/data`) are such requests, so every file download added an
|
||||
error-level line. These requests are now passed on with a debug-level log.
|
||||
|
||||
https://github.com/owncloud/ocis/issues/13101
|
||||
@@ -0,0 +1,10 @@
|
||||
Bugfix: Show an error instead of "no deleted files" for inaccessible trash
|
||||
|
||||
Members of a space who are not allowed to list its trash, for example members
|
||||
with the "Can edit" role, were told that the space has no deleted files, even
|
||||
though files had been deleted. The trash view now tells the user that the
|
||||
deleted files could not be loaded and that they might lack the permission to
|
||||
view them. A trash that is really empty still shows the "no deleted files"
|
||||
message.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13105
|
||||
@@ -0,0 +1,10 @@
|
||||
Bugfix: Clean up the trash view in the Safe
|
||||
|
||||
The trash offered a "Copy permanent link" action for deleted items, which
|
||||
cannot be linked to. The action is no longer shown for deleted items.
|
||||
|
||||
The personal space in the trash was labelled "Personal" in the Safe, while the
|
||||
rest of the interface calls it "Safe-Personal". The trash now uses the same
|
||||
name.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13136
|
||||
@@ -0,0 +1,8 @@
|
||||
Bugfix: Show correct message when Safe access is denied for lacking permission
|
||||
|
||||
A user without permission to use the Safe who opened the Safe URL directly was
|
||||
shown "Not logged in" with a "Log in again" button, even though they were
|
||||
still logged in. The page now shows "Access denied" with a "Continue" button
|
||||
that returns to the app for this case.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13111
|
||||
@@ -0,0 +1,13 @@
|
||||
Bugfix: Fix file and folder downloads in vault mode
|
||||
|
||||
Downloading a file in the vault failed with a 403 error. A download uses a
|
||||
signed link without a login token. Thus the proxy uses the stored MFA status of
|
||||
the user. The proxy did not store this status. Now the proxy stores it after it
|
||||
knows the user. A download is accepted if the user had a request with MFA within
|
||||
the MFA session duration.
|
||||
|
||||
Downloading a folder or several files in the vault failed with a 404 error. In
|
||||
vault mode, the web UI requested the signing key from a wrong address. Now the
|
||||
web UI uses the correct address.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13097
|
||||
@@ -0,0 +1,13 @@
|
||||
Change: Remove the MFA session extension popup in vault mode
|
||||
|
||||
In vault mode, the web UI showed a popup shortly before the multi-factor
|
||||
authentication session was about to expire, offering to extend or dismiss it.
|
||||
Extending only reset a timer in the browser and did not renew anything on the
|
||||
server, so the popup has been removed.
|
||||
|
||||
The frontend service no longer exposes the MFA session duration in its
|
||||
capabilities, and its `session_duration` setting has been removed. The
|
||||
`OCIS_MFA_SESSION_DURATION` environment variable is still used by the proxy
|
||||
service.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13085
|
||||
@@ -0,0 +1,13 @@
|
||||
Enhancement: Add LLM proxy service
|
||||
|
||||
oCIS now ships a native `llm` microservice, as part of the single binary,
|
||||
that proxies chat-completion requests from AI web extensions to a
|
||||
configured OpenAI-compatible LLM endpoint, so AI-enabled oCIS deployments
|
||||
no longer need a separate process or image.
|
||||
|
||||
The service trusts oCIS's existing authentication (no independent OIDC
|
||||
validation), rate-limits requests per user using oCIS's shared store
|
||||
abstraction (shared across multiple replicas), and forwards a sanitized
|
||||
request body — only the fields the LLM needs are passed through.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12965
|
||||
@@ -0,0 +1,12 @@
|
||||
Enhancement: Record tag changes in the audit log
|
||||
|
||||
Adding or removing tags on a file or folder left no trace in the audit log.
|
||||
The graph service already publishes `TagsAdded` and `TagsRemoved` events for
|
||||
every change, but only the search service listened to them.
|
||||
|
||||
The audit service now records both: `file_tags_add` and `file_tags_remove`
|
||||
entries carry the acting user, the file id and path, the space owner and the
|
||||
tags concerned. The graph service also sets the timestamp on the two events,
|
||||
which it left empty before.
|
||||
|
||||
https://github.com/owncloud/ocis/issues/13054
|
||||
@@ -0,0 +1,13 @@
|
||||
Enhancement: Add a --timeout flag to the search index command
|
||||
|
||||
`ocis search index` called the search service with a fixed 10 minute request
|
||||
timeout. The service walks the whole space inside that request, so once the
|
||||
timeout expired the walk was cancelled with "error walking the tree: context
|
||||
canceled" and everything after that point stayed unindexed. A space whose
|
||||
walk takes longer than ten minutes, for example because the content extractor
|
||||
is slow on a few files, could never be fully indexed from the command line.
|
||||
|
||||
The timeout is now a flag. `--timeout` takes a duration (default `10m`, so the
|
||||
behaviour is unchanged out of the box); `0` waits indefinitely.
|
||||
|
||||
https://github.com/owncloud/ocis/issues/13052
|
||||
@@ -0,0 +1,14 @@
|
||||
Bugfix: The global variable OCIS_CACHE_DATABASE was replaced
|
||||
|
||||
Some services accepted only the global variable OCIS_CACHE_DATABASE for their
|
||||
cache database name. The default values for each service is unique that is
|
||||
why this has not been noticed until now.
|
||||
|
||||
We added a local variable for each service. The GATEWAY service now accepts
|
||||
GATEWAY_PROVIDER_CACHE_DATABASE. The PROXY service now accepts
|
||||
PROXY_OIDC_USERINFO_CACHE_DATABASE. The SETTINGS service now accepts
|
||||
SETTINGS_CACHE_DATABASE. The STORAGE-SYSTEM service now accepts
|
||||
STORAGE_SYSTEM_CACHE_DATABASE. The do not use the global variable OCIS_CACHE_DATABASE
|
||||
to avoid the cache collisions.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13158
|
||||
@@ -23,9 +23,9 @@ require (
|
||||
github.com/gabriel-vasile/mimetype v1.4.15
|
||||
github.com/ggwhite/go-masker v1.1.0
|
||||
github.com/go-chi/chi/v5 v5.3.2
|
||||
github.com/go-chi/httprate v0.16.0
|
||||
github.com/go-chi/httprate v0.16.1
|
||||
github.com/go-chi/render v1.0.3
|
||||
github.com/go-ldap/ldap/v3 v3.4.14
|
||||
github.com/go-ldap/ldap/v3 v3.4.15
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3
|
||||
github.com/go-micro/plugins/v4/client/grpc v1.2.1
|
||||
github.com/go-micro/plugins/v4/logger/zerolog v1.2.0
|
||||
@@ -58,7 +58,7 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/mna/pigeon v1.3.0
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/nats-io/nats-server/v2 v2.15.0
|
||||
github.com/nats-io/nats-server/v2 v2.15.1
|
||||
github.com/nats-io/nats.go v1.54.0
|
||||
github.com/olekukonko/tablewriter v1.1.5
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
@@ -67,10 +67,10 @@ require (
|
||||
github.com/open-policy-agent/opa v1.21.1
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261007144855-b8082819aa39
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.24.1
|
||||
github.com/prometheus/client_golang v1.25.0
|
||||
github.com/r3labs/sse/v2 v2.10.0
|
||||
github.com/rogpeppe/go-internal v1.16.0
|
||||
github.com/rs/cors v1.11.1
|
||||
@@ -82,7 +82,7 @@ require (
|
||||
github.com/stretchr/testify v1.12.1
|
||||
github.com/test-go/testify v1.1.4
|
||||
github.com/thejerf/suture/v4 v4.0.6
|
||||
github.com/tidwall/gjson v1.19.1
|
||||
github.com/tidwall/gjson v1.20.0
|
||||
github.com/tus/tusd/v2 v2.10.1
|
||||
github.com/unrolled/secure v1.17.0
|
||||
github.com/urfave/cli/v2 v2.27.7
|
||||
@@ -90,7 +90,7 @@ require (
|
||||
go-micro.dev/v4 v4.11.0
|
||||
go.etcd.io/bbolt v1.5.0
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0
|
||||
go.opentelemetry.io/contrib/zpages v0.72.0
|
||||
go.opentelemetry.io/otel v1.47.0
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
||||
@@ -100,9 +100,9 @@ require (
|
||||
golang.org/x/crypto v0.57.0
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba
|
||||
golang.org/x/image v0.46.0
|
||||
golang.org/x/net v0.59.0
|
||||
golang.org/x/net v0.60.0
|
||||
golang.org/x/oauth2 v0.37.0
|
||||
golang.org/x/sync v0.23.0
|
||||
golang.org/x/sync v0.24.0
|
||||
golang.org/x/term v0.46.0
|
||||
golang.org/x/text v0.42.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc
|
||||
@@ -238,7 +238,7 @@ require (
|
||||
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
|
||||
github.com/juliangruber/go-intersect v1.1.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/klauspost/compress v1.20.0 // indirect
|
||||
github.com/klauspost/compress v1.20.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
|
||||
github.com/klauspost/crc32 v1.3.0 // indirect
|
||||
github.com/kovidgoyal/go-parallel v1.1.1 // indirect
|
||||
@@ -292,8 +292,8 @@ require (
|
||||
github.com/pquerna/cachecontrol v0.2.0 // indirect
|
||||
github.com/prometheus/alertmanager v0.34.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.3 // indirect
|
||||
github.com/prometheus/common v0.70.1 // indirect
|
||||
github.com/prometheus/procfs v0.21.1 // indirect
|
||||
github.com/prometheus/common v0.72.0 // indirect
|
||||
github.com/prometheus/procfs v0.22.0 // indirect
|
||||
github.com/prometheus/statsd_exporter v0.22.8 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
|
||||
@@ -288,8 +288,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoM
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-chi/chi/v5 v5.3.2 h1:5YQkICvTCSZ25hoRsyJazN0scjzKGiu4VAUc7H1o1nY=
|
||||
github.com/go-chi/chi/v5 v5.3.2/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
|
||||
github.com/go-chi/httprate v0.16.0 h1:8V5DH9j6pSK6UQoBsTpvMyFxycqaKEIToyPKzHJjUa8=
|
||||
github.com/go-chi/httprate v0.16.0/go.mod h1:A8lo+qRhk+s9LiuP5saS7XCGDXRXMcrueq0NfIuCa/I=
|
||||
github.com/go-chi/httprate v0.16.1 h1:q2M8FmDsI4oEr1oRX43N+VeA0Ujd1tb/EasrSzXy87o=
|
||||
github.com/go-chi/httprate v0.16.1/go.mod h1:A8lo+qRhk+s9LiuP5saS7XCGDXRXMcrueq0NfIuCa/I=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||
@@ -315,8 +315,8 @@ github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj
|
||||
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
|
||||
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||
github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14 h1:D6PYdEgsaVzsXyr6w/yDC06Ria4uUhWm+Rb+er8lfAs=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14/go.mod h1:S4eJUMUNjDkE0ZJtIZdybwyb03sGGLW6gxXT1Hs8VKA=
|
||||
github.com/go-ldap/ldap/v3 v3.4.15 h1:eRB4f4Ecn1POL1mO86+uUDlecmyWsdiJwh60bAUS4UY=
|
||||
github.com/go-ldap/ldap/v3 v3.4.15/go.mod h1:jeD0c98EdZQCKKKKe4kTWs5aCf6y+j8KuYsYLznZSQk=
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3 h1:sfz1YppV05y4sYaW7kXZtrocU/+vimnIWt4cxAYh7+o=
|
||||
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3/go.mod h1:ZXFhGda43Z2TVbfGZefXyMJzsDHhCh0go3bZUcwTx7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
@@ -573,8 +573,8 @@ github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4
|
||||
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
||||
@@ -696,8 +696,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
|
||||
github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0 h1:M99yf0y05rTr46/qc/Is6ZAowI58Ryp2SjufLCUeVJc=
|
||||
github.com/nats-io/nats-server/v2 v2.15.0/go.mod h1:5qLF4CDGzZVFt//3fUrY1ePpwbi05r7QHPNroSUtolk=
|
||||
github.com/nats-io/nats-server/v2 v2.15.1 h1:fK3AeYFIji1Smng60jB0hVoAPZezA/UzsaI3BqXFNEI=
|
||||
github.com/nats-io/nats-server/v2 v2.15.1/go.mod h1:yeuYRtKVKIFtmMz2/YPk+6hvmNBnk+WwTUzErBdH6IE=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
@@ -736,8 +736,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261007144855-b8082819aa39 h1:lC5Y4C3/i0uDhMLA53+kfDJg919gNbjSe2+FiViP3XM=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261007144855-b8082819aa39/go.mod h1:cgqg+UTe4ekjMbJj8hgoXSTxQ9fQramKcOUdvsFUrzc=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899 h1:IMu076AtnFEdabpBbowcGDYOeFLtm9ycNY1Z43YPYZU=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261012083840-8b649a4c3899/go.mod h1:cgqg+UTe4ekjMbJj8hgoXSTxQ9fQramKcOUdvsFUrzc=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
@@ -777,8 +777,8 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr
|
||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
|
||||
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
|
||||
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
||||
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
|
||||
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
|
||||
github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
@@ -793,8 +793,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9
|
||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||
github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
||||
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
||||
github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4=
|
||||
github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk=
|
||||
github.com/prometheus/procfs v0.0.0-20170703101242-e645f4e5aaa8/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
@@ -802,8 +802,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
||||
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
|
||||
github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics=
|
||||
github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58=
|
||||
github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI=
|
||||
github.com/prometheus/statsd_exporter v0.22.8 h1:Qo2D9ZzaQG+id9i5NYNGmbf1aa/KxKbB9aKfMS+Yib0=
|
||||
github.com/prometheus/statsd_exporter v0.22.8/go.mod h1:/DzwbTEaFTE0Ojz5PqcSk6+PFHOPWGxdXVr6yC8eFOM=
|
||||
@@ -891,8 +891,8 @@ github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o
|
||||
github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
|
||||
github.com/thejerf/suture/v4 v4.0.6 h1:QsuCEsCqb03xF9tPAsWAj8QOAJBgQI1c0VqJNaingg8=
|
||||
github.com/thejerf/suture/v4 v4.0.6/go.mod h1:gu9Y4dXNUWFrByqRt30Rm9/UZ0wzRSt9AJS6xu/ZGxU=
|
||||
github.com/tidwall/gjson v1.19.1 h1:uKxUTe/+mtjSY3Sf1EIND83MyH+jWf1SixZ7DHpjbJU=
|
||||
github.com/tidwall/gjson v1.19.1/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
|
||||
github.com/tidwall/gjson v1.20.0 h1:+agJ3rEzKcCXKDKo0ml26UROcpcAlnZyjq+TjbY5Fto=
|
||||
github.com/tidwall/gjson v1.20.0/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
@@ -968,8 +968,8 @@ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0 h1:Tq+E65HaNbZTeqcLw6QUhsV+/EIWdkfUH2CQzcrlE5M=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.72.0/go.mod h1:A+EVhDakAj1waJBPhmTszZaSr08ww8MRRKy1nB1rqck=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||
go.opentelemetry.io/contrib/zpages v0.72.0 h1:aXBUaFvbF7xy77q6vXBvaw7dcZK0zUqJSF5UhtbbuZ4=
|
||||
go.opentelemetry.io/contrib/zpages v0.72.0/go.mod h1:e/qIKK0RHtY2dvkJhp1jtjVvglq/IDzMI7gDN8mMMtY=
|
||||
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||
@@ -1102,8 +1102,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
|
||||
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1127,8 +1127,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
idm "github.com/owncloud/ocis/v2/services/idm/pkg/config"
|
||||
idp "github.com/owncloud/ocis/v2/services/idp/pkg/config"
|
||||
invitations "github.com/owncloud/ocis/v2/services/invitations/pkg/config"
|
||||
llm "github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
nats "github.com/owncloud/ocis/v2/services/nats/pkg/config"
|
||||
notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/config"
|
||||
ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/config"
|
||||
@@ -103,6 +104,7 @@ type Config struct {
|
||||
IDM *idm.Config `yaml:"idm"`
|
||||
IDP *idp.Config `yaml:"idp"`
|
||||
Invitations *invitations.Config `yaml:"invitations"`
|
||||
LLM *llm.Config `yaml:"llm"`
|
||||
Nats *nats.Config `yaml:"nats"`
|
||||
Notifications *notifications.Config `yaml:"notifications"`
|
||||
OCDav *ocdav.Config `yaml:"ocdav"`
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
idm "github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults"
|
||||
idp "github.com/owncloud/ocis/v2/services/idp/pkg/config/defaults"
|
||||
invitations "github.com/owncloud/ocis/v2/services/invitations/pkg/config/defaults"
|
||||
llm "github.com/owncloud/ocis/v2/services/llm/pkg/config/defaults"
|
||||
nats "github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults"
|
||||
notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults"
|
||||
ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults"
|
||||
@@ -77,6 +78,7 @@ func DefaultConfig() *Config {
|
||||
IDM: idm.DefaultConfig(),
|
||||
IDP: idp.DefaultConfig(),
|
||||
Invitations: invitations.DefaultConfig(),
|
||||
LLM: llm.DefaultConfig(),
|
||||
Nats: nats.DefaultConfig(),
|
||||
Notifications: notifications.DefaultConfig(),
|
||||
OCDav: ocdav.DefaultConfig(),
|
||||
|
||||
+6
-11
@@ -7,14 +7,13 @@ import (
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
)
|
||||
|
||||
// EnhanceFilterWithMasterID OR's the given LDAP filter with master-id match clauses.
|
||||
// Returns filter unchanged when masterID is empty or both attributes are empty.
|
||||
// EnhanceFilterWithMasterID adds master-ID match clauses to the given LDAP filter with OR.
|
||||
// An empty filter means "no restriction". Do not OR an empty filter with a master-ID clause.
|
||||
// This action would restrict an unrestricted search to the master ID only.
|
||||
// The function returns the filter without a change when masterID is empty, when both
|
||||
// attributes are empty, or when filter is empty.
|
||||
func EnhanceFilterWithMasterID(filter, masterID, memberAttr, guestAttr string) string {
|
||||
if masterID == "" {
|
||||
return filter
|
||||
}
|
||||
|
||||
if memberAttr == "" && guestAttr == "" {
|
||||
if masterID == "" || (memberAttr == "" && guestAttr == "") || filter == "" {
|
||||
return filter
|
||||
}
|
||||
|
||||
@@ -35,9 +34,5 @@ func EnhanceFilterWithMasterID(filter, masterID, memberAttr, guestAttr string) s
|
||||
masterIDFilter = fmt.Sprintf("(|%s)", strings.Join(masterIDParts, ""))
|
||||
}
|
||||
|
||||
if filter == "" {
|
||||
return masterIDFilter
|
||||
}
|
||||
|
||||
return fmt.Sprintf("(|%s%s)", filter, masterIDFilter)
|
||||
}
|
||||
@@ -54,12 +54,12 @@ func TestEnhanceFilterWithMasterID(t *testing.T) {
|
||||
expectedFilter: "(|(ownCloudGuestOf=instance-1)(ownCloudGuestOf=0000-0000-000-0000))",
|
||||
},
|
||||
{
|
||||
name: "empty existing filter",
|
||||
name: "empty existing filter stays unrestricted",
|
||||
filter: "",
|
||||
masterID: "0000-0000-000-0000",
|
||||
memberAttr: "ownCloudMemberOf",
|
||||
guestAttr: "ownCloudGuestOf",
|
||||
expectedFilter: "(|(ownCloudMemberOf=0000-0000-000-0000)(ownCloudGuestOf=0000-0000-000-0000))",
|
||||
expectedFilter: "",
|
||||
},
|
||||
{
|
||||
name: "LDAP injection protection",
|
||||
|
||||
@@ -46,6 +46,13 @@ func MissingLDAPBindPassword(service string) error {
|
||||
service, defaults.BaseConfigPath())
|
||||
}
|
||||
|
||||
func MissingLDAPUserFilterForMasterID(service string) error {
|
||||
return fmt.Errorf("The ldap user_filter has not been set for %s, but OCIS_MULTI_INSTANCE_MASTER_ID is set. "+
|
||||
"Set an explicit user_filter to scope this instance to its own users. "+
|
||||
"Without a user_filter, every user in the shared LDAP directory can access this instance.",
|
||||
service)
|
||||
}
|
||||
|
||||
func MissingServiceUserPassword(service, serviceUser string) error {
|
||||
return fmt.Errorf("The password of service user %s has not been set properly in your config for %s. "+
|
||||
"Make sure your %s config contains the proper values "+
|
||||
|
||||
@@ -54,8 +54,8 @@ type GRPCClientOptions struct {
|
||||
// which read them independently of each other but apply the same rules, so both behave
|
||||
// identically for every input. Keepalive is off unless the time is set to a duration that
|
||||
// parses; a value without a unit suffix leaves the clients without pings.
|
||||
GRPCClientKeepaliveTime time.Duration `yaml:"grpc_client_keepalive_time" env:"GRPC_CLIENT_KEEPALIVE_TIME" desc:"How long a grpc client connection with an ongoing request may stay silent before the server is pinged to check whether it is still answering. Set a duration like '20s' to enable detection of unresponsive peers. Leaving it unset, or at '0', sends no pings at all, which is grpc's own default. Values below '10s' are raised to '10s' by grpc. Make sure to include the unit suffix, a bare number is not a valid duration." introductionVersion:"8.3.0"`
|
||||
GRPCClientKeepaliveTimeout time.Duration `yaml:"grpc_client_keepalive_timeout" env:"GRPC_CLIENT_KEEPALIVE_TIMEOUT" desc:"How long a grpc client waits for the answer to a keepalive ping before it considers the connection dead and fails all requests on it. Defaults to '10s'. Has no effect unless GRPC_CLIENT_KEEPALIVE_TIME is set. See GRPC_CLIENT_KEEPALIVE_TIME." introductionVersion:"8.3.0"`
|
||||
GRPCClientKeepaliveTime time.Duration `yaml:"grpc_client_keepalive_time" env:"GRPC_CLIENT_KEEPALIVE_TIME" desc:"How long a grpc client connection with an ongoing request may stay silent before the server is pinged to check whether it is still answering. Set a duration like '20s' to enable detection of unresponsive peers. Leaving it unset, or at '0', sends no pings at all, which is grpc's own default. Values below '10s' are raised to '10s' by grpc. Make sure to include the unit suffix, a bare number is not a valid duration." introductionVersion:"9.0.0"`
|
||||
GRPCClientKeepaliveTimeout time.Duration `yaml:"grpc_client_keepalive_timeout" env:"GRPC_CLIENT_KEEPALIVE_TIMEOUT" desc:"How long a grpc client waits for the answer to a keepalive ping before it considers the connection dead and fails all requests on it. Defaults to '10s'. Has no effect unless GRPC_CLIENT_KEEPALIVE_TIME is set. See GRPC_CLIENT_KEEPALIVE_TIME." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
type GRPCServiceTLS struct {
|
||||
@@ -80,9 +80,9 @@ type Cache struct {
|
||||
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
|
||||
AuthUsername string `yaml:"auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"pre5.0"`
|
||||
AuthPassword string `yaml:"auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"pre5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the NATS store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the NATS store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate used to validate the NATS store TLS certificate. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the NATS store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the NATS store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate used to validate the NATS store TLS certificate. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// Commons holds configuration that are common to all extensions. Each extension can then decide whether
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
idm "github.com/owncloud/ocis/v2/services/idm/pkg/command"
|
||||
idp "github.com/owncloud/ocis/v2/services/idp/pkg/command"
|
||||
invitations "github.com/owncloud/ocis/v2/services/invitations/pkg/command"
|
||||
llm "github.com/owncloud/ocis/v2/services/llm/pkg/command"
|
||||
nats "github.com/owncloud/ocis/v2/services/nats/pkg/command"
|
||||
notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/command"
|
||||
ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/command"
|
||||
@@ -58,6 +59,11 @@ var svccmds = []register.Command{
|
||||
cfg.Activitylog.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.LLM.Service.Name, llm.GetCommands(cfg.LLM), func(c *config.Config) {
|
||||
cfg.LLM.Commons = cfg.Commons
|
||||
})
|
||||
},
|
||||
func(cfg *config.Config) *cli.Command {
|
||||
return ServiceCommand(cfg, cfg.Antivirus.Service.Name, antivirus.GetCommands(cfg.Antivirus), func(c *config.Config) {
|
||||
// cfg.Antivirus.Commons = cfg.Commons // antivirus needs no commons atm
|
||||
|
||||
@@ -48,6 +48,7 @@ import (
|
||||
idm "github.com/owncloud/ocis/v2/services/idm/pkg/command"
|
||||
idp "github.com/owncloud/ocis/v2/services/idp/pkg/command"
|
||||
invitations "github.com/owncloud/ocis/v2/services/invitations/pkg/command"
|
||||
llm "github.com/owncloud/ocis/v2/services/llm/pkg/command"
|
||||
nats "github.com/owncloud/ocis/v2/services/nats/pkg/command"
|
||||
ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/command"
|
||||
ocm "github.com/owncloud/ocis/v2/services/ocm/pkg/command"
|
||||
@@ -355,6 +356,11 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
|
||||
cfg.Notifications.Commons = cfg.Commons
|
||||
return runServerCommand(ctx, notifications.Server(cfg.Notifications))
|
||||
})
|
||||
areg(opts.Config.LLM.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
|
||||
cfg.LLM.Context = ctx
|
||||
cfg.LLM.Commons = cfg.Commons
|
||||
return runServerCommand(ctx, llm.Server(cfg.LLM))
|
||||
})
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ type Store struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;ACTIVITYLOG_STORE_TTL" desc:"Time to live for events in the store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;ACTIVITYLOG_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;ACTIVITYLOG_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;ACTIVITYLOG_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;ACTIVITYLOG_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;ACTIVITYLOG_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;ACTIVITYLOG_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;ACTIVITYLOG_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;ACTIVITYLOG_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// ServiceAccount is the configuration for the used service account
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
The audit service logs all events of the system as an audit log. Per default, it will be logged to standard out, but can also be configured to a file output. Supported log formats are json or a minimal human-readable format.
|
||||
|
||||
Besides shares, links, files, spaces, users and groups, tag changes are recorded: adding tags to a file or folder is logged as `file_tags_add` and removing them as `file_tags_remove`, each with the acting user, the file id and the tags as requested. The request is recorded as made: a tag that was already present (or, for a removal, absent) is still listed, so repeated requests remain visible.
|
||||
|
||||
With audit logs, you are able to prove compliance with corporate guidelines as well as to enable reporting and auditing of operations. The audit service takes note of actions conducted by users and administrators.
|
||||
|
||||
Example minimal format:
|
||||
|
||||
@@ -83,6 +83,10 @@ func StartAuditLogger(ctx context.Context, ch <-chan events.Event, log log.Logge
|
||||
auditEvent = types.ItemRestored(ev)
|
||||
case events.FileVersionRestored:
|
||||
auditEvent = types.FileVersionRestored(ev)
|
||||
case events.TagsAdded:
|
||||
auditEvent = types.TagsAdded(ev)
|
||||
case events.TagsRemoved:
|
||||
auditEvent = types.TagsRemoved(ev)
|
||||
case events.SpaceCreated:
|
||||
auditEvent = types.SpaceCreated(ev)
|
||||
case events.SpaceRenamed:
|
||||
|
||||
@@ -325,7 +325,7 @@ var testCases = []struct {
|
||||
Event: events.FileUploaded{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -335,7 +335,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' created file 'pro-1$sto-123!iid-123/item'", "file_create")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
},
|
||||
}, {
|
||||
Alias: "File read",
|
||||
@@ -343,7 +343,7 @@ var testCases = []struct {
|
||||
Event: events.FileDownloaded{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -353,7 +353,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' read file 'pro-1$sto-123!iid-123/item'", "file_read")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
},
|
||||
}, {
|
||||
Alias: "File trashed",
|
||||
@@ -361,7 +361,7 @@ var testCases = []struct {
|
||||
Event: events.ItemTrashed{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -371,7 +371,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' trashed file 'pro-1$sto-123!iid-123/item'", "file_delete")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
},
|
||||
}, {
|
||||
Alias: "File renamed",
|
||||
@@ -380,7 +380,7 @@ var testCases = []struct {
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
OldReference: reference("pro-1", "sto-123", "iid-123", "./anotheritem"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -390,7 +390,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' moved file 'pro-1$sto-123!iid-123/item' from './anotheritem' to './item'", "file_rename")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
// AuditEventFileRenamed fields
|
||||
require.Equal(t, "./anotheritem", ev.OldPath)
|
||||
|
||||
@@ -401,7 +401,7 @@ var testCases = []struct {
|
||||
Event: events.ItemPurged{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -411,7 +411,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' removed file 'pro-1$sto-123!iid-123/item' from trashbin", "file_trash_delete")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
},
|
||||
}, {
|
||||
Alias: "File restored",
|
||||
@@ -419,7 +419,7 @@ var testCases = []struct {
|
||||
Event: events.ItemRestored{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
OldReference: reference("pro-1", "sto-123", "sto-123!iid-123/item", "./oldpath"),
|
||||
Key: "",
|
||||
},
|
||||
@@ -431,7 +431,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' from trashbin to './item'", "file_trash_restore")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
// AuditEventFileRestored fields
|
||||
require.Equal(t, "./oldpath", ev.OldPath)
|
||||
|
||||
@@ -442,7 +442,7 @@ var testCases = []struct {
|
||||
Event: events.FileVersionRestored{
|
||||
Executant: userID("uid-123"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva
|
||||
Owner: userID("uid-owner"),
|
||||
Key: "v1",
|
||||
},
|
||||
},
|
||||
@@ -453,7 +453,7 @@ var testCases = []struct {
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' in version 'v1'", "file_version_restore")
|
||||
// AuditEventSharing fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item")
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
// AuditEventFileRestored fields
|
||||
require.Equal(t, "v1", ev.Key)
|
||||
|
||||
@@ -464,7 +464,7 @@ var testCases = []struct {
|
||||
Event: events.SpaceCreated{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
Owner: userID("uid-123"),
|
||||
Owner: userID("uid-owner"),
|
||||
Root: resourceID("pro-1", "sto-123", "iid-123"),
|
||||
Name: "test-space",
|
||||
Type: "project",
|
||||
@@ -477,11 +477,11 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_created")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_created")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
// AuditEventFileRestored fields
|
||||
require.Equal(t, "uid-123", ev.Owner)
|
||||
require.Equal(t, "uid-owner", ev.Owner)
|
||||
require.Equal(t, "pro-1$sto-123!iid-123", ev.RootItem)
|
||||
require.Equal(t, "test-space", ev.Name)
|
||||
require.Equal(t, "project", ev.Type)
|
||||
@@ -492,7 +492,7 @@ var testCases = []struct {
|
||||
Event: events.SpaceRenamed{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
Owner: userID("uid-123"),
|
||||
Owner: userID("uid-owner"),
|
||||
Name: "new-name",
|
||||
},
|
||||
},
|
||||
@@ -501,7 +501,7 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' renamed space 'space-123' to 'new-name' (storage: 'storage-1')", "space_renamed")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' renamed space 'space-123' to 'new-name' (storage: 'storage-1')", "space_renamed")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
// AuditEventSpaceRenamed fields
|
||||
@@ -520,7 +520,7 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123' (storage: 'storage-1')", "space_disabled")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123' (storage: 'storage-1')", "space_disabled")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
@@ -537,7 +537,7 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' (re-) enabled the space 'space-123' (storage: 'storage-1')", "space_enabled")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' (re-) enabled the space 'space-123' (storage: 'storage-1')", "space_enabled")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
@@ -555,7 +555,7 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_deleted")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_deleted")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
@@ -587,6 +587,92 @@ var testCases = []struct {
|
||||
require.Equal(t, "http://ocis.test/invite", ev.InviteLink)
|
||||
},
|
||||
},
|
||||
{
|
||||
Alias: "User created",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.UserCreated{
|
||||
Executant: userID("uid-admin"),
|
||||
UserID: "uid-new",
|
||||
Timestamp: timestamp(10e8),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
ev := types.AuditEventUserCreated{}
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields: User is the actor, not the affected user
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-admin", "2001-09-09T01:46:40Z", "user 'uid-admin' created the user 'uid-new'", "user_created")
|
||||
// AuditEventUserCreated fields
|
||||
require.Equal(t, "uid-new", ev.UserID)
|
||||
},
|
||||
},
|
||||
{
|
||||
Alias: "Group member added",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.GroupMemberAdded{
|
||||
Executant: userID("uid-admin"),
|
||||
GroupID: "gid-123",
|
||||
UserID: "uid-member",
|
||||
Timestamp: timestamp(10e8),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
ev := types.AuditEventGroupMemberAdded{}
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields: User is the actor, not the member
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-admin", "2001-09-09T01:46:40Z", "user 'uid-admin' added user 'uid-member' was added to group 'gid-123'", "group_member_added")
|
||||
// AuditEventGroupMemberAdded fields
|
||||
require.Equal(t, "gid-123", ev.GroupID)
|
||||
require.Equal(t, "uid-member", ev.UserID)
|
||||
},
|
||||
},
|
||||
{
|
||||
Alias: "Tags added",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.TagsAdded{
|
||||
Executant: userID("uid-123"),
|
||||
SpaceOwner: userID("uid-owner"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Tags: "holiday,family",
|
||||
Timestamp: timestamp(10e8),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
ev := types.AuditEventTagsAdded{}
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields: User is the actor, Owner the space owner
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2001-09-09T01:46:40Z", "user 'uid-123' added tags 'holiday,family' to file 'pro-1$sto-123!iid-123/item'", "file_tags_add")
|
||||
// AuditEventFiles fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
// AuditEventTagsAdded fields
|
||||
require.Equal(t, "holiday,family", ev.Tags)
|
||||
},
|
||||
},
|
||||
{
|
||||
Alias: "Tags removed",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.TagsRemoved{
|
||||
Executant: userID("uid-123"),
|
||||
SpaceOwner: userID("uid-owner"),
|
||||
Ref: reference("pro-1", "sto-123", "iid-123", "./item"),
|
||||
Tags: "holiday",
|
||||
Timestamp: timestamp(10e8),
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
ev := types.AuditEventTagsRemoved{}
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields: User is the actor, Owner the space owner
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "2001-09-09T01:46:40Z", "user 'uid-123' removed tags 'holiday' from file 'pro-1$sto-123!iid-123/item'", "file_tags_remove")
|
||||
// AuditEventFiles fields
|
||||
checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-owner", "./item")
|
||||
// AuditEventTagsRemoved fields
|
||||
require.Equal(t, "holiday", ev.Tags)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestAuditLogging(t *testing.T) {
|
||||
|
||||
@@ -247,7 +247,7 @@ func FilesAuditEvent(base AuditEvent, itemid, owner, path string) AuditEventFile
|
||||
// ContainerCreated converts a ContainerCreated event to an AuditEventContainerCreated
|
||||
func ContainerCreated(ev events.ContainerCreated) AuditEventContainerCreated {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageContainerCreated(ev.Executant.GetOpaqueId(), iid), ActionContainerCreated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageContainerCreated(ev.Executant.GetOpaqueId(), iid), ActionContainerCreated)
|
||||
return AuditEventContainerCreated{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
@@ -256,7 +256,7 @@ func ContainerCreated(ev events.ContainerCreated) AuditEventContainerCreated {
|
||||
// FileUploaded converts a FileUploaded event to an AuditEventFileCreated
|
||||
func FileUploaded(ev events.FileUploaded) AuditEventFileCreated {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileCreated(ev.Executant.GetOpaqueId(), iid), ActionFileCreated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileCreated(ev.Executant.GetOpaqueId(), iid), ActionFileCreated)
|
||||
return AuditEventFileCreated{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
@@ -265,7 +265,7 @@ func FileUploaded(ev events.FileUploaded) AuditEventFileCreated {
|
||||
// FileDownloaded converts a FileDownloaded event to an AuditEventFileRead
|
||||
func FileDownloaded(ev events.FileDownloaded) AuditEventFileRead {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRead(ev.Executant.GetOpaqueId(), iid), ActionFileRead)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRead(ev.Executant.GetOpaqueId(), iid), ActionFileRead)
|
||||
return AuditEventFileRead{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func ItemMoved(ev events.ItemMoved) AuditEventFileRenamed {
|
||||
oldpath = ev.OldReference.GetPath()
|
||||
}
|
||||
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRenamed(ev.Executant.GetOpaqueId(), iid, oldpath, path), ActionFileRenamed)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRenamed(ev.Executant.GetOpaqueId(), iid, oldpath, path), ActionFileRenamed)
|
||||
return AuditEventFileRenamed{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
OldPath: oldpath,
|
||||
@@ -290,7 +290,7 @@ func ItemMoved(ev events.ItemMoved) AuditEventFileRenamed {
|
||||
// ItemTrashed converts a ItemTrashed event to an AuditEventFileDeleted
|
||||
func ItemTrashed(ev events.ItemTrashed) AuditEventFileDeleted {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileTrashed(ev.Executant.GetOpaqueId(), iid), ActionFileTrashed)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileTrashed(ev.Executant.GetOpaqueId(), iid), ActionFileTrashed)
|
||||
return AuditEventFileDeleted{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func ItemTrashed(ev events.ItemTrashed) AuditEventFileDeleted {
|
||||
// ItemPurged converts a ItemPurged event to an AuditEventFilePurged
|
||||
func ItemPurged(ev events.ItemPurged) AuditEventFilePurged {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFilePurged(ev.Executant.GetOpaqueId(), iid), ActionFilePurged)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFilePurged(ev.Executant.GetOpaqueId(), iid), ActionFilePurged)
|
||||
return AuditEventFilePurged{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func ItemRestored(ev events.ItemRestored) AuditEventFileRestored {
|
||||
oldpath = ev.OldReference.GetPath()
|
||||
}
|
||||
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileRestored(ev.Executant.GetOpaqueId(), iid, path), ActionFileRestored)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileRestored(ev.Executant.GetOpaqueId(), iid, path), ActionFileRestored)
|
||||
return AuditEventFileRestored{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
OldPath: oldpath,
|
||||
@@ -324,13 +324,37 @@ func ItemRestored(ev events.ItemRestored) AuditEventFileRestored {
|
||||
// FileVersionRestored converts a FileVersionRestored event to an AuditEventFileVersionRestored
|
||||
func FileVersionRestored(ev events.FileVersionRestored) AuditEventFileVersionRestored {
|
||||
iid, path, uid := extractFileDetails(ev.Ref, ev.Owner)
|
||||
base := BasicAuditEvent(uid, formatTime(ev.Timestamp), MessageFileVersionRestored(ev.Executant.GetOpaqueId(), iid, ev.Key), ActionFileVersionRestored)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageFileVersionRestored(ev.Executant.GetOpaqueId(), iid, ev.Key), ActionFileVersionRestored)
|
||||
return AuditEventFileVersionRestored{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, uid, path),
|
||||
Key: ev.Key,
|
||||
}
|
||||
}
|
||||
|
||||
// TagsAdded converts a TagsAdded event to an AuditEventTagsAdded.
|
||||
// Unlike the other file events, User is the executant (who changed the tags), not the
|
||||
// space owner: tags are usually changed by someone other than the owner, and the
|
||||
// owner is still recorded in the Owner field.
|
||||
func TagsAdded(ev events.TagsAdded) AuditEventTagsAdded {
|
||||
iid, path, owner := extractFileDetails(ev.Ref, ev.SpaceOwner)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageTagsAdded(ev.Executant.GetOpaqueId(), ev.Tags, iid), ActionTagsAdded)
|
||||
return AuditEventTagsAdded{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, owner, path),
|
||||
Tags: ev.Tags,
|
||||
}
|
||||
}
|
||||
|
||||
// TagsRemoved converts a TagsRemoved event to an AuditEventTagsRemoved.
|
||||
// User is the executant, as in TagsAdded.
|
||||
func TagsRemoved(ev events.TagsRemoved) AuditEventTagsRemoved {
|
||||
iid, path, owner := extractFileDetails(ev.Ref, ev.SpaceOwner)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageTagsRemoved(ev.Executant.GetOpaqueId(), ev.Tags, iid), ActionTagsRemoved)
|
||||
return AuditEventTagsRemoved{
|
||||
AuditEventFiles: FilesAuditEvent(base, iid, owner, path),
|
||||
Tags: ev.Tags,
|
||||
}
|
||||
}
|
||||
|
||||
// SpacesAuditEvent creates an AuditEventSpaces from the given values
|
||||
func SpacesAuditEvent(base AuditEvent, spaceID string) AuditEventSpaces {
|
||||
return AuditEventSpaces{
|
||||
@@ -343,7 +367,7 @@ func SpacesAuditEvent(base AuditEvent, spaceID string) AuditEventSpaces {
|
||||
func SpaceCreated(ev events.SpaceCreated) AuditEventSpaceCreated {
|
||||
sid := ev.ID.GetOpaqueId()
|
||||
iid, _, owner := extractFileDetails(&provider.Reference{ResourceId: ev.Root}, ev.Owner)
|
||||
base := BasicAuditEvent("", formatTime(ev.MTime), MessageSpaceCreated(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceCreated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.MTime), MessageSpaceCreated(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceCreated)
|
||||
return AuditEventSpaceCreated{
|
||||
AuditEventSpaces: SpacesAuditEvent(base, sid),
|
||||
Owner: owner,
|
||||
@@ -356,7 +380,7 @@ func SpaceCreated(ev events.SpaceCreated) AuditEventSpaceCreated {
|
||||
// SpaceRenamed converts a SpaceRenamed event to an AuditEventSpaceRenamed
|
||||
func SpaceRenamed(ev events.SpaceRenamed) AuditEventSpaceRenamed {
|
||||
sid := ev.ID.GetOpaqueId()
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceRenamed(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceRenamed)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceRenamed(ev.Executant.GetOpaqueId(), sid, ev.Name), ActionSpaceRenamed)
|
||||
return AuditEventSpaceRenamed{
|
||||
AuditEventSpaces: SpacesAuditEvent(base, sid),
|
||||
NewName: ev.Name,
|
||||
@@ -366,7 +390,7 @@ func SpaceRenamed(ev events.SpaceRenamed) AuditEventSpaceRenamed {
|
||||
// SpaceDisabled converts a SpaceDisabled event to an AuditEventSpaceDisabled
|
||||
func SpaceDisabled(ev events.SpaceDisabled) AuditEventSpaceDisabled {
|
||||
sid := ev.ID.GetOpaqueId()
|
||||
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDisabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceDisabled)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDisabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceDisabled)
|
||||
return AuditEventSpaceDisabled{
|
||||
AuditEventSpaces: SpacesAuditEvent(base, sid),
|
||||
}
|
||||
@@ -375,7 +399,7 @@ func SpaceDisabled(ev events.SpaceDisabled) AuditEventSpaceDisabled {
|
||||
// SpaceEnabled converts a SpaceEnabled event to an AuditEventSpaceEnabled
|
||||
func SpaceEnabled(ev events.SpaceEnabled) AuditEventSpaceEnabled {
|
||||
sid := ev.ID.GetOpaqueId()
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceEnabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceEnabled)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceEnabled(ev.Executant.GetOpaqueId(), sid), ActionSpaceEnabled)
|
||||
return AuditEventSpaceEnabled{
|
||||
AuditEventSpaces: SpacesAuditEvent(base, sid),
|
||||
}
|
||||
@@ -384,7 +408,7 @@ func SpaceEnabled(ev events.SpaceEnabled) AuditEventSpaceEnabled {
|
||||
// SpaceDeleted converts a SpaceDeleted event to an AuditEventSpaceDeleted
|
||||
func SpaceDeleted(ev events.SpaceDeleted) AuditEventSpaceDeleted {
|
||||
sid := ev.ID.GetOpaqueId()
|
||||
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDeleted(ev.Executant.GetOpaqueId(), sid, ev.SpaceName), ActionSpaceDeleted)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceDeleted(ev.Executant.GetOpaqueId(), sid, ev.SpaceName), ActionSpaceDeleted)
|
||||
return AuditEventSpaceDeleted{
|
||||
AuditEventSpaces: SpacesAuditEvent(base, sid),
|
||||
}
|
||||
@@ -403,7 +427,7 @@ func SpaceShared(ev events.SpaceShared) AuditEventSpaceShared {
|
||||
sse.GranteeGroupID = ev.GranteeGroupID.OpaqueId
|
||||
grantee = "group:" + ev.GranteeGroupID.OpaqueId
|
||||
}
|
||||
base := BasicAuditEvent("", "", MessageSpaceShared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceShared)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), "", MessageSpaceShared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceShared)
|
||||
sse.AuditEventSpaces = SpacesAuditEvent(base, sid)
|
||||
|
||||
return sse
|
||||
@@ -422,7 +446,7 @@ func SpaceUnshared(ev events.SpaceUnshared) AuditEventSpaceUnshared {
|
||||
sue.GranteeGroupID = ev.GranteeGroupID.OpaqueId
|
||||
grantee = "group:" + ev.GranteeGroupID.OpaqueId
|
||||
}
|
||||
base := BasicAuditEvent("", formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceUnshared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceUnshared)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(utils.TimeToTS(ev.Timestamp)), MessageSpaceUnshared(ev.Executant.GetOpaqueId(), sid, grantee), ActionSpaceUnshared)
|
||||
sue.AuditEventSpaces = SpacesAuditEvent(base, sid)
|
||||
|
||||
return sue
|
||||
@@ -437,7 +461,7 @@ func SpaceUpdated(ev events.SpaceUpdated) AuditEventSpaceUpdated {
|
||||
Opaque: opaqueMap,
|
||||
}
|
||||
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageSpaceUpdated(ev.Executant.GetOpaqueId(), sid, ev.Space.Name, ev.Space.Quota.QuotaMaxBytes, opaqueMap), ActionSpaceUpdated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageSpaceUpdated(ev.Executant.GetOpaqueId(), sid, ev.Space.Name, ev.Space.Quota.QuotaMaxBytes, opaqueMap), ActionSpaceUpdated)
|
||||
sue.AuditEventSpaces = SpacesAuditEvent(base, sid)
|
||||
|
||||
return sue
|
||||
@@ -445,7 +469,7 @@ func SpaceUpdated(ev events.SpaceUpdated) AuditEventSpaceUpdated {
|
||||
|
||||
// UserCreated converts a UserCreated event to an AuditEventUserCreated
|
||||
func UserCreated(ev events.UserCreated) AuditEventUserCreated {
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageUserCreated(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserCreated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageUserCreated(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserCreated)
|
||||
return AuditEventUserCreated{
|
||||
AuditEvent: base,
|
||||
UserID: ev.UserID,
|
||||
@@ -454,7 +478,7 @@ func UserCreated(ev events.UserCreated) AuditEventUserCreated {
|
||||
|
||||
// UserDeleted converts a UserDeleted event to an AuditEventUserDeleted
|
||||
func UserDeleted(ev events.UserDeleted) AuditEventUserDeleted {
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageUserDeleted(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserDeleted)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageUserDeleted(ev.Executant.GetOpaqueId(), ev.UserID), ActionUserDeleted)
|
||||
return AuditEventUserDeleted{
|
||||
AuditEvent: base,
|
||||
UserID: ev.UserID,
|
||||
@@ -464,7 +488,7 @@ func UserDeleted(ev events.UserDeleted) AuditEventUserDeleted {
|
||||
// UserFeatureChanged converts a UserFeatureChanged event to an AuditEventUserFeatureChanged
|
||||
func UserFeatureChanged(ev events.UserFeatureChanged) AuditEventUserFeatureChanged {
|
||||
msg := MessageUserFeatureChanged(ev.Executant.GetOpaqueId(), ev.UserID, ev.Features)
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionUserFeatureChanged)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionUserFeatureChanged)
|
||||
return AuditEventUserFeatureChanged{
|
||||
AuditEvent: base,
|
||||
UserID: ev.UserID,
|
||||
@@ -474,7 +498,7 @@ func UserFeatureChanged(ev events.UserFeatureChanged) AuditEventUserFeatureChang
|
||||
|
||||
// GroupCreated converts a GroupCreated event to an AuditEventGroupCreated
|
||||
func GroupCreated(ev events.GroupCreated) AuditEventGroupCreated {
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageGroupCreated(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupCreated)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageGroupCreated(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupCreated)
|
||||
return AuditEventGroupCreated{
|
||||
AuditEvent: base,
|
||||
GroupID: ev.GroupID,
|
||||
@@ -483,7 +507,7 @@ func GroupCreated(ev events.GroupCreated) AuditEventGroupCreated {
|
||||
|
||||
// GroupDeleted converts a GroupDeleted event to an AuditEventGroupDeleted
|
||||
func GroupDeleted(ev events.GroupDeleted) AuditEventGroupDeleted {
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), MessageGroupDeleted(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupDeleted)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), MessageGroupDeleted(ev.Executant.GetOpaqueId(), ev.GroupID), ActionGroupDeleted)
|
||||
return AuditEventGroupDeleted{
|
||||
AuditEvent: base,
|
||||
GroupID: ev.GroupID,
|
||||
@@ -492,8 +516,8 @@ func GroupDeleted(ev events.GroupDeleted) AuditEventGroupDeleted {
|
||||
|
||||
// GroupMemberAdded converts a GroupMemberAdded event to an AuditEventGroupMemberAdded
|
||||
func GroupMemberAdded(ev events.GroupMemberAdded) AuditEventGroupMemberAdded {
|
||||
msg := MessageGroupMemberAdded(ev.Executant.GetOpaqueId(), ev.GroupID, ev.UserID)
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionGroupMemberAdded)
|
||||
msg := MessageGroupMemberAdded(ev.Executant.GetOpaqueId(), ev.UserID, ev.GroupID)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionGroupMemberAdded)
|
||||
return AuditEventGroupMemberAdded{
|
||||
AuditEvent: base,
|
||||
GroupID: ev.GroupID,
|
||||
@@ -503,8 +527,8 @@ func GroupMemberAdded(ev events.GroupMemberAdded) AuditEventGroupMemberAdded {
|
||||
|
||||
// GroupMemberRemoved converts a GroupMemberRemoved event to an AuditEventGroupMemberRemove
|
||||
func GroupMemberRemoved(ev events.GroupMemberRemoved) AuditEventGroupMemberRemoved {
|
||||
msg := MessageGroupMemberRemoved(ev.Executant.GetOpaqueId(), ev.GroupID, ev.UserID)
|
||||
base := BasicAuditEvent("", formatTime(ev.Timestamp), msg, ActionGroupMemberRemoved)
|
||||
msg := MessageGroupMemberRemoved(ev.Executant.GetOpaqueId(), ev.UserID, ev.GroupID)
|
||||
base := BasicAuditEvent(ev.Executant.GetOpaqueId(), formatTime(ev.Timestamp), msg, ActionGroupMemberRemoved)
|
||||
return AuditEventGroupMemberRemoved{
|
||||
AuditEvent: base,
|
||||
GroupID: ev.GroupID,
|
||||
|
||||
@@ -24,6 +24,8 @@ func RegisteredEvents() []events.Unmarshaller {
|
||||
events.ItemPurged{},
|
||||
events.ItemRestored{},
|
||||
events.FileVersionRestored{},
|
||||
events.TagsAdded{},
|
||||
events.TagsRemoved{},
|
||||
events.SpaceCreated{},
|
||||
events.SpaceRenamed{},
|
||||
events.SpaceEnabled{},
|
||||
|
||||
@@ -32,6 +32,8 @@ const (
|
||||
ActionFilePurged = "file_trash_delete"
|
||||
ActionFileRestored = "file_trash_restore"
|
||||
ActionFileVersionRestored = "file_version_restore"
|
||||
ActionTagsAdded = "file_tags_add"
|
||||
ActionTagsRemoved = "file_tags_remove"
|
||||
|
||||
// Spaces
|
||||
ActionSpaceCreated = "space_created"
|
||||
@@ -124,7 +126,17 @@ func MessageFileRead(executant, item string) string {
|
||||
return fmt.Sprintf("user '%s' read file '%s'", executant, item)
|
||||
}
|
||||
|
||||
// MessageFileTrashed returns the human-readable string that describes the action
|
||||
// MessageTagsAdded returns a human readable string that describes the action
|
||||
func MessageTagsAdded(executant, tags, item string) string {
|
||||
return fmt.Sprintf("user '%s' added tags '%s' to file '%s'", executant, tags, item)
|
||||
}
|
||||
|
||||
// MessageTagsRemoved returns a human readable string that describes the action
|
||||
func MessageTagsRemoved(executant, tags, item string) string {
|
||||
return fmt.Sprintf("user '%s' removed tags '%s' from file '%s'", executant, tags, item)
|
||||
}
|
||||
|
||||
// MessageFileTrashed returns a human readable string that describes the action
|
||||
func MessageFileTrashed(executant, item string) string {
|
||||
return fmt.Sprintf("user '%s' trashed file '%s'", executant, item)
|
||||
}
|
||||
|
||||
@@ -149,6 +149,20 @@ type AuditEventFileRestored struct {
|
||||
OldPath string
|
||||
}
|
||||
|
||||
// AuditEventTagsAdded is the event logged when tags are added to a file or folder
|
||||
type AuditEventTagsAdded struct {
|
||||
AuditEventFiles
|
||||
|
||||
Tags string // the tags the request asked to add, as carried by the event (ev.Tags); some may already have been present
|
||||
}
|
||||
|
||||
// AuditEventTagsRemoved is the event logged when tags are removed from a file or folder
|
||||
type AuditEventTagsRemoved struct {
|
||||
AuditEventFiles
|
||||
|
||||
Tags string // the tags the request asked to remove, as carried by the event (ev.Tags); some may not have been present
|
||||
}
|
||||
|
||||
// AuditEventFileVersionRestored is the event logged when a file version is restored
|
||||
type AuditEventFileVersionRestored struct {
|
||||
AuditEventFiles
|
||||
|
||||
@@ -82,7 +82,7 @@ type LDAPProvider struct {
|
||||
IDP string `yaml:"idp" env:"OCIS_URL;OCIS_OIDC_ISSUER;AUTH_BASIC_IDP_URL" desc:"The identity provider value to set in the userids of the CS3 user objects for users returned by this user provider." introductionVersion:"pre5.0"`
|
||||
DisableUserMechanism string `yaml:"disable_user_mechanism" env:"OCIS_LDAP_DISABLE_USER_MECHANISM;AUTH_BASIC_DISABLE_USER_MECHANISM" desc:"An option to control the behavior for disabling users. Valid options are 'none', 'attribute' and 'group'. If set to 'group', disabling a user via API will add the user to the configured group for disabled users, if set to 'attribute' this will be done in the ldap user entry, if set to 'none' the disable request is not processed." introductionVersion:"pre5.0"`
|
||||
LdapDisabledUsersGroupDN string `yaml:"ldap_disabled_users_group_dn" env:"OCIS_LDAP_DISABLED_USERS_GROUP_DN;AUTH_BASIC_DISABLED_USERS_GROUP_DN" desc:"The distinguished name of the group to which added users will be classified as disabled when 'disable_user_mechanism' is set to 'group'." introductionVersion:"pre5.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance." introductionVersion:"7.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance. Also set 'user_filter'. Without an explicit 'user_filter', this instance allows login for every user in the shared LDAP directory." introductionVersion:"7.0"`
|
||||
UserMemberAttribute string `yaml:"user_member_attribute" env:"OCIS_LDAP_USER_MEMBER_ATTRIBUTE" desc:"LDAP attribute that marks a user as a member of an instance." introductionVersion:"7.0"`
|
||||
UserGuestAttribute string `yaml:"user_guest_attribute" env:"OCIS_LDAP_USER_GUEST_ATTRIBUTE" desc:"LDAP attribute that marks a user as a guest of an instance." introductionVersion:"7.0"`
|
||||
UserSchema LDAPUserSchema `yaml:"user_schema"`
|
||||
|
||||
@@ -42,5 +42,9 @@ func Validate(cfg *config.Config) error {
|
||||
return shared.MissingLDAPBindPassword(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.AuthProvider == "ldap" && cfg.AuthProviders.LDAP.MasterID != "" && cfg.AuthProviders.LDAP.UserFilter == "" {
|
||||
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-basic/pkg/config"
|
||||
)
|
||||
|
||||
func TestValidateMasterIDRequiresUserFilter(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "auth-basic"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
AuthProvider: "ldap",
|
||||
AuthProviders: config.AuthProviders{
|
||||
LDAP: config.LDAPProvider{
|
||||
BindPassword: "secret",
|
||||
MasterID: "master-1",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestValidateMasterIDWithUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "auth-basic"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
AuthProvider: "ldap",
|
||||
AuthProviders: config.AuthProviders{
|
||||
LDAP: config.LDAPProvider{
|
||||
BindPassword: "secret",
|
||||
MasterID: "master-1",
|
||||
UserFilter: "(ownCloudMemberOf=instance-1)",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestValidateNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "auth-basic"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
AuthProvider: "ldap",
|
||||
AuthProviders: config.AuthProviders{
|
||||
LDAP: config.LDAPProvider{
|
||||
BindPassword: "secret",
|
||||
MasterID: "",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ type Store struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;COLLABORATION_STORE_TTL" desc:"Time to live for events in the store. Defaults to '30m' (30 minutes). See the Environment Variable Types description for more details." introductionVersion:"7.0.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;COLLABORATION_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.0.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;COLLABORATION_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.0.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;COLLABORATION_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;COLLABORATION_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;COLLABORATION_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;COLLABORATION_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;COLLABORATION_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;COLLABORATION_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -45,9 +45,9 @@ type Store struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;EVENTHISTORY_STORE_TTL" desc:"Time to live for events in the store. Defaults to '336h' (2 weeks). See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;EVENTHISTORY_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;EVENTHISTORY_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;EVENTHISTORY_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;EVENTHISTORY_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;EVENTHISTORY_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;EVENTHISTORY_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;EVENTHISTORY_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;EVENTHISTORY_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// Events combines the configuration options for the event bus.
|
||||
|
||||
@@ -150,9 +150,9 @@ type OCS struct {
|
||||
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"9.0.0"`
|
||||
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"9.0.0"`
|
||||
|
||||
CacheWarmupDriver string `yaml:"cache_warmup_driver,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
CacheWarmupDrivers CacheWarmupDrivers `yaml:"cache_warmup_drivers,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
@@ -215,7 +215,6 @@ type Validation struct {
|
||||
|
||||
// MFAConfig configures multi factor multifactor authentication
|
||||
type MFAConfig struct {
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_MFA_ENABLED" desc:"Set to true to enable multi factor authentication. See the documentation for more details." introductionVersion:"7.3.0"`
|
||||
AuthLevelNames []string `yaml:"auth_level_names" env:"OCIS_MFA_AUTH_LEVEL_NAMES" desc:"This authentication level name indicates that multi-factor authentication was performed. The name must match the ACR claim in the access token received. Note: If multiple names are required, use a comma-separated list. The front-end service will use the first name in the list when requesting multi-factor authentication (MFA)." introductionVersion:"7.3.0"`
|
||||
SessionDuration int `yaml:"session_duration" env:"OCIS_MFA_SESSION_DURATION" desc:"The duration in seconds that a multi-factor authentication session is valid. After this time the user will be prompted to re-authenticate. Defaults to 3600 (1 hour)." introductionVersion:"8.1.0"`
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_MFA_ENABLED" desc:"Set to true to enable multi factor authentication. See the documentation for more details." introductionVersion:"7.3.0"`
|
||||
AuthLevelNames []string `yaml:"auth_level_names" env:"OCIS_MFA_AUTH_LEVEL_NAMES" desc:"This authentication level name indicates that multi-factor authentication was performed. The name must match the ACR claim in the access token received. Note: If multiple names are required, use a comma-separated list. The front-end service will use the first name in the list when requesting multi-factor authentication (MFA)." introductionVersion:"7.3.0"`
|
||||
}
|
||||
@@ -144,8 +144,7 @@ func DefaultConfig() *config.Config {
|
||||
MaxTagLength: 100,
|
||||
},
|
||||
MultiFactorAuthentication: config.MFAConfig{
|
||||
AuthLevelNames: []string{"advanced"},
|
||||
SessionDuration: 3600,
|
||||
AuthLevelNames: []string{"advanced"},
|
||||
},
|
||||
DefaultVaultShareExpirationDays: 30,
|
||||
}
|
||||
|
||||
@@ -361,9 +361,8 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
|
||||
},
|
||||
"auth": map[string]interface{}{
|
||||
"mfa": map[string]interface{}{
|
||||
"enabled": cfg.MultiFactorAuthentication.Enabled,
|
||||
"levelnames": cfg.MultiFactorAuthentication.AuthLevelNames,
|
||||
"session_duration": cfg.MultiFactorAuthentication.SessionDuration,
|
||||
"enabled": cfg.MultiFactorAuthentication.Enabled,
|
||||
"levelnames": cfg.MultiFactorAuthentication.AuthLevelNames,
|
||||
},
|
||||
},
|
||||
"vault": map[string]interface{}{
|
||||
|
||||
@@ -88,14 +88,14 @@ type StorageRegistry struct {
|
||||
|
||||
// Cache holds cache config
|
||||
type Cache struct {
|
||||
ProviderCacheStore string `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0"`
|
||||
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheDisablePersistence bool `yaml:"provider_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GATEWAY_PROVIDER_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the provider cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
|
||||
ProviderCacheAuthUsername string `yaml:"provider_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME;GATEWAY_PROVIDER_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
ProviderCacheAuthPassword string `yaml:"provider_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD;GATEWAY_PROVIDER_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
ProviderCacheEnableTLS bool `yaml:"provider_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GATEWAY_PROVIDER_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
ProviderCacheTLSInsecure bool `yaml:"provider_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GATEWAY_PROVIDER_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
ProviderCacheTLSRootCACertificate string `yaml:"provider_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GATEWAY_PROVIDER_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
ProviderCacheStore string `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE;GATEWAY_PROVIDER_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"9.0" deprecationInfo:"The global variable OCIS_CACHE_DATABASE is deprecated and will be removed in a future release. Please use local variable GATEWAY_PROVIDER_CACHE_DATABASE instead."`
|
||||
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
ProviderCacheDisablePersistence bool `yaml:"provider_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GATEWAY_PROVIDER_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the provider cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
|
||||
ProviderCacheAuthUsername string `yaml:"provider_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME;GATEWAY_PROVIDER_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
ProviderCacheAuthPassword string `yaml:"provider_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD;GATEWAY_PROVIDER_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
ProviderCacheEnableTLS bool `yaml:"provider_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GATEWAY_PROVIDER_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
ProviderCacheTLSInsecure bool `yaml:"provider_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GATEWAY_PROVIDER_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
ProviderCacheTLSRootCACertificate string `yaml:"provider_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GATEWAY_PROVIDER_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -12,7 +12,7 @@ type Cache struct {
|
||||
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;GRAPH_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;GRAPH_CACHE_AUTH_USERNAME" desc:"The username to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;GRAPH_CACHE_AUTH_PASSWORD" desc:"The password to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GRAPH_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GRAPH_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GRAPH_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;GRAPH_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;GRAPH_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;GRAPH_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -125,7 +125,7 @@ type LDAP struct {
|
||||
InstanceMapperIDAttribute string `yaml:"instance_mapper_id_attribute" env:"OCIS_LDAP_INSTANCE_MAPPER_ID_ATTRIBUTE" desc:"LDAP Attribute of the instance ID. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
CrossInstanceReferenceTemplate string `yaml:"cross_instance_reference_template" env:"OCIS_LDAP_CROSS_INSTANCE_REFERENCE_TEMPLATE" desc:"Template for the users unique reference across oCIS instances. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceURLTemplate string `yaml:"instance_url_template" env:"OCIS_LDAP_INSTANCE_URL_TEMPLATE" desc:"Template for the instance URL. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.3.0"`
|
||||
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// LDAPEducationConfig represents the LDAP configuration for education related resources
|
||||
@@ -194,13 +194,13 @@ type ServiceAccount struct {
|
||||
|
||||
type Validation struct {
|
||||
MaxTagLength int `yaml:"max_tag_length" env:"OCIS_MAX_TAG_LENGTH" desc:"Define the maximum tag length. Defaults to 100 if not set. Set to 0 to not limit the tag length. Changes only impact the validation of new tags." introductionVersion:"7.2.0"`
|
||||
MaxImageFileSize string `yaml:"max_image_file_size" env:"GRAPH_MAX_IMAGE_FILE_SIZE" desc:"The maximum file size of an image which can be set as a space image. Must be less than or equal to 'THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE' of the thumbnails service, otherwise images between the two values are accepted but cannot be rendered. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB], example: 2GB. Set to 0 to not limit the file size." introductionVersion:"8.3.0"`
|
||||
MaxImageFileSize string `yaml:"max_image_file_size" env:"GRAPH_MAX_IMAGE_FILE_SIZE" desc:"The maximum file size of an image which can be set as a space image. Must be less than or equal to 'THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE' of the thumbnails service, otherwise images between the two values are accepted but cannot be rendered. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB], example: 2GB. Set to 0 to not limit the file size." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// MultiInstanceConfig holds configuration for multi-instance-ocis
|
||||
type MultiInstanceConfig struct {
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_MULTI_INSTANCE_ENABLED" desc:"Enable multiple instances of Infinite Scale." introductionVersion:"8.0.0"`
|
||||
InstanceID string `yaml:"instanceid" env:"OCIS_MULTI_INSTANCE_INSTANCEID" desc:"The unique ID of this instance." introductionVersion:"8.0.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master ID that grants access to all instances. Users with this ID in their memberOf or guestOf claims can access any instance. Leave empty to disable." introductionVersion:"8.1.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master ID that grants access to all instances. Users with this ID in their memberOf or guestOf claims can access any instance. Leave empty to disable. Also set 'OCIS_LDAP_USER_FILTER'. Without an explicit user filter, this instance resolves every user in the shared LDAP directory." introductionVersion:"8.1.0"`
|
||||
QueryRegexp string `yaml:"query_regexp" env:"OCIS_MULTI_INSTANCE_QUERY_TEMPLATE" desc:"The regular expression extracting username and instancename from a user provided search." introductionVersion:"8.0.0"`
|
||||
}
|
||||
@@ -98,6 +98,10 @@ func validateLDAPSettings(cfg *config.Config) error {
|
||||
return shared.MissingLDAPBindPassword(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.MultiInstance.MasterID != "" && cfg.Identity.LDAP.UserFilter == "" {
|
||||
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
|
||||
}
|
||||
|
||||
// ensure that "GroupBaseDN" is below "GroupBaseDN"
|
||||
if cfg.Identity.LDAP.WriteEnabled && cfg.Identity.LDAP.GroupCreateBaseDN != cfg.Identity.LDAP.GroupBaseDN {
|
||||
baseDN, err := ldap.ParseDN(cfg.Identity.LDAP.GroupBaseDN)
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
|
||||
)
|
||||
|
||||
func TestValidateLDAPSettingsMasterIDRequiresUserFilter(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "graph"},
|
||||
Identity: config.Identity{
|
||||
LDAP: config.LDAP{
|
||||
BindPassword: "secret",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
MultiInstance: config.MultiInstanceConfig{
|
||||
MasterID: "master-1",
|
||||
},
|
||||
}
|
||||
|
||||
err := validateLDAPSettings(cfg)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestValidateLDAPSettingsMasterIDWithUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "graph"},
|
||||
Identity: config.Identity{
|
||||
LDAP: config.LDAP{
|
||||
BindPassword: "secret",
|
||||
UserFilter: "(ownCloudMemberOf=instance-1)",
|
||||
},
|
||||
},
|
||||
MultiInstance: config.MultiInstanceConfig{
|
||||
MasterID: "master-1",
|
||||
},
|
||||
}
|
||||
|
||||
err := validateLDAPSettings(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestValidateLDAPSettingsNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "graph"},
|
||||
Identity: config.Identity{
|
||||
LDAP: config.LDAP{
|
||||
BindPassword: "secret",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
MultiInstance: config.MultiInstanceConfig{
|
||||
MasterID: "",
|
||||
},
|
||||
}
|
||||
|
||||
err := validateLDAPSettings(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/owncloud/reva/v2/pkg/events"
|
||||
"github.com/owncloud/reva/v2/pkg/storagespace"
|
||||
"github.com/owncloud/reva/v2/pkg/tags"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
"go-micro.dev/v4/metadata"
|
||||
)
|
||||
|
||||
@@ -141,6 +142,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if g.eventsPublisher != nil {
|
||||
ev := events.TagsAdded{
|
||||
// The tags as requested, including any that were already present.
|
||||
Tags: strings.Join(assignment.Tags, ","),
|
||||
Ref: &provider.Reference{
|
||||
ResourceId: &rid,
|
||||
@@ -148,6 +150,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
},
|
||||
SpaceOwner: sres.Info.Owner,
|
||||
Executant: revaCtx.ContextMustGetUser(r.Context()).Id,
|
||||
Timestamp: utils.TSNow(),
|
||||
}
|
||||
if err := events.Publish(r.Context(), g.eventsPublisher, ev); err != nil {
|
||||
g.logger.Error().Err(err).Msg("Failed to publish TagsAdded event")
|
||||
@@ -239,6 +242,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
|
||||
// Always publish the event so the search index gets updated,
|
||||
// even if the tag was already absent from file metadata.
|
||||
ev := events.TagsRemoved{
|
||||
// The tags as requested, including any that were not present.
|
||||
Tags: strings.Join(unassignment.Tags, ","),
|
||||
Ref: &provider.Reference{
|
||||
ResourceId: &rid,
|
||||
@@ -246,6 +250,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
|
||||
},
|
||||
SpaceOwner: sres.Info.Owner,
|
||||
Executant: revaCtx.ContextMustGetUser(ctx).Id,
|
||||
Timestamp: utils.TSNow(),
|
||||
}
|
||||
if g.publishTagsRemoved(ctx, client, ev, tagsChanged, currentTags) != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
@@ -79,7 +79,7 @@ type LDAPDriver struct {
|
||||
UserObjectClass string `yaml:"user_object_class" env:"OCIS_LDAP_USER_OBJECTCLASS;GROUPS_LDAP_USER_OBJECTCLASS" desc:"The object class to use for users in the default user search filter ('inetOrgPerson')." introductionVersion:"pre5.0"`
|
||||
GroupObjectClass string `yaml:"group_object_class" env:"OCIS_LDAP_GROUP_OBJECTCLASS;GROUPS_LDAP_GROUP_OBJECTCLASS" desc:"The object class to use for groups in the default group search filter ('groupOfNames')." introductionVersion:"pre5.0"`
|
||||
IDP string `yaml:"idp" env:"OCIS_URL;OCIS_OIDC_ISSUER;GROUPS_IDP_URL" desc:"The identity provider value to set in the group IDs of the CS3 group objects for groups returned by this group provider." introductionVersion:"pre5.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance." introductionVersion:"7.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master instance ID for multi-instance setups. When set, LDAP user filters are enhanced to also match users belonging to the master instance. Also set 'user_filter'. Without an explicit 'user_filter', this instance resolves every user in the shared LDAP directory." introductionVersion:"7.0"`
|
||||
UserMemberAttribute string `yaml:"user_member_attribute" env:"OCIS_LDAP_USER_MEMBER_ATTRIBUTE" desc:"LDAP attribute that marks a user as a member of an instance." introductionVersion:"7.0"`
|
||||
UserGuestAttribute string `yaml:"user_guest_attribute" env:"OCIS_LDAP_USER_GUEST_ATTRIBUTE" desc:"LDAP attribute that marks a user as a guest of an instance." introductionVersion:"7.0"`
|
||||
UserSchema LDAPUserSchema `yaml:"user_schema"`
|
||||
|
||||
@@ -42,5 +42,9 @@ func Validate(cfg *config.Config) error {
|
||||
return shared.MissingLDAPBindPassword(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.Driver == "ldap" && cfg.Drivers.LDAP.MasterID != "" && cfg.Drivers.LDAP.UserFilter == "" {
|
||||
return shared.MissingLDAPUserFilterForMasterID(cfg.Service.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/groups/pkg/config"
|
||||
)
|
||||
|
||||
func TestValidateMasterIDRequiresUserFilter(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "groups"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
Driver: "ldap",
|
||||
Drivers: config.Drivers{
|
||||
LDAP: config.LDAPDriver{
|
||||
BindPassword: "secret",
|
||||
MasterID: "master-1",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestValidateMasterIDWithUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "groups"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
Driver: "ldap",
|
||||
Drivers: config.Drivers{
|
||||
LDAP: config.LDAPDriver{
|
||||
BindPassword: "secret",
|
||||
MasterID: "master-1",
|
||||
UserFilter: "(ownCloudMemberOf=instance-1)",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestValidateNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Service: config.Service{Name: "groups"},
|
||||
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
||||
Driver: "ldap",
|
||||
Drivers: config.Drivers{
|
||||
LDAP: config.LDAPDriver{
|
||||
BindPassword: "secret",
|
||||
MasterID: "",
|
||||
UserFilter: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := Validate(cfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -32,5 +32,5 @@ type Keycloak struct {
|
||||
ClientRealm string `yaml:"client_realm" env:"OCIS_KEYCLOAK_CLIENT_REALM;INVITATIONS_KEYCLOAK_CLIENT_REALM" desc:"The realm the client is defined in." introductionVersion:"pre5.0"`
|
||||
UserRealm string `yaml:"user_realm" env:"OCIS_KEYCLOAK_USER_REALM;INVITATIONS_KEYCLOAK_USER_REALM" desc:"The realm users are defined." introductionVersion:"pre5.0"`
|
||||
InsecureSkipVerify bool `yaml:"insecure_skip_verify" env:"OCIS_KEYCLOAK_INSECURE_SKIP_VERIFY;INVITATIONS_KEYCLOAK_INSECURE_SKIP_VERIFY" desc:"Disable TLS certificate validation for Keycloak connections. Do not set this in production environments." introductionVersion:"pre5.0"`
|
||||
ExecuteActions []string `yaml:"execute_actions" env:"INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS" desc:"A comma-separated list of Keycloak required actions sent to invited guests via the execute-actions email. Values are passed to Keycloak as-is. Defaults to 'UPDATE_PASSWORD,VERIFY_EMAIL'. See the Environment Variable Types description for more details." introductionVersion:"8.3.0"`
|
||||
ExecuteActions []string `yaml:"execute_actions" env:"INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS" desc:"A comma-separated list of Keycloak required actions sent to invited guests via the execute-actions email. Values are passed to Keycloak as-is. Defaults to 'UPDATE_PASSWORD,VERIFY_EMAIL'. See the Environment Variable Types description for more details." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
SHELL := bash
|
||||
NAME := llm
|
||||
|
||||
include ../../.make/recursion.mk
|
||||
|
||||
############ tooling ############
|
||||
ifneq (, $(shell command -v go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI
|
||||
include ../../.bingo/Variables.mk
|
||||
endif
|
||||
|
||||
############ go tooling ############
|
||||
include ../../.make/go.mk
|
||||
|
||||
############ release ############
|
||||
include ../../.make/release.mk
|
||||
|
||||
############ docs generate ############
|
||||
include ../../.make/docs.mk
|
||||
|
||||
.PHONY: docs-generate
|
||||
docs-generate: config-docs-generate
|
||||
|
||||
############ generate ############
|
||||
include ../../.make/generate.mk
|
||||
|
||||
.PHONY: ci-go-generate
|
||||
ci-go-generate: # CI runs ci-node-generate automatically before this target
|
||||
|
||||
.PHONY: ci-node-generate
|
||||
ci-node-generate:
|
||||
|
||||
############ licenses ############
|
||||
.PHONY: ci-node-check-licenses
|
||||
ci-node-check-licenses:
|
||||
|
||||
.PHONY: ci-node-save-licenses
|
||||
ci-node-save-licenses:
|
||||
@@ -0,0 +1,46 @@
|
||||
# LLM Proxy
|
||||
|
||||
The `llm` service proxies chat-completion requests from oCIS AI web
|
||||
extensions to a configured, OpenAI-compatible LLM endpoint, so extensions
|
||||
never see the upstream API key.
|
||||
|
||||
The public endpoint is reached through the `proxy` service at
|
||||
`POST /graph/v1beta1/extensions/org.libregraph/llm/chat/completions`.
|
||||
|
||||
`LLM_ENDPOINT` is a **required** environment variable; the service will not
|
||||
start without it. `llm` is an **opt-in** service — it must be explicitly
|
||||
enabled via `OCIS_ADD_RUN_SERVICES=llm` (the same way `antivirus`,
|
||||
`auth-app`, and `invitations` are enabled) for `ocis server` to run it.
|
||||
|
||||
## Limitations
|
||||
|
||||
Streaming responses are not supported. Requests with `"stream": true` are
|
||||
rejected with `400 Bad Request`; the full completion is always returned as a
|
||||
single JSON response.
|
||||
|
||||
## Auth
|
||||
|
||||
The `llm` service does not authenticate callers itself. It trusts the
|
||||
`proxy` service, which validates the caller's OIDC token and forwards a
|
||||
signed identity via the `X-Access-Token` header before the request reaches
|
||||
`llm`.
|
||||
|
||||
## Rate limiting
|
||||
|
||||
Requests are rate-limited per user using a sliding window backed by the
|
||||
configured store (`LLM_STORE`, defaults to `nats-js-kv`), so the limit is
|
||||
shared across replicas when `llm` runs multiple instances. Configure the
|
||||
window and request ceiling with `LLM_RATE_LIMIT_WINDOW` /
|
||||
`LLM_RATE_LIMIT_MAX_REQUESTS`.
|
||||
|
||||
Each request is stored as its own record, so concurrent replicas never
|
||||
overwrite each other's counts; under heavy concurrency at the limit a
|
||||
request may be rejected, but the limit is never exceeded. Only requests
|
||||
that are forwarded to the LLM count. Expiry is handled by the store, so
|
||||
`LLM_STORE_TTL` must not be shorter than `LLM_RATE_LIMIT_WINDOW` (the
|
||||
service refuses to start otherwise).
|
||||
|
||||
## Configuration
|
||||
|
||||
See the `LLM_*` environment variables in `pkg/config` for the upstream
|
||||
endpoint, API key, model override, timeout, and body-size limit.
|
||||
@@ -0,0 +1,20 @@
|
||||
// services/llm/cmd/llm/main.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// services/llm/pkg/command/health.go
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/logging"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Health is the entrypoint for the health command.
|
||||
func Health(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "health",
|
||||
Usage: "check health status",
|
||||
Category: "info",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnError(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf("http://%s/healthz", cfg.Debug.Addr))
|
||||
if err != nil {
|
||||
logger.Fatal().Err(err).Msg("Failed to request health check")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
logger.Fatal().Int("code", resp.StatusCode).Msg("Health seems to be in bad state")
|
||||
}
|
||||
|
||||
logger.Debug().Int("code", resp.StatusCode).Msg("Health got a good state")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// services/llm/pkg/command/root.go
|
||||
package command
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// GetCommands provides all commands for this service.
|
||||
func GetCommands(cfg *config.Config) cli.Commands {
|
||||
return []*cli.Command{
|
||||
Server(cfg),
|
||||
Health(cfg),
|
||||
Version(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
// Execute is the entry point for the ocis llm command.
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "llm",
|
||||
Usage: "serve the LLM proxy for oCIS AI extensions",
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// services/llm/pkg/command/server.go
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/signal"
|
||||
|
||||
"github.com/owncloud/reva/v2/pkg/store"
|
||||
"github.com/urfave/cli/v2"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/runner"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/logging"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/metrics"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/ratelimit"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/server/http"
|
||||
)
|
||||
|
||||
// Server is the entrypoint for the server command.
|
||||
func Server(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "server",
|
||||
Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
|
||||
Category: "server",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
tracerProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to initialize tracer")
|
||||
return err
|
||||
}
|
||||
|
||||
var cancel context.CancelFunc
|
||||
if cfg.Context == nil {
|
||||
cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
|
||||
defer cancel()
|
||||
}
|
||||
ctx := cfg.Context
|
||||
|
||||
m := metrics.New()
|
||||
m.BuildInfo.WithLabelValues(version.GetString()).Set(1)
|
||||
|
||||
rateLimitStore := store.Create(
|
||||
store.Store(cfg.Store.Store),
|
||||
store.TTL(cfg.Store.TTL),
|
||||
microstore.Nodes(cfg.Store.Nodes...),
|
||||
microstore.Database(cfg.Store.Database),
|
||||
microstore.Table(cfg.Store.Table),
|
||||
store.Authentication(cfg.Store.AuthUsername, cfg.Store.AuthPassword),
|
||||
store.TLS(cfg.Store.EnableTLS, cfg.Store.TLSInsecure, cfg.Store.TLSRootCACertificate),
|
||||
)
|
||||
limiter := ratelimit.New(rateLimitStore, cfg.RateLimit.Window, cfg.RateLimit.MaxRequests)
|
||||
|
||||
gr := runner.NewGroup()
|
||||
{
|
||||
httpServer, err := http.Server(
|
||||
http.Logger(logger),
|
||||
http.Context(ctx),
|
||||
http.Config(cfg),
|
||||
http.Limiter(limiter),
|
||||
http.TraceProvider(tracerProvider),
|
||||
)
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", "http").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
gr.Add(runner.NewGoMicroHttpServerRunner(cfg.Service.Name+".http", httpServer))
|
||||
}
|
||||
|
||||
{
|
||||
debugServer, err := debug.Server(
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("transport", "debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer))
|
||||
}
|
||||
|
||||
logger.Warn().Msgf("starting service %s", cfg.Service.Name)
|
||||
grResults := gr.Run(ctx)
|
||||
|
||||
if err := runner.ProcessResults(grResults); err != nil {
|
||||
logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name)
|
||||
return err
|
||||
}
|
||||
logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// services/llm/pkg/command/version.go
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Version prints the service versions of all running instances.
|
||||
func Version(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "print the version of this binary and the running service instances",
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("Version: " + version.GetString())
|
||||
fmt.Printf("Compiled: %s\n", version.Compiled())
|
||||
fmt.Println("")
|
||||
|
||||
reg := registry.GetRegistry()
|
||||
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
|
||||
return err
|
||||
}
|
||||
|
||||
if len(services) == 0 {
|
||||
fmt.Println("No running " + cfg.Service.Name + " service found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
table := tablewriter.NewTable(os.Stdout)
|
||||
table.Header("Version", "Address", "Id")
|
||||
for _, s := range services {
|
||||
for _, n := range s.Nodes {
|
||||
table.Append([]string{s.Version, n.Address, n.Id})
|
||||
}
|
||||
}
|
||||
table.Render()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
|
||||
)
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
|
||||
TokenManager *TokenManager `yaml:"token_manager"`
|
||||
|
||||
Store Store `yaml:"store"`
|
||||
RateLimit RateLimit `yaml:"rate_limit"`
|
||||
LLM LLM `yaml:"llm"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
// TokenManager is the config for using the reva token manager.
|
||||
type TokenManager struct {
|
||||
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;LLM_JWT_SECRET" desc:"The secret to mint and validate jwt tokens." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
// Store configures the store used for per-user rate limiting.
|
||||
type Store struct {
|
||||
Store string `yaml:"store" env:"OCIS_PERSISTENT_STORE;LLM_STORE" desc:"The type of the store. Supported values are: 'memory', 'nats-js-kv', 'redis-sentinel', 'noop'. See the text description for details." introductionVersion:"%%NEXT%%"`
|
||||
Nodes []string `yaml:"nodes" env:"OCIS_PERSISTENT_STORE_NODES;LLM_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
Database string `yaml:"database" env:"LLM_STORE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"%%NEXT%%"`
|
||||
Table string `yaml:"table" env:"LLM_STORE_TABLE" desc:"The database table the store should use." introductionVersion:"%%NEXT%%"`
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;LLM_STORE_TTL" desc:"Time to live for rate-limit entries in the store. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;LLM_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"%%NEXT%%"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;LLM_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"%%NEXT%%"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;LLM_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"%%NEXT%%"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;LLM_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"%%NEXT%%"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;LLM_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
// RateLimit configures the per-user request rate limit.
|
||||
type RateLimit struct {
|
||||
Window time.Duration `yaml:"window" env:"LLM_RATE_LIMIT_WINDOW" desc:"The sliding time window over which requests per user are counted. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
MaxRequests int `yaml:"max_requests" env:"LLM_RATE_LIMIT_MAX_REQUESTS" desc:"The maximum number of chat completion requests a single user may make within the configured window. Set to 0 to disable rate limiting." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
// LLM configures the upstream OpenAI-compatible LLM endpoint.
|
||||
type LLM struct {
|
||||
Endpoint string `yaml:"endpoint" env:"LLM_ENDPOINT" desc:"The base URL of the OpenAI-compatible LLM endpoint, without the trailing '/chat/completions' path, e.g. 'https://api.openai.com/v1'." introductionVersion:"%%NEXT%%"`
|
||||
APIKey string `yaml:"api_key" env:"LLM_API_KEY" desc:"The API key used to authenticate with the LLM endpoint. Leave empty for LLM endpoints that require no authentication." introductionVersion:"%%NEXT%%" mask:"password"`
|
||||
Model string `yaml:"model" env:"LLM_MODEL" desc:"When set, overrides the 'model' field of every client request, regardless of what the client sent." introductionVersion:"%%NEXT%%"`
|
||||
MaxTokensLimit int `yaml:"max_tokens_limit" env:"LLM_MAX_TOKENS_LIMIT" desc:"Hard ceiling on the 'max_tokens' value forwarded to the LLM. A client-requested value above this is clamped to it." introductionVersion:"%%NEXT%%"`
|
||||
Timeout time.Duration `yaml:"timeout" env:"LLM_TIMEOUT" desc:"Timeout for the upstream LLM request. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
MaxBodyBytes int64 `yaml:"max_body_bytes" env:"LLM_MAX_BODY_BYTES" desc:"Maximum request body size in bytes the service will buffer from a client before rejecting the request." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Debug defines the available debug configuration.
|
||||
type Debug struct {
|
||||
Addr string `yaml:"addr" env:"LLM_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"%%NEXT%%"`
|
||||
Token string `yaml:"token" env:"LLM_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint." introductionVersion:"%%NEXT%%"`
|
||||
Pprof bool `yaml:"pprof" env:"LLM_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling." introductionVersion:"%%NEXT%%"`
|
||||
Zpages bool `yaml:"zpages" env:"LLM_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
)
|
||||
|
||||
// FullDefaultConfig returns the full default config.
|
||||
func FullDefaultConfig() *config.Config {
|
||||
cfg := DefaultConfig()
|
||||
EnsureDefaults(cfg)
|
||||
Sanitize(cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// DefaultConfig returns the default configuration.
|
||||
func DefaultConfig() *config.Config {
|
||||
return &config.Config{
|
||||
Debug: config.Debug{
|
||||
Addr: "127.0.0.1:9346",
|
||||
Token: "",
|
||||
Pprof: false,
|
||||
Zpages: false,
|
||||
},
|
||||
Service: config.Service{
|
||||
Name: "llm",
|
||||
},
|
||||
HTTP: config.HTTP{
|
||||
Addr: "127.0.0.1:9345",
|
||||
Root: "/",
|
||||
Namespace: "com.owncloud.web",
|
||||
CORS: config.CORS{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"POST"},
|
||||
AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With", "X-Request-Id"},
|
||||
AllowCredentials: true,
|
||||
},
|
||||
},
|
||||
Store: config.Store{
|
||||
Store: "nats-js-kv",
|
||||
Nodes: []string{"127.0.0.1:9233"},
|
||||
Database: "llm",
|
||||
Table: "rate-limit",
|
||||
TTL: 10 * time.Minute,
|
||||
},
|
||||
RateLimit: config.RateLimit{
|
||||
Window: time.Minute,
|
||||
MaxRequests: 20,
|
||||
},
|
||||
LLM: config.LLM{
|
||||
MaxTokensLimit: 4096,
|
||||
Timeout: 60 * time.Second,
|
||||
MaxBodyBytes: 6291456, // 6 MiB, covers a 4 MiB image after base64 encoding
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// EnsureDefaults ensures the config contains default values.
|
||||
func EnsureDefaults(cfg *config.Config) {
|
||||
// provide with defaults for shared logging, since we need a valid destination address for "envdecode".
|
||||
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
|
||||
cfg.Log = &config.Log{
|
||||
Level: cfg.Commons.Log.Level,
|
||||
Pretty: cfg.Commons.Log.Pretty,
|
||||
Color: cfg.Commons.Log.Color,
|
||||
File: cfg.Commons.Log.File,
|
||||
}
|
||||
} else if cfg.Log == nil {
|
||||
cfg.Log = &config.Log{}
|
||||
}
|
||||
|
||||
if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil {
|
||||
cfg.TokenManager = &config.TokenManager{
|
||||
JWTSecret: cfg.Commons.TokenManager.JWTSecret,
|
||||
}
|
||||
} else if cfg.TokenManager == nil {
|
||||
cfg.TokenManager = &config.TokenManager{}
|
||||
}
|
||||
|
||||
if cfg.Commons != nil {
|
||||
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
|
||||
}
|
||||
|
||||
// provide with defaults for shared tracing, since we need a valid destination address for "envdecode".
|
||||
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
|
||||
cfg.Tracing = &config.Tracing{
|
||||
Enabled: cfg.Commons.Tracing.Enabled,
|
||||
Type: cfg.Commons.Tracing.Type,
|
||||
Endpoint: cfg.Commons.Tracing.Endpoint,
|
||||
Collector: cfg.Commons.Tracing.Collector,
|
||||
}
|
||||
} else if cfg.Tracing == nil {
|
||||
cfg.Tracing = &config.Tracing{}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize sanitizes the config.
|
||||
func Sanitize(cfg *config.Config) {
|
||||
// sanitize config
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package config
|
||||
|
||||
import "github.com/owncloud/ocis/v2/ocis-pkg/shared"
|
||||
|
||||
// CORS defines the available cors configuration.
|
||||
type CORS struct {
|
||||
AllowedOrigins []string `yaml:"allow_origins" env:"OCIS_CORS_ALLOW_ORIGINS;LLM_CORS_ALLOW_ORIGINS" desc:"A list of allowed CORS origins. See following chapter for more details: *Access-Control-Allow-Origin* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
AllowedMethods []string `yaml:"allow_methods" env:"OCIS_CORS_ALLOW_METHODS;LLM_CORS_ALLOW_METHODS" desc:"A list of allowed CORS methods. See following chapter for more details: *Access-Control-Request-Method* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
AllowedHeaders []string `yaml:"allow_headers" env:"OCIS_CORS_ALLOW_HEADERS;LLM_CORS_ALLOW_HEADERS" desc:"A list of allowed CORS headers. See following chapter for more details: *Access-Control-Request-Headers* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers. See the Environment Variable Types description for more details." introductionVersion:"%%NEXT%%"`
|
||||
AllowCredentials bool `yaml:"allow_credentials" env:"OCIS_CORS_ALLOW_CREDENTIALS;LLM_CORS_ALLOW_CREDENTIALS" desc:"Allow credentials for CORS. See following chapter for more details: *Access-Control-Allow-Credentials* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
// HTTP defines the available http configuration.
|
||||
type HTTP struct {
|
||||
Addr string `yaml:"addr" env:"LLM_HTTP_ADDR" desc:"The bind address of the HTTP service." introductionVersion:"%%NEXT%%"`
|
||||
Namespace string `yaml:"-"`
|
||||
Root string `yaml:"root" env:"LLM_HTTP_ROOT" desc:"Subdirectory that serves as the root for this HTTP service." introductionVersion:"%%NEXT%%"`
|
||||
CORS CORS `yaml:"cors"`
|
||||
TLS shared.HTTPServiceTLS `yaml:"tls"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
// Log defines the available log configuration.
|
||||
type Log struct {
|
||||
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;LLM_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"%%NEXT%%"`
|
||||
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;LLM_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"%%NEXT%%"`
|
||||
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;LLM_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"%%NEXT%%"`
|
||||
File string `mapstructure:"file" env:"OCIS_LOG_FILE;LLM_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config/defaults"
|
||||
)
|
||||
|
||||
// ParseConfig loads configuration from known paths.
|
||||
func ParseConfig(cfg *config.Config) error {
|
||||
err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defaults.EnsureDefaults(cfg)
|
||||
|
||||
// load all env variables relevant to the config in the current context.
|
||||
if err := envdecode.Decode(cfg); err != nil {
|
||||
// no environment variable set for this config is an expected "error"
|
||||
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
defaults.Sanitize(cfg)
|
||||
|
||||
return Validate(cfg)
|
||||
}
|
||||
|
||||
// Validate validates the config.
|
||||
func Validate(cfg *config.Config) error {
|
||||
if cfg.LLM.Endpoint == "" {
|
||||
return errors.New("llm: LLM_ENDPOINT is required")
|
||||
}
|
||||
u, err := url.Parse(cfg.LLM.Endpoint)
|
||||
if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
|
||||
return fmt.Errorf("llm: LLM_ENDPOINT must be an http(s) URL, got %q", cfg.LLM.Endpoint)
|
||||
}
|
||||
if cfg.LLM.MaxTokensLimit <= 0 {
|
||||
return errors.New("llm: LLM_MAX_TOKENS_LIMIT must be greater than 0")
|
||||
}
|
||||
if cfg.LLM.Timeout < 0 {
|
||||
return errors.New("llm: LLM_TIMEOUT must not be negative")
|
||||
}
|
||||
if cfg.RateLimit.Window < 0 || cfg.RateLimit.MaxRequests < 0 {
|
||||
return errors.New("llm: LLM_RATE_LIMIT_WINDOW and LLM_RATE_LIMIT_MAX_REQUESTS must not be negative")
|
||||
}
|
||||
// Rate-limit records are expired by the store; a store TTL shorter than
|
||||
// the window would silently shrink the effective window.
|
||||
if cfg.RateLimit.Window > 0 && cfg.RateLimit.MaxRequests > 0 &&
|
||||
cfg.Store.TTL > 0 && cfg.Store.TTL < cfg.RateLimit.Window {
|
||||
return fmt.Errorf("llm: LLM_STORE_TTL (%s) must not be shorter than LLM_RATE_LIMIT_WINDOW (%s)", cfg.Store.TTL, cfg.RateLimit.Window)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
)
|
||||
|
||||
func TestValidate_RequiresEndpoint(t *testing.T) {
|
||||
cfg := &config.Config{}
|
||||
|
||||
if err := Validate(cfg); err == nil {
|
||||
t.Fatal("expected an error when LLM.Endpoint is empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_PassesWhenEndpointSet(t *testing.T) {
|
||||
cfg := validConfig()
|
||||
|
||||
if err := Validate(cfg); err != nil {
|
||||
t.Fatalf("expected no error when LLM.Endpoint is set, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func validConfig() *config.Config {
|
||||
return &config.Config{
|
||||
LLM: config.LLM{
|
||||
Endpoint: "https://api.example.com/v1",
|
||||
MaxTokensLimit: 4096,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_RejectsInvalidValues(t *testing.T) {
|
||||
tests := map[string]func(*config.Config){
|
||||
"endpoint without scheme": func(c *config.Config) { c.LLM.Endpoint = "api.example.com/v1" },
|
||||
"endpoint wrong scheme": func(c *config.Config) { c.LLM.Endpoint = "ftp://api.example.com" },
|
||||
"zero max tokens": func(c *config.Config) { c.LLM.MaxTokensLimit = 0 },
|
||||
"negative timeout": func(c *config.Config) { c.LLM.Timeout = -time.Second },
|
||||
"negative window": func(c *config.Config) { c.RateLimit.Window = -time.Second },
|
||||
"store ttl below window": func(c *config.Config) {
|
||||
c.RateLimit.Window = time.Hour
|
||||
c.RateLimit.MaxRequests = 10
|
||||
c.Store.TTL = 10 * time.Minute
|
||||
},
|
||||
}
|
||||
for name, mutate := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
cfg := validConfig()
|
||||
mutate(cfg)
|
||||
if err := Validate(cfg); err == nil {
|
||||
t.Fatal("expected a validation error")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_AcceptsStoreTTLCoveringWindow(t *testing.T) {
|
||||
cfg := validConfig()
|
||||
cfg.RateLimit.Window = time.Minute
|
||||
cfg.RateLimit.MaxRequests = 20
|
||||
cfg.Store.TTL = 10 * time.Minute
|
||||
|
||||
if err := Validate(cfg); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package config
|
||||
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string `yaml:"-"`
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package config
|
||||
|
||||
import "github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;LLM_TRACING_ENABLED" desc:"Activates tracing." introductionVersion:"%%NEXT%%"`
|
||||
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;LLM_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger', 'otlp' and '' as of now." introductionVersion:"%%NEXT%%"`
|
||||
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;LLM_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent." introductionVersion:"%%NEXT%%"`
|
||||
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;LLM_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
// Convert Tracing to the tracing package's Config struct.
|
||||
func (t Tracing) Convert() tracing.Config {
|
||||
return tracing.Config{
|
||||
Enabled: t.Enabled,
|
||||
Type: t.Type,
|
||||
Endpoint: t.Endpoint,
|
||||
Collector: t.Collector,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// services/llm/pkg/logging/logging.go
|
||||
package logging
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
)
|
||||
|
||||
// Configure initializes a service-specific logger instance.
|
||||
func Configure(name string, cfg *config.Log) log.Logger {
|
||||
return log.NewLogger(
|
||||
log.Name(name),
|
||||
log.Level(cfg.Level),
|
||||
log.Pretty(cfg.Pretty),
|
||||
log.Color(cfg.Color),
|
||||
log.File(cfg.File),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// services/llm/pkg/metrics/metrics.go
|
||||
package metrics
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
var (
|
||||
// Namespace defines the namespace for the defined metrics.
|
||||
Namespace = "ocis"
|
||||
|
||||
// Subsystem defines the subsystem for the defined metrics.
|
||||
Subsystem = "llm"
|
||||
)
|
||||
|
||||
// Metrics defines the available metrics of this service.
|
||||
type Metrics struct {
|
||||
BuildInfo *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
// New initializes the available metrics.
|
||||
func New() *Metrics {
|
||||
m := &Metrics{
|
||||
BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: Namespace,
|
||||
Subsystem: Subsystem,
|
||||
Name: "build_info",
|
||||
Help: "Build information",
|
||||
}, []string{"version"}),
|
||||
}
|
||||
|
||||
_ = prometheus.Register(m.BuildInfo)
|
||||
|
||||
return m
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// Package ratelimit implements a per-key sliding-window request limiter
|
||||
// backed by a go-micro store.
|
||||
//
|
||||
// The go-micro store interface has no compare-and-swap, so a read-modify-write
|
||||
// of a single shared counter would let concurrent replicas overwrite each
|
||||
// other. Instead every request writes its own record (key "<key>/<unixnano>-<nonce>")
|
||||
// and then counts the key's records within the window. A request that finds
|
||||
// itself over the limit removes its own record and is denied. Because records
|
||||
// are never overwritten, the limit holds across replicas: concurrent requests
|
||||
// at the boundary may all be denied, but more than the maximum are never
|
||||
// admitted.
|
||||
//
|
||||
// Records are expired by the store (a per-write TTL where supported, the
|
||||
// store-wide TTL otherwise, which must therefore be at least the window).
|
||||
package ratelimit
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
microstore "go-micro.dev/v4/store"
|
||||
)
|
||||
|
||||
const separator = "/"
|
||||
|
||||
// Limiter enforces a per-key sliding-window request limit.
|
||||
type Limiter struct {
|
||||
store microstore.Store
|
||||
window time.Duration
|
||||
maxRequests int
|
||||
}
|
||||
|
||||
// New creates a Limiter. If window <= 0 or maxRequests <= 0, the limiter is
|
||||
// disabled and Allow always returns true.
|
||||
func New(store microstore.Store, window time.Duration, maxRequests int) *Limiter {
|
||||
return &Limiter{
|
||||
store: store,
|
||||
window: window,
|
||||
maxRequests: maxRequests,
|
||||
}
|
||||
}
|
||||
|
||||
// Allow registers a request for key and reports whether it is within the
|
||||
// configured limit. A denied request does not count against the limit.
|
||||
func (l *Limiter) Allow(key string) (bool, error) {
|
||||
if l == nil {
|
||||
return true, nil
|
||||
}
|
||||
if l.window <= 0 || l.maxRequests <= 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
nonce := make([]byte, 4)
|
||||
if _, err := rand.Read(nonce); err != nil {
|
||||
return false, err
|
||||
}
|
||||
now := time.Now()
|
||||
recordKey := key + separator + strconv.FormatInt(now.UnixNano(), 10) + "-" + hex.EncodeToString(nonce)
|
||||
|
||||
if err := l.store.Write(µstore.Record{Key: recordKey}, microstore.WriteTTL(l.window)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
prefix := key + separator
|
||||
keys, err := l.store.List(microstore.ListPrefix(prefix))
|
||||
if err != nil {
|
||||
// do not leave an uncounted-for record behind when we cannot decide
|
||||
_ = l.store.Delete(recordKey)
|
||||
return false, err
|
||||
}
|
||||
|
||||
cutoff := now.Add(-l.window).UnixNano()
|
||||
count := 0
|
||||
for _, k := range keys {
|
||||
if recordTime(k, prefix) >= cutoff {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
if count > l.maxRequests {
|
||||
if err := l.store.Delete(recordKey); err != nil && err != microstore.ErrNotFound {
|
||||
return false, err
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// recordTime extracts the request timestamp from a record key. Keys that do
|
||||
// not belong to prefix or are malformed yield 0 (i.e. "expired").
|
||||
func recordTime(recordKey, prefix string) int64 {
|
||||
if !strings.HasPrefix(recordKey, prefix) {
|
||||
return 0
|
||||
}
|
||||
suffix := strings.TrimPrefix(recordKey, prefix)
|
||||
ts, _, _ := strings.Cut(suffix, "-")
|
||||
n, err := strconv.ParseInt(ts, 10, 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return n
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package ratelimit
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
microstore "go-micro.dev/v4/store"
|
||||
)
|
||||
|
||||
func TestLimiter_AllowsUpToMax(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), time.Minute, 3)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !allowed {
|
||||
t.Fatalf("request %d should have been allowed", i+1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_DeniesOverMax(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), time.Minute, 2)
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
if _, err := l.Allow("user-1"); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if allowed {
|
||||
t.Fatal("third request should have been denied")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_TracksUsersIndependently(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), time.Minute, 1)
|
||||
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil || !allowed {
|
||||
t.Fatalf("user-1 first request should be allowed, got allowed=%v err=%v", allowed, err)
|
||||
}
|
||||
|
||||
allowed, err = l.Allow("user-2")
|
||||
if err != nil || !allowed {
|
||||
t.Fatalf("user-2 first request should be allowed, got allowed=%v err=%v", allowed, err)
|
||||
}
|
||||
|
||||
allowed, err = l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if allowed {
|
||||
t.Fatal("user-1 second request should have been denied")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_WindowExpiryClearsOldEntries(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), 10*time.Millisecond, 1)
|
||||
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil || !allowed {
|
||||
t.Fatalf("first request should be allowed, got allowed=%v err=%v", allowed, err)
|
||||
}
|
||||
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
allowed, err = l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !allowed {
|
||||
t.Fatal("request after window expiry should have been allowed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_DisabledWhenMaxRequestsIsZero(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), time.Minute, 0)
|
||||
|
||||
for i := 0; i < 50; i++ {
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !allowed {
|
||||
t.Fatalf("request %d should have been allowed when the limiter is disabled", i+1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Two limiters sharing one store stand in for two llm replicas.
|
||||
func TestLimiter_SharedAcrossReplicas(t *testing.T) {
|
||||
shared := microstore.NewMemoryStore()
|
||||
a := New(shared, time.Minute, 4)
|
||||
b := New(shared, time.Minute, 4)
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
for _, l := range []*Limiter{a, b} {
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil || !allowed {
|
||||
t.Fatalf("request should be allowed, got allowed=%v err=%v", allowed, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, l := range []*Limiter{a, b} {
|
||||
allowed, err := l.Allow("user-1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if allowed {
|
||||
t.Fatal("request beyond the shared limit should have been denied")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_ConcurrentRequestsNeverExceedMax(t *testing.T) {
|
||||
shared := microstore.NewMemoryStore()
|
||||
const max = 5
|
||||
|
||||
var admitted int32
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 40; i++ {
|
||||
wg.Add(1)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
// each goroutine is its own "replica" with no shared mutex
|
||||
allowed, err := New(shared, time.Minute, max).Allow("user-1")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if allowed {
|
||||
atomic.AddInt32(&admitted, 1)
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
if admitted > max {
|
||||
t.Fatalf("admitted %d requests, limit is %d", admitted, max)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_DeniedRequestsDoNotCount(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), 50*time.Millisecond, 1)
|
||||
|
||||
if allowed, _ := l.Allow("user-1"); !allowed {
|
||||
t.Fatal("first request should be allowed")
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
if allowed, _ := l.Allow("user-1"); allowed {
|
||||
t.Fatal("request should be denied")
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(80 * time.Millisecond)
|
||||
|
||||
if allowed, _ := l.Allow("user-1"); !allowed {
|
||||
t.Fatal("denied requests must not extend the window")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimiter_KeyPrefixDoesNotLeak(t *testing.T) {
|
||||
l := New(microstore.NewMemoryStore(), time.Minute, 1)
|
||||
|
||||
if allowed, _ := l.Allow("user"); !allowed {
|
||||
t.Fatal("first request should be allowed")
|
||||
}
|
||||
if allowed, _ := l.Allow("user/other"); !allowed {
|
||||
t.Fatal("a key that merely starts with another key must be tracked separately")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Package sanitize validates and sanitizes the JSON body a client sends to
|
||||
// the chat-completions endpoint before it is forwarded to the upstream LLM.
|
||||
// Only the fields the LLM actually needs are forwarded; everything else the
|
||||
// client sent is dropped, so a client cannot inject unexpected upstream
|
||||
// parameters.
|
||||
package sanitize
|
||||
|
||||
import "errors"
|
||||
|
||||
// Request is the sanitized body forwarded to the upstream LLM.
|
||||
type Request struct {
|
||||
Model string `json:"model"`
|
||||
Messages []interface{} `json:"messages"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
Temperature *float64 `json:"temperature,omitempty"`
|
||||
}
|
||||
|
||||
// Body validates and sanitizes a client's decoded JSON body.
|
||||
//
|
||||
// modelOverride, when non-empty, replaces whatever model the client sent.
|
||||
// maxTokensLimit is a hard ceiling: the client's max_tokens is used only if
|
||||
// positive, and is always clamped to this limit, which must itself be positive.
|
||||
func Body(raw map[string]interface{}, modelOverride string, maxTokensLimit int) (Request, error) {
|
||||
if maxTokensLimit <= 0 {
|
||||
return Request{}, errors.New("max tokens limit must be positive")
|
||||
}
|
||||
|
||||
if stream, ok := raw["stream"].(bool); ok && stream {
|
||||
return Request{}, errors.New("streaming is not supported")
|
||||
}
|
||||
|
||||
model := modelOverride
|
||||
if model == "" {
|
||||
if m, ok := raw["model"].(string); ok {
|
||||
model = m
|
||||
}
|
||||
}
|
||||
if model == "" {
|
||||
return Request{}, errors.New("model is required")
|
||||
}
|
||||
|
||||
messages, ok := raw["messages"].([]interface{})
|
||||
if !ok || len(messages) == 0 {
|
||||
return Request{}, errors.New("messages must be a non-empty array")
|
||||
}
|
||||
for _, m := range messages {
|
||||
msg, ok := m.(map[string]interface{})
|
||||
if !ok {
|
||||
return Request{}, errors.New("each message must be an object")
|
||||
}
|
||||
if _, ok := msg["role"].(string); !ok {
|
||||
return Request{}, errors.New("each message must have a string role")
|
||||
}
|
||||
}
|
||||
|
||||
maxTokens := maxTokensLimit
|
||||
if v, ok := raw["max_tokens"].(float64); ok && v > 0 {
|
||||
maxTokens = int(v)
|
||||
}
|
||||
if maxTokens > maxTokensLimit {
|
||||
maxTokens = maxTokensLimit
|
||||
}
|
||||
|
||||
req := Request{
|
||||
Model: model,
|
||||
Messages: messages,
|
||||
MaxTokens: maxTokens,
|
||||
}
|
||||
|
||||
if t, ok := raw["temperature"].(float64); ok {
|
||||
req.Temperature = &t
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package sanitize
|
||||
|
||||
import "testing"
|
||||
|
||||
var validMessages = []interface{}{map[string]interface{}{"role": "user", "content": "hi"}}
|
||||
|
||||
func TestBody_RequiresModel(t *testing.T) {
|
||||
_, err := Body(map[string]interface{}{
|
||||
"messages": validMessages,
|
||||
}, "", 4096)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error when model is missing and no override is set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_ModelOverrideWins(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "client-requested-model",
|
||||
"messages": validMessages,
|
||||
}, "forced-model", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.Model != "forced-model" {
|
||||
t.Fatalf("expected model override to win, got %q", req.Model)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_ClientModelUsedWhenNoOverride(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "client-model",
|
||||
"messages": validMessages,
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.Model != "client-model" {
|
||||
t.Fatalf("expected client model, got %q", req.Model)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_RequiresMessagesArray(t *testing.T) {
|
||||
_, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": "not-an-array",
|
||||
}, "", 4096)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error when messages is not an array")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_MaxTokensClampedToLimit(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
"max_tokens": float64(999999),
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.MaxTokens != 4096 {
|
||||
t.Fatalf("expected max_tokens clamped to 4096, got %d", req.MaxTokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_MaxTokensDefaultsToLimitWhenAbsent(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.MaxTokens != 4096 {
|
||||
t.Fatalf("expected max_tokens to default to the limit, got %d", req.MaxTokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_MaxTokensDefaultsToLimitWhenNotPositive(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
"max_tokens": float64(-1),
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.MaxTokens != 4096 {
|
||||
t.Fatalf("expected max_tokens to default to the limit for a non-positive value, got %d", req.MaxTokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_TemperaturePassedThrough(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
"temperature": float64(0.7),
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.Temperature == nil || *req.Temperature != 0.7 {
|
||||
t.Fatalf("expected temperature 0.7, got %v", req.Temperature)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_TemperatureOmittedWhenAbsent(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.Temperature != nil {
|
||||
t.Fatalf("expected temperature to be nil, got %v", req.Temperature)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_DropsUnknownFields(t *testing.T) {
|
||||
req, err := Body(map[string]interface{}{
|
||||
"model": "m",
|
||||
"messages": validMessages,
|
||||
"some_random_field": "should be dropped",
|
||||
}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if req.Model != "m" || len(req.Messages) != 1 {
|
||||
t.Fatalf("unexpected sanitized request: %+v", req)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_RejectsInvalidMessages(t *testing.T) {
|
||||
tests := map[string][]interface{}{
|
||||
"empty": {},
|
||||
"non-object": {"hi"},
|
||||
"missing role": {map[string]interface{}{"content": "hi"}},
|
||||
"non-string role": {map[string]interface{}{"role": 1}},
|
||||
}
|
||||
for name, messages := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
_, err := Body(map[string]interface{}{"model": "m", "messages": messages}, "", 4096)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_RejectsNonPositiveMaxTokensLimit(t *testing.T) {
|
||||
for _, limit := range []int{0, -1} {
|
||||
_, err := Body(map[string]interface{}{"model": "m", "messages": validMessages}, "", limit)
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error for limit %d", limit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_RejectsStreaming(t *testing.T) {
|
||||
_, err := Body(map[string]interface{}{"model": "m", "messages": validMessages, "stream": true}, "", 4096)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error when stream is true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBody_AllowsStreamFalse(t *testing.T) {
|
||||
_, err := Body(map[string]interface{}{"model": "m", "messages": validMessages, "stream": false}, "", 4096)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// services/llm/pkg/server/debug/option.go
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) { o.Logger = val }
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) { o.Context = val }
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) { o.Config = val }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// services/llm/pkg/server/debug/server.go
|
||||
package debug
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
checkHandler := handlers.NewCheckHandler(
|
||||
handlers.NewCheckHandlerConfiguration().
|
||||
WithLogger(options.Logger).
|
||||
WithCheck("llm reachability", checks.NewHTTPCheck(options.Config.HTTP.Addr)),
|
||||
)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.GetString()),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(checkHandler),
|
||||
debug.Ready(checkHandler),
|
||||
debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// services/llm/pkg/server/http/option.go
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/ratelimit"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Flags []cli.Flag
|
||||
Limiter *ratelimit.Limiter
|
||||
TraceProvider trace.TracerProvider
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) { o.Logger = val }
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) { o.Context = val }
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) { o.Config = val }
|
||||
}
|
||||
|
||||
// Limiter provides a function to set the rate limiter option.
|
||||
func Limiter(val *ratelimit.Limiter) Option {
|
||||
return func(o *Options) { o.Limiter = val }
|
||||
}
|
||||
|
||||
// TraceProvider provides a function to configure the trace provider.
|
||||
func TraceProvider(traceProvider trace.TracerProvider) Option {
|
||||
return func(o *Options) {
|
||||
if traceProvider != nil {
|
||||
o.TraceProvider = traceProvider
|
||||
} else {
|
||||
o.TraceProvider = noop.NewTracerProvider()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// services/llm/pkg/server/http/server.go
|
||||
package http
|
||||
|
||||
import (
|
||||
nethttp "net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
chimiddleware "github.com/go-chi/chi/v5/middleware"
|
||||
"go-micro.dev/v4"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/account"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/middleware"
|
||||
ohttp "github.com/owncloud/ocis/v2/ocis-pkg/service/http"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/service"
|
||||
)
|
||||
|
||||
// Server initializes the http service and server.
|
||||
func Server(opts ...Option) (ohttp.Service, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
newService, err := ohttp.NewService(
|
||||
ohttp.TLSConfig(options.Config.HTTP.TLS),
|
||||
ohttp.Logger(options.Logger),
|
||||
ohttp.Namespace(options.Config.HTTP.Namespace),
|
||||
ohttp.Name(options.Config.Service.Name),
|
||||
ohttp.Version(version.GetString()),
|
||||
ohttp.Address(options.Config.HTTP.Addr),
|
||||
ohttp.Context(options.Context),
|
||||
ohttp.Flags(options.Flags...),
|
||||
ohttp.TraceProvider(options.TraceProvider),
|
||||
)
|
||||
if err != nil {
|
||||
options.Logger.Error().Err(err).Msg("Error initializing http service")
|
||||
return ohttp.Service{}, err
|
||||
}
|
||||
|
||||
svc := service.New(options.Config, options.Limiter, options.Logger)
|
||||
|
||||
mux := chi.NewMux()
|
||||
mux.Use(
|
||||
middleware.GetOtelhttpMiddleware(options.Config.Service.Name, options.TraceProvider),
|
||||
chimiddleware.RequestID,
|
||||
middleware.Version(options.Config.Service.Name, version.GetString()),
|
||||
middleware.Logger(options.Logger),
|
||||
requireIdentity(middleware.ExtractAccountUUID(
|
||||
account.Logger(options.Logger),
|
||||
account.JWTSecret(options.Config.TokenManager.JWTSecret),
|
||||
)),
|
||||
middleware.Cors(
|
||||
cors.Logger(options.Logger),
|
||||
cors.AllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
cors.AllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
cors.AllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
cors.AllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
),
|
||||
)
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
// proxy forwards the original request path unchanged (it does not
|
||||
// strip the matched prefix — see activitylog's route registration
|
||||
// for the same pattern), so this must be the full external path.
|
||||
r.Post("/graph/v1beta1/extensions/org.libregraph/llm/chat/completions", svc.HandleChatCompletions)
|
||||
})
|
||||
|
||||
if err := micro.RegisterHandler(newService.Server(), mux); err != nil {
|
||||
options.Logger.Error().Err(err).Msg("failed to register the handler")
|
||||
return ohttp.Service{}, err
|
||||
}
|
||||
|
||||
newService.Init()
|
||||
return newService, nil
|
||||
}
|
||||
|
||||
// requireIdentity wraps the account middleware, which silently returns an
|
||||
// empty 200 when the token is invalid or out of scope. Reject those requests
|
||||
// explicitly instead.
|
||||
func requireIdentity(extract func(nethttp.Handler) nethttp.Handler) func(nethttp.Handler) nethttp.Handler {
|
||||
return func(next nethttp.Handler) nethttp.Handler {
|
||||
return nethttp.HandlerFunc(func(w nethttp.ResponseWriter, r *nethttp.Request) {
|
||||
passed := false
|
||||
extract(nethttp.HandlerFunc(func(w nethttp.ResponseWriter, r *nethttp.Request) {
|
||||
passed = true
|
||||
next.ServeHTTP(w, r)
|
||||
})).ServeHTTP(w, r)
|
||||
if !passed {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(nethttp.StatusUnauthorized)
|
||||
_, _ = w.Write([]byte(`{"error":"invalid access token"}` + "\n"))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
nethttp "net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRequireIdentity_RejectsWhenAccountMiddlewareStopsTheRequest(t *testing.T) {
|
||||
// stands in for ExtractAccountUUID returning early on an invalid token
|
||||
extract := func(next nethttp.Handler) nethttp.Handler {
|
||||
return nethttp.HandlerFunc(func(w nethttp.ResponseWriter, r *nethttp.Request) {})
|
||||
}
|
||||
called := false
|
||||
h := requireIdentity(extract)(nethttp.HandlerFunc(func(w nethttp.ResponseWriter, r *nethttp.Request) { called = true }))
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, httptest.NewRequest(nethttp.MethodPost, "/", nil))
|
||||
|
||||
if rec.Code != nethttp.StatusUnauthorized {
|
||||
t.Fatalf("expected 401, got %d", rec.Code)
|
||||
}
|
||||
if called {
|
||||
t.Fatal("next handler must not run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequireIdentity_PassesThroughWhenAccountMiddlewareContinues(t *testing.T) {
|
||||
extract := func(next nethttp.Handler) nethttp.Handler { return next }
|
||||
h := requireIdentity(extract)(nethttp.HandlerFunc(func(w nethttp.ResponseWriter, r *nethttp.Request) {
|
||||
w.WriteHeader(nethttp.StatusNoContent)
|
||||
}))
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, httptest.NewRequest(nethttp.MethodPost, "/", nil))
|
||||
|
||||
if rec.Code != nethttp.StatusNoContent {
|
||||
t.Fatalf("expected 204, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
var errBodyTooLarge = errors.New("request body too large")
|
||||
|
||||
// readLimited reads r fully, returning errBodyTooLarge if the body exceeds
|
||||
// maxBytes.
|
||||
func readLimited(r io.Reader, maxBytes int64) ([]byte, error) {
|
||||
data, err := io.ReadAll(io.LimitReader(r, maxBytes+1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if int64(len(data)) > maxBytes {
|
||||
return nil, errBodyTooLarge
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
revactx "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/ratelimit"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/sanitize"
|
||||
)
|
||||
|
||||
// maxUpstreamResponseBytes caps how much of the upstream LLM's response body
|
||||
// this service will buffer before giving up.
|
||||
const maxUpstreamResponseBytes = 10 * 1024 * 1024 // 10 MiB
|
||||
|
||||
// Service handles chat completion requests, proxying them to the configured
|
||||
// upstream LLM endpoint.
|
||||
type Service struct {
|
||||
cfg *config.Config
|
||||
limiter *ratelimit.Limiter
|
||||
client *http.Client
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
// New creates a new Service.
|
||||
func New(cfg *config.Config, limiter *ratelimit.Limiter, logger log.Logger) *Service {
|
||||
return &Service{
|
||||
cfg: cfg,
|
||||
limiter: limiter,
|
||||
client: &http.Client{},
|
||||
log: logger,
|
||||
}
|
||||
}
|
||||
|
||||
// HandleChatCompletions handles POST requests forwarding chat completions to
|
||||
// the configured LLM.
|
||||
func (s *Service) HandleChatCompletions(w http.ResponseWriter, r *http.Request) {
|
||||
user, ok := revactx.ContextGetUser(r.Context())
|
||||
if !ok {
|
||||
writeError(w, http.StatusUnauthorized, "missing authenticated user")
|
||||
return
|
||||
}
|
||||
|
||||
body, err := readLimited(r.Body, s.cfg.LLM.MaxBodyBytes)
|
||||
if err != nil {
|
||||
if errors.Is(err, errBodyTooLarge) {
|
||||
writeError(w, http.StatusRequestEntityTooLarge, "request body too large")
|
||||
} else {
|
||||
writeError(w, http.StatusBadRequest, "could not read request body")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var raw map[string]interface{}
|
||||
if err := json.Unmarshal(body, &raw); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
sanitized, err := sanitize.Body(raw, s.cfg.LLM.Model, s.cfg.LLM.MaxTokensLimit)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// only requests that are valid and about to hit the upstream count
|
||||
// against the user's quota.
|
||||
allowed, err := s.limiter.Allow(user.GetId().GetOpaqueId())
|
||||
if err != nil {
|
||||
s.log.Warn().Err(err).Msg("rate limit check failed")
|
||||
writeError(w, http.StatusInternalServerError, "rate limit check failed")
|
||||
return
|
||||
}
|
||||
if !allowed {
|
||||
writeError(w, http.StatusTooManyRequests, "rate limit exceeded. Please slow down.")
|
||||
return
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(sanitized)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "could not encode upstream request")
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := contextWithTimeout(r.Context(), s.cfg.LLM.Timeout)
|
||||
defer cancel()
|
||||
|
||||
upstreamURL := strings.TrimSuffix(s.cfg.LLM.Endpoint, "/") + "/chat/completions"
|
||||
upstreamReq, err := http.NewRequestWithContext(ctx, http.MethodPost, upstreamURL, bytes.NewReader(payload))
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "could not build upstream request")
|
||||
return
|
||||
}
|
||||
upstreamReq.Header.Set("Content-Type", "application/json")
|
||||
if s.cfg.LLM.APIKey != "" {
|
||||
upstreamReq.Header.Set("Authorization", "Bearer "+s.cfg.LLM.APIKey)
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(upstreamReq)
|
||||
if err != nil {
|
||||
s.log.Warn().Err(err).Msg("could not reach upstream LLM endpoint")
|
||||
writeError(w, http.StatusBadGateway, "could not reach LLM endpoint")
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
respBody, err := readLimited(resp.Body, maxUpstreamResponseBytes)
|
||||
if err != nil {
|
||||
s.log.Warn().Err(err).Msg("could not read upstream LLM response")
|
||||
writeError(w, http.StatusBadGateway, "could not read LLM response")
|
||||
return
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||
// Do not relay upstream errors: a 401/403 caused by a bad API key
|
||||
// would look like an expired session to the web client, and the
|
||||
// error text can contain provider account details.
|
||||
s.log.Warn().
|
||||
Int("status", resp.StatusCode).
|
||||
Str("body", truncate(string(respBody), 512)).
|
||||
Msg("upstream LLM endpoint returned an error")
|
||||
if resp.StatusCode == http.StatusTooManyRequests {
|
||||
writeError(w, http.StatusTooManyRequests, "the LLM endpoint is busy. Please try again later.")
|
||||
} else {
|
||||
writeError(w, http.StatusBadGateway, "the LLM endpoint returned an error")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
if contentType == "" {
|
||||
contentType = "application/json"
|
||||
}
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
_, _ = w.Write(respBody)
|
||||
}
|
||||
|
||||
func truncate(s string, n int) string {
|
||||
if len(s) <= n {
|
||||
return s
|
||||
}
|
||||
return s[:n] + "..."
|
||||
}
|
||||
|
||||
func writeError(w http.ResponseWriter, status int, message string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"error": message})
|
||||
}
|
||||
|
||||
// contextWithTimeout wraps context.WithTimeout; a timeout <= 0 means "no
|
||||
// explicit timeout beyond whatever the parent context already has" instead
|
||||
// of expiring immediately.
|
||||
func contextWithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
|
||||
if timeout <= 0 {
|
||||
return parent, func() {}
|
||||
}
|
||||
return context.WithTimeout(parent, timeout)
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
revactx "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/llm/pkg/ratelimit"
|
||||
)
|
||||
|
||||
func testUser(id string) *userpb.User {
|
||||
return &userpb.User{Id: &userpb.UserId{OpaqueId: id}}
|
||||
}
|
||||
|
||||
func newTestService(t *testing.T, llmServerURL string, maxRequests int) *Service {
|
||||
t.Helper()
|
||||
cfg := &config.Config{
|
||||
LLM: config.LLM{
|
||||
Endpoint: llmServerURL,
|
||||
MaxTokensLimit: 4096,
|
||||
Timeout: 5 * time.Second,
|
||||
MaxBodyBytes: 1024,
|
||||
},
|
||||
}
|
||||
limiter := ratelimit.New(microstore.NewMemoryStore(), time.Minute, maxRequests)
|
||||
return New(cfg, limiter, log.NewLogger(log.Level("error")))
|
||||
}
|
||||
|
||||
func requestWithUser(body []byte, userID string) *http.Request {
|
||||
req := httptest.NewRequest(http.MethodPost, "/chat/completions", bytes.NewReader(body))
|
||||
if userID != "" {
|
||||
ctx := revactx.ContextSetUser(req.Context(), testUser(userID))
|
||||
req = req.WithContext(ctx)
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_NoUser_Returns401(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 20)
|
||||
req := requestWithUser([]byte(`{}`), "")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusUnauthorized {
|
||||
t.Fatalf("expected 401, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_RateLimited_Returns429(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 1)
|
||||
|
||||
// first request consumes the only allowed slot; the upstream call will
|
||||
// fail (no server listening at unused.invalid), which is fine — we only
|
||||
// care about the rate limiter state after this call.
|
||||
first := requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`), "user-1")
|
||||
svc.HandleChatCompletions(httptest.NewRecorder(), first)
|
||||
|
||||
second := requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
svc.HandleChatCompletions(rec, second)
|
||||
|
||||
if rec.Code != http.StatusTooManyRequests {
|
||||
t.Fatalf("expected 429, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_OversizedBody_Returns413(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 20)
|
||||
oversized := bytes.Repeat([]byte("a"), 2048)
|
||||
req := requestWithUser(oversized, "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusRequestEntityTooLarge {
|
||||
t.Fatalf("expected 413, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_InvalidJSON_Returns400(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 20)
|
||||
req := requestWithUser([]byte(`not json`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_MissingMessages_Returns400(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 20)
|
||||
req := requestWithUser([]byte(`{"model":"m"}`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_HappyPath_RelaysUpstreamResponse(t *testing.T) {
|
||||
var receivedPath string
|
||||
var receivedAuth string
|
||||
var receivedBody []byte
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
receivedPath = r.URL.Path
|
||||
receivedAuth = r.Header.Get("Authorization")
|
||||
receivedBody, _ = io.ReadAll(r.Body)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte(`{"choices":[{"message":{"content":"hi"}}]}`))
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
svc := newTestService(t, upstream.URL, 20)
|
||||
svc.cfg.LLM.APIKey = "test-key"
|
||||
|
||||
req := requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}],"max_tokens":999999,"some_unknown_field":"should be dropped"}`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d, body: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
if receivedPath != "/chat/completions" {
|
||||
t.Fatalf("expected upstream path /chat/completions, got %q", receivedPath)
|
||||
}
|
||||
if receivedAuth != "Bearer test-key" {
|
||||
t.Fatalf("expected upstream Authorization header, got %q", receivedAuth)
|
||||
}
|
||||
|
||||
var got map[string]interface{}
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &got); err != nil {
|
||||
t.Fatalf("expected valid JSON relayed back, got error: %v, body: %s", err, rec.Body.String())
|
||||
}
|
||||
|
||||
var forwarded map[string]interface{}
|
||||
if err := json.Unmarshal(receivedBody, &forwarded); err != nil {
|
||||
t.Fatalf("expected valid JSON forwarded to upstream, got error: %v, body: %s", err, receivedBody)
|
||||
}
|
||||
if _, present := forwarded["some_unknown_field"]; present {
|
||||
t.Fatalf("expected unknown field to be dropped from forwarded body, got: %s", receivedBody)
|
||||
}
|
||||
maxTokens, ok := forwarded["max_tokens"].(float64)
|
||||
if !ok {
|
||||
t.Fatalf("expected max_tokens to be forwarded, got: %s", receivedBody)
|
||||
}
|
||||
if int(maxTokens) != svc.cfg.LLM.MaxTokensLimit {
|
||||
t.Fatalf("expected max_tokens clamped to %d, got %v", svc.cfg.LLM.MaxTokensLimit, maxTokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_ModelOverride_ReplacesClientModel(t *testing.T) {
|
||||
var receivedBody []byte
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
receivedBody, _ = io.ReadAll(r.Body)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte(`{"choices":[{"message":{"content":"hi"}}]}`))
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
svc := newTestService(t, upstream.URL, 20)
|
||||
svc.cfg.LLM.Model = "forced-model"
|
||||
|
||||
req := requestWithUser([]byte(`{"model":"client-requested-model","messages":[{"role":"user","content":"hi"}]}`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d, body: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
|
||||
var forwarded map[string]interface{}
|
||||
if err := json.Unmarshal(receivedBody, &forwarded); err != nil {
|
||||
t.Fatalf("expected valid JSON forwarded to upstream, got error: %v, body: %s", err, receivedBody)
|
||||
}
|
||||
if forwarded["model"] != "forced-model" {
|
||||
t.Fatalf("expected forwarded model to be overridden to %q, got %v", "forced-model", forwarded["model"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_UpstreamUnreachable_Returns502(t *testing.T) {
|
||||
svc := newTestService(t, "http://127.0.0.1:1", 20) // nothing listens here
|
||||
req := requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`), "user-1")
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
svc.HandleChatCompletions(rec, req)
|
||||
|
||||
if rec.Code != http.StatusBadGateway {
|
||||
t.Fatalf("expected 502, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_ClientDisconnect_CancelsUpstreamCall(t *testing.T) {
|
||||
upstreamStarted := make(chan struct{})
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Drain the request body before waiting: net/http's server only starts
|
||||
// watching the connection for a client disconnect (which cancels
|
||||
// r.Context()) once the request body has been fully read. Without this,
|
||||
// r.Context().Done() below would never fire and the test would hang -
|
||||
// this is standard net/http behavior, not something the handler under
|
||||
// test can influence, since it is the *client* whose context we cancel.
|
||||
_, _ = io.Copy(io.Discard, r.Body)
|
||||
close(upstreamStarted)
|
||||
<-r.Context().Done() // the client cancellation below should propagate here
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
svc := newTestService(t, upstream.URL, 20)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
req := httptest.NewRequest(http.MethodPost, "/chat/completions", bytes.NewReader([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`)))
|
||||
req = req.WithContext(revactx.ContextSetUser(ctx, testUser("user-1")))
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
svc.HandleChatCompletions(httptest.NewRecorder(), req)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
<-upstreamStarted
|
||||
cancel()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
// handler returned once the client context was canceled, as expected
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("handler did not return after client disconnect")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_InvalidRequestDoesNotConsumeQuota(t *testing.T) {
|
||||
svc := newTestService(t, "http://unused.invalid", 1)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
rec := httptest.NewRecorder()
|
||||
svc.HandleChatCompletions(rec, requestWithUser([]byte(`{"model":"m","messages":[]}`), "user-1"))
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
// the single allowed slot is still free, so this reaches the (dead) upstream
|
||||
rec := httptest.NewRecorder()
|
||||
svc.HandleChatCompletions(rec, requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`), "user-1"))
|
||||
if rec.Code != http.StatusBadGateway {
|
||||
t.Fatalf("expected 502, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleChatCompletions_UpstreamErrors_AreNotRelayed(t *testing.T) {
|
||||
tests := []struct {
|
||||
upstream int
|
||||
want int
|
||||
}{
|
||||
{http.StatusUnauthorized, http.StatusBadGateway},
|
||||
{http.StatusForbidden, http.StatusBadGateway},
|
||||
{http.StatusInternalServerError, http.StatusBadGateway},
|
||||
{http.StatusTooManyRequests, http.StatusTooManyRequests},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(http.StatusText(tt.upstream), func(t *testing.T) {
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(tt.upstream)
|
||||
_, _ = w.Write([]byte(`{"error":"secret provider account detail"}`))
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
svc := newTestService(t, upstream.URL, 20)
|
||||
rec := httptest.NewRecorder()
|
||||
svc.HandleChatCompletions(rec, requestWithUser([]byte(`{"model":"m","messages":[{"role":"user","content":"hi"}]}`), "user-1"))
|
||||
|
||||
if rec.Code != tt.want {
|
||||
t.Fatalf("expected %d, got %d", tt.want, rec.Code)
|
||||
}
|
||||
if strings.Contains(rec.Body.String(), "secret provider account detail") {
|
||||
t.Fatal("upstream error body must not be relayed to the client")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ type Store struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;NOTIFICATIONS_STORE_TTL" desc:"Time to live for notifications in the store. Defaults to '336h' (2 weeks). See the Environment Variable Types description for more details." introductionVersion:"7.1.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;NOTIFICATIONS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.1.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;NOTIFICATIONS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"7.1.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;NOTIFICATIONS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;NOTIFICATIONS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;NOTIFICATIONS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;NOTIFICATIONS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;NOTIFICATIONS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;NOTIFICATIONS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/notifications/pkg/channels"
|
||||
"github.com/owncloud/reva/v2/pkg/events"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/owncloud/reva/v2/pkg/storagespace"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
cs3mocks "github.com/owncloud/reva/v2/tests/cs3mocks/mocks"
|
||||
"github.com/stretchr/testify/mock"
|
||||
@@ -80,6 +81,11 @@ var _ = Describe("Notifications", func() {
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(&user.GetUserResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharer}, nil).Once()
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(&user.GetUserResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharee}, nil).Once()
|
||||
gatewayClient.On("Authenticate", mock.Anything, mock.Anything).Return(&gateway.AuthenticateResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, User: sharer}, nil)
|
||||
// Registered before the catch-all below: testify/mock matches expectations in
|
||||
// registration order, so the more specific vault matcher must come first.
|
||||
gatewayClient.On("Stat", mock.Anything, mock.MatchedBy(func(r *provider.StatRequest) bool {
|
||||
return r.GetRef().GetResourceId().GetStorageId() == utils.VaultStorageProviderID
|
||||
})).Return(&provider.StatResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, Info: &provider.ResourceInfo{Name: "report.pdf", Space: &provider.StorageSpace{Name: "vault space"}}}, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(&provider.StatResponse{Status: &rpc.Status{Code: rpc.Code_CODE_OK}, Info: &provider.ResourceInfo{Name: "secrets of the board", Space: &provider.StorageSpace{Name: "secret space"}}}, nil)
|
||||
vs = &settingssvc.MockValueService{}
|
||||
vs.GetValueByUniqueIdentifiersFunc = func(ctx context.Context, req *settingssvc.GetValueByUniqueIdentifiersRequest, opts ...client.CallOption) (*settingssvc.GetValueResponse, error) {
|
||||
@@ -270,6 +276,95 @@ https://owncloud.com
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
vaultResourceID := &provider.ResourceId{
|
||||
StorageId: utils.VaultStorageProviderID,
|
||||
SpaceId: "spaceid",
|
||||
OpaqueId: "itemid",
|
||||
}
|
||||
vaultSpaceID := &provider.StorageSpaceId{
|
||||
OpaqueId: storagespace.FormatResourceID(&provider.ResourceId{
|
||||
StorageId: utils.VaultStorageProviderID,
|
||||
SpaceId: "vaultspaceid",
|
||||
OpaqueId: "vaultspaceid",
|
||||
}),
|
||||
}
|
||||
|
||||
DescribeTable("Vault resources are redacted in notifications",
|
||||
func(ev events.Event, mustNotContain string) {
|
||||
received := make(chan *channels.Message, 1)
|
||||
ch := make(chan events.Event)
|
||||
evts := NewEventsNotifier(trace.NewNoopTracerProvider(), ch, capturingChannel{out: received}, log.NewLogger(), gatewaySelector, vs, "",
|
||||
"", "", "", "", "", "",
|
||||
store.Create(), nil, nil)
|
||||
go evts.Run()
|
||||
|
||||
ch <- ev
|
||||
|
||||
var msg *channels.Message
|
||||
select {
|
||||
case msg = <-received:
|
||||
case <-time.Tick(3 * time.Second):
|
||||
Fail("timeout waiting for notification")
|
||||
}
|
||||
|
||||
Expect(msg.Subject).NotTo(ContainSubstring(mustNotContain))
|
||||
Expect(msg.TextBody).NotTo(ContainSubstring(mustNotContain))
|
||||
},
|
||||
|
||||
Entry("Share Created", events.Event{
|
||||
Event: events.ShareCreated{
|
||||
Sharer: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
CTime: utils.TimeToTS(time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC)),
|
||||
ItemID: vaultResourceID,
|
||||
},
|
||||
}, "report.pdf"),
|
||||
|
||||
Entry("Share Expired", events.Event{
|
||||
Event: events.ShareExpired{
|
||||
ShareOwner: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
ExpiredAt: time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC),
|
||||
ItemID: vaultResourceID,
|
||||
},
|
||||
}, "report.pdf"),
|
||||
|
||||
Entry("Share Removed", events.Event{
|
||||
Event: events.ShareRemoved{
|
||||
Executant: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
ItemID: vaultResourceID,
|
||||
},
|
||||
}, "report.pdf"),
|
||||
|
||||
Entry("Added to Space", events.Event{
|
||||
Event: events.SpaceShared{
|
||||
Executant: sharer.GetId(),
|
||||
Creator: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
ID: vaultSpaceID,
|
||||
},
|
||||
}, "vault space"),
|
||||
|
||||
Entry("Removed from Space", events.Event{
|
||||
Event: events.SpaceUnshared{
|
||||
Executant: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
ID: vaultSpaceID,
|
||||
},
|
||||
}, "vault space"),
|
||||
|
||||
Entry("Space Expired", events.Event{
|
||||
Event: events.SpaceMembershipExpired{
|
||||
SpaceOwner: sharer.GetId(),
|
||||
GranteeUserID: sharee.GetId(),
|
||||
SpaceID: vaultSpaceID,
|
||||
SpaceName: "vault space",
|
||||
ExpiredAt: time.Date(2023, 4, 17, 16, 42, 0, 0, time.UTC),
|
||||
},
|
||||
}, "vault space"),
|
||||
)
|
||||
})
|
||||
|
||||
var _ = Describe("Notifications X-Site Scripting", func() {
|
||||
@@ -1278,6 +1373,17 @@ type testChannel struct {
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// capturingChannel hands the sent message to the caller instead of asserting on it itself,
|
||||
// for tests that need to inspect the message rather than match it exactly.
|
||||
type capturingChannel struct {
|
||||
out chan *channels.Message
|
||||
}
|
||||
|
||||
func (c capturingChannel) SendMessage(_ context.Context, m *channels.Message) error {
|
||||
c.out <- m
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc testChannel) SendMessage(_ context.Context, m *channels.Message) error {
|
||||
defer GinkgoRecover()
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@ import (
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
)
|
||||
|
||||
// vaultRedactedName replaces a file/space name with a generic placeholder when it belongs to
|
||||
// the vault storage provider, so personal data never leaves the vault in a notification email.
|
||||
func vaultRedactedName(storageID, name string) string {
|
||||
if storageID == utils.VaultStorageProviderID {
|
||||
return "a shared item"
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (s eventsNotifier) handleShareCreated(baseCtx context.Context, e events.ShareCreated, eventId string) {
|
||||
logger := s.logger.With().
|
||||
Str("event", "ShareCreated").
|
||||
@@ -69,7 +78,7 @@ func (s eventsNotifier) prepareShareCreated(baseCtx context.Context, logger zero
|
||||
Msg("could not stat resource")
|
||||
return owner, shareFolder, shareLink, ctx, err
|
||||
}
|
||||
shareFolder = resourceInfo.Name
|
||||
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.Name)
|
||||
|
||||
shareLink, err = urlJoinPath(s.ocisURL, "files/shares/with-me")
|
||||
if err != nil {
|
||||
@@ -157,7 +166,7 @@ func (s eventsNotifier) prepareShareExpired(baseCtx context.Context, logger zero
|
||||
Msg("could not stat resource")
|
||||
return shareFolder, ctx, err
|
||||
}
|
||||
shareFolder = resourceInfo.GetName()
|
||||
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.GetName())
|
||||
|
||||
return shareFolder, ctx, err
|
||||
}
|
||||
@@ -219,7 +228,7 @@ func (s eventsNotifier) prepareShareRemoved(baseCtx context.Context, logger zero
|
||||
Msg("could not stat resource")
|
||||
return executant, shareFolder, ctx, err
|
||||
}
|
||||
shareFolder = resourceInfo.Name
|
||||
shareFolder = vaultRedactedName(e.ItemID.GetStorageId(), resourceInfo.Name)
|
||||
|
||||
executant, err = utils.GetUserWithContext(ctx, e.Executant, gatewayClient)
|
||||
if err != nil {
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s eventsNotifier) prepareSpaceShared(baseCtx context.Context, logger zerol
|
||||
Msg("could not get space info")
|
||||
return executant, spaceName, shareLink, ctx, err
|
||||
}
|
||||
spaceName = resourceInfo.GetSpace().GetName()
|
||||
spaceName = vaultRedactedName(resourceID.GetStorageId(), resourceInfo.GetSpace().GetName())
|
||||
|
||||
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
|
||||
if err != nil {
|
||||
@@ -169,7 +169,7 @@ func (s eventsNotifier) prepareSpaceUnshared(baseCtx context.Context, logger zer
|
||||
Msg("could not get space info")
|
||||
return executant, spaceName, shareLink, ctx, err
|
||||
}
|
||||
spaceName = resourceInfo.GetSpace().GetName()
|
||||
spaceName = vaultRedactedName(resourceID.GetStorageId(), resourceInfo.GetSpace().GetName())
|
||||
|
||||
shareLink, err = urlJoinPath(s.ocisURL, "f", e.ID.OpaqueId)
|
||||
if err != nil {
|
||||
@@ -220,10 +220,17 @@ func (s eventsNotifier) handleSpaceMembershipExpired(baseCtx context.Context, e
|
||||
return
|
||||
}
|
||||
|
||||
spaceName := e.SpaceName
|
||||
if resourceID, err := storagespace.ParseID(e.SpaceID.GetOpaqueId()); err == nil {
|
||||
spaceName = vaultRedactedName(resourceID.GetStorageId(), spaceName)
|
||||
} else {
|
||||
logger.Error().Err(err).Msg("could not parse resourceid from SpaceID, skipping vault redaction check")
|
||||
}
|
||||
|
||||
emails, err := s.render(ctx, email.MembershipExpired,
|
||||
"SpaceGrantee",
|
||||
map[string]string{
|
||||
"SpaceName": e.SpaceName,
|
||||
"SpaceName": spaceName,
|
||||
"ExpiredAt": e.ExpiredAt.Format("2006-01-02 15:04:05"),
|
||||
}, recipientsInstant, owner.GetDisplayName())
|
||||
if err != nil {
|
||||
|
||||
@@ -39,7 +39,7 @@ type Config struct {
|
||||
|
||||
AllowPropfindDepthInfinity bool `yaml:"allow_propfind_depth_infinity" env:"OCDAV_ALLOW_PROPFIND_DEPTH_INFINITY" desc:"Allow the use of depth infinity in PROPFINDS. When enabled, a propfind will traverse through all subfolders. If many subfolders are expected, depth infinity can cause heavy server load and/or delayed response times." introductionVersion:"pre5.0"`
|
||||
|
||||
DisablePropfindPublicLinkResolution bool `yaml:"disable_propfind_public_link_resolution" env:"OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION" desc:"Disable the resolution of public link shares when answering PROPFIND requests. When disabled, the oc:share-type property will not be populated with public link share information, which can reduce load on services for large collections." introductionVersion:"8.3.0"`
|
||||
DisablePropfindPublicLinkResolution bool `yaml:"disable_propfind_public_link_resolution" env:"OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION" desc:"Disable the resolution of public link shares when answering PROPFIND requests. When disabled, the oc:share-type property will not be populated with public link share information, which can reduce load on services for large collections." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
type Log struct {
|
||||
|
||||
@@ -38,7 +38,7 @@ type SigningKeys struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TTL" desc:"Default time to live for signing keys. See the Environment Variable Types description for more details." introductionVersion:"5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;OCS_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -64,7 +64,7 @@ type Store struct {
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_PERSISTENT_STORE_TTL;POSTPROCESSING_STORE_TTL" desc:"Time to live for events in the store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;POSTPROCESSING_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;POSTPROCESSING_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;POSTPROCESSING_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;POSTPROCESSING_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;POSTPROCESSING_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_PERSISTENT_STORE_ENABLE_TLS;POSTPROCESSING_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_PERSISTENT_STORE_TLS_INSECURE;POSTPROCESSING_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the store connection. Only applies when store type 'nats-js-kv' is configured. Do not enable this in production because it disables authentication of the NATS server. Use it only for testing with self-signed certificates." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_PERSISTENT_STORE_TLS_ROOT_CA_CERTIFICATE;POSTPROCESSING_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
@@ -287,15 +287,19 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
|
||||
if cfg.EnableBasicAuth {
|
||||
logger.Warn().Msg("basic auth enabled, use only for testing or development")
|
||||
authenticators = append(authenticators, middleware.BasicAuthenticator{
|
||||
Logger: logger,
|
||||
UserProvider: userProvider,
|
||||
Logger: logger,
|
||||
UserProvider: userProvider,
|
||||
UserRoleAssigner: roleAssigner,
|
||||
MultiInstanceEnabled: cfg.MultiInstance.Enabled,
|
||||
})
|
||||
}
|
||||
|
||||
if cfg.AuthMiddleware.AllowAppAuth {
|
||||
authenticators = append(authenticators, middleware.AppAuthAuthenticator{
|
||||
Logger: logger,
|
||||
RevaGatewaySelector: gatewaySelector,
|
||||
Logger: logger,
|
||||
RevaGatewaySelector: gatewaySelector,
|
||||
UserRoleAssigner: roleAssigner,
|
||||
MultiInstanceEnabled: cfg.MultiInstance.Enabled,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -353,7 +357,6 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
|
||||
middleware.AllowAppAuth(cfg.AuthMiddleware.AllowAppAuth),
|
||||
middleware.TraceProvider(traceProvider),
|
||||
),
|
||||
middleware.MultiFactor(cfg.MultiFactorAuthentication, middleware.Logger(logger), middleware.MFAStore(signingKeyStore)),
|
||||
middleware.AccountResolver(
|
||||
middleware.Logger(logger),
|
||||
middleware.UserProvider(userProvider),
|
||||
@@ -365,6 +368,8 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
|
||||
middleware.EventsPublisher(publisher),
|
||||
middleware.MultiInstance(cfg.MultiInstance.Enabled, cfg.MultiInstance.InstanceID, cfg.MultiInstance.MasterID, cfg.MultiInstance.MemberClaim, cfg.MultiInstance.GuestClaim, cfg.MultiInstance.GuestRole),
|
||||
),
|
||||
// needs the user resolved by the AccountResolver
|
||||
middleware.MultiFactor(cfg.MultiFactorAuthentication, middleware.Logger(logger), middleware.MFAStore(signingKeyStore)),
|
||||
middleware.SelectorCookie(
|
||||
middleware.Logger(logger),
|
||||
middleware.PolicySelectorConfig(*cfg.PolicySelector),
|
||||
|
||||
@@ -141,15 +141,15 @@ type MFAConfig struct {
|
||||
type Cache struct {
|
||||
Store string `yaml:"store" env:"OCIS_CACHE_STORE;PROXY_OIDC_USERINFO_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0"`
|
||||
Nodes []string `yaml:"addresses" env:"OCIS_CACHE_STORE_NODES;PROXY_OIDC_USERINFO_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0"`
|
||||
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE;PROXY_OIDC_USERINFO_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"9.0" deprecationInfo:"The global variable OCIS_CACHE_DATABASE is deprecated and will be removed in a future release. Please use local variable PROXY_OIDC_USERINFO_CACHE_DATABASE instead."`
|
||||
Table string `yaml:"table" env:"PROXY_OIDC_USERINFO_CACHE_TABLE" desc:"The database table the store should use." introductionVersion:"pre5.0"`
|
||||
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;PROXY_OIDC_USERINFO_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0"`
|
||||
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;PROXY_OIDC_USERINFO_CACHE_DISABLE_PERSISTENCE" desc:"Disables persistence of the cache. Only applies when store type 'nats-js-kv' is configured. Defaults to false." introductionVersion:"pre5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;PROXY_OIDC_USERINFO_CACHE_AUTH_USERNAME" desc:"The username to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;PROXY_OIDC_USERINFO_CACHE_AUTH_PASSWORD" desc:"The password to authenticate with the cache. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_OIDC_USERINFO_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_OIDC_USERINFO_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_OIDC_USERINFO_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_OIDC_USERINFO_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the cache store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_OIDC_USERINFO_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the cache store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_OIDC_USERINFO_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the cache store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// RoleAssignment contains the configuration for how to assign roles to users during login
|
||||
@@ -205,9 +205,9 @@ type SigningKeys struct {
|
||||
DisablePersistence bool `yaml:"disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_DISABLE_PERSISTENCE" desc:"Disables persistence of the store. Only applies when store type 'nats-js-kv' is configured. Defaults to true." introductionVersion:"5.0"`
|
||||
AuthUsername string `yaml:"username" env:"OCIS_CACHE_AUTH_USERNAME;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
AuthPassword string `yaml:"password" env:"OCIS_CACHE_AUTH_PASSWORD;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"5.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"8.3.0"`
|
||||
EnableTLS bool `yaml:"enable_tls" env:"OCIS_CACHE_ENABLE_TLS;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_ENABLE_TLS" desc:"Activate TLS for the connection to the signing key store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSInsecure bool `yaml:"tls_insecure" env:"OCIS_CACHE_TLS_INSECURE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_INSECURE" desc:"Disable TLS certificate verification for the signing key store connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
TLSRootCACertificate string `yaml:"tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE;PROXY_PRESIGNEDURL_SIGNING_KEYS_STORE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the signing key store TLS connection. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"9.0.0"`
|
||||
}
|
||||
|
||||
// ClaimsSelectorConf is the config for the claims-selector
|
||||
|
||||
@@ -270,10 +270,22 @@ func DefaultPolicies() []config.Policy {
|
||||
Endpoint: "/graph/v1.0/invitations",
|
||||
Service: "com.owncloud.web.invitations",
|
||||
},
|
||||
{
|
||||
Endpoint: "/graph/v1beta1/extensions/org.libregraph/llm/",
|
||||
Service: "com.owncloud.web.llm",
|
||||
},
|
||||
{
|
||||
Endpoint: "/graph/",
|
||||
Service: "com.owncloud.web.graph",
|
||||
},
|
||||
{
|
||||
Endpoint: "/vault/graph/v1beta1/extensions/org.libregraph/activities",
|
||||
Service: "com.owncloud.web.activitylog",
|
||||
},
|
||||
{
|
||||
Endpoint: "/vault/graph/v1.0/invitations",
|
||||
Service: "com.owncloud.web.invitations",
|
||||
},
|
||||
{
|
||||
Endpoint: "/vault/graph/",
|
||||
Service: "com.owncloud.web.graph",
|
||||
|
||||
@@ -105,6 +105,15 @@ func (m accountResolver) verifyUser(w http.ResponseWriter, req *http.Request, us
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, backend.ErrAccountNotFound) {
|
||||
// the identity backend excludes disabled accounts from by-claim
|
||||
// lookups, so a disabled account also ends up here, not just a
|
||||
// genuinely unknown username.
|
||||
m.logger.Debug().Interface("user", user).Msg("Not found")
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
m.logger.Error().Err(err).Msg("Could not get user by claim")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
@@ -472,3 +472,35 @@ func TestResolveUserType(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestVerifyUserUnauthorizedOnUserNotFound covers the verifyUser fast path
|
||||
// (user already in context, e.g. via AppAuthAuthenticator/BasicAuthenticator),
|
||||
// as opposed to TestUnauthorizedOnUserNotFound which covers the claims-based
|
||||
// resolveUserFromClaims path. A disabled account is looked up by username and
|
||||
// comes back as ErrAccountNotFound (the identity backend excludes disabled
|
||||
// accounts from by-claim lookups), which must map to 401, not 500.
|
||||
func TestVerifyUserUnauthorizedOnUserNotFound(t *testing.T) {
|
||||
user := &userv1beta1.User{
|
||||
Id: &userv1beta1.UserId{Idp: "https://idx.example.com", OpaqueId: "123"},
|
||||
Username: "alice",
|
||||
}
|
||||
|
||||
ub := mocks.UserBackend{}
|
||||
ub.On("GetUserByClaims", mock.Anything, "username", "alice").Return(nil, "", backend.ErrAccountNotFound)
|
||||
|
||||
ra := userRoleMocks.UserRoleAssigner{}
|
||||
|
||||
sut := AccountResolver(
|
||||
Logger(log.NewLogger()),
|
||||
UserProvider(&ub),
|
||||
UserRoleAssigner(&ra),
|
||||
)(mockHandler{})
|
||||
|
||||
req := httptest.NewRequest("GET", "http://example.com/foo", nil)
|
||||
req = req.WithContext(revactx.ContextSetUser(context.Background(), user))
|
||||
rw := httptest.NewRecorder()
|
||||
|
||||
sut.ServeHTTP(rw, req)
|
||||
|
||||
assert.Equal(t, http.StatusUnauthorized, rw.Code)
|
||||
}
|
||||
Loaded 100 of 374 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user