mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-15 07:43:27 +00:00
Compare commits
45 Commits
ac/pm-1528
...
v2025.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
752132f0b0 | ||
|
|
50be1218e2 | ||
|
|
e4abb2c751 | ||
|
|
23c591f903 | ||
|
|
2ea2fd701c | ||
|
|
3b74be446e | ||
|
|
2651a53f27 | ||
|
|
09ed8326c3 | ||
|
|
c5a65a85ad | ||
|
|
3ae90cbb4c | ||
|
|
99dbb3162e | ||
|
|
f146d41b66 | ||
|
|
b35cf8e995 | ||
|
|
f7ee5dcd92 | ||
|
|
61bbff771e | ||
|
|
2047b6644e | ||
|
|
26dd9662cf | ||
|
|
70073fb570 | ||
|
|
8642b9d7aa | ||
|
|
d77b50c540 | ||
|
|
ed935d998a | ||
|
|
682da52040 | ||
|
|
531619af1d | ||
|
|
cf54858cc5 | ||
|
|
6cc022b135 | ||
|
|
a8a4390624 | ||
|
|
f9d817f0b1 | ||
|
|
112bda1137 | ||
|
|
23713d92fa | ||
|
|
6ebc9631aa | ||
|
|
e8579f11d3 | ||
|
|
6b2c7a5f00 | ||
|
|
2a1a5bf064 | ||
|
|
1464d72b27 | ||
|
|
f5cbd8f03d | ||
|
|
fdbbef68c1 | ||
|
|
efb412684d | ||
|
|
79f7a2b495 | ||
|
|
4342734412 | ||
|
|
62f14e5043 | ||
|
|
c2b22518fe | ||
|
|
37c992f16b | ||
|
|
69156677ac | ||
|
|
aaed7b13ea | ||
|
|
096d2a03ab |
6
.github/renovate.json
vendored
6
.github/renovate.json
vendored
@@ -7,6 +7,12 @@
|
|||||||
"groupName": "gh minor",
|
"groupName": "gh minor",
|
||||||
"matchManagers": ["github-actions"],
|
"matchManagers": ["github-actions"],
|
||||||
"matchUpdateTypes": ["minor", "patch"]
|
"matchUpdateTypes": ["minor", "patch"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupName": "Google Libraries",
|
||||||
|
"matchPackagePatterns": ["google-auth-library", "googleapis"],
|
||||||
|
"matchManagers": ["npm"],
|
||||||
|
"groupSlug": "google-libraries"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
68
.github/workflows/build.yml
vendored
68
.github/workflows/build.yml
vendored
@@ -5,6 +5,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
- "rc"
|
||||||
|
- "hotfix-rc"
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -13,7 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up CLOC
|
- name: Set up CLOC
|
||||||
run: |
|
run: |
|
||||||
@@ -31,7 +33,7 @@ jobs:
|
|||||||
package_version: ${{ steps.retrieve-version.outputs.package_version }}
|
package_version: ${{ steps.retrieve-version.outputs.package_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Get Package Version
|
- name: Get Package Version
|
||||||
id: retrieve-version
|
id: retrieve-version
|
||||||
@@ -50,10 +52,10 @@ jobs:
|
|||||||
_PKG_FETCH_VERSION: 3.4
|
_PKG_FETCH_VERSION: 3.4
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -121,14 +123,14 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload Linux Zip to GitHub
|
- name: Upload Linux Zip to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-linux-${{ env._PACKAGE_VERSION }}.zip
|
name: bwdc-linux-${{ env._PACKAGE_VERSION }}.zip
|
||||||
path: ./dist-cli/bwdc-linux-${{ env._PACKAGE_VERSION }}.zip
|
path: ./dist-cli/bwdc-linux-${{ env._PACKAGE_VERSION }}.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload Linux checksum to GitHub
|
- name: Upload Linux checksum to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
|
name: bwdc-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
path: ./dist-cli/bwdc-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
|
path: ./dist-cli/bwdc-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
@@ -145,10 +147,10 @@ jobs:
|
|||||||
_PKG_FETCH_VERSION: 3.4
|
_PKG_FETCH_VERSION: 3.4
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -209,14 +211,14 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload Mac Zip to GitHub
|
- name: Upload Mac Zip to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-macos-${{ env._PACKAGE_VERSION }}.zip
|
name: bwdc-macos-${{ env._PACKAGE_VERSION }}.zip
|
||||||
path: ./dist-cli/bwdc-macos-${{ env._PACKAGE_VERSION }}.zip
|
path: ./dist-cli/bwdc-macos-${{ env._PACKAGE_VERSION }}.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload Mac checksum to GitHub
|
- name: Upload Mac checksum to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
|
name: bwdc-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
path: ./dist-cli/bwdc-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
|
path: ./dist-cli/bwdc-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
@@ -232,7 +234,7 @@ jobs:
|
|||||||
_WIN_PKG_VERSION: 3.4
|
_WIN_PKG_VERSION: 3.4
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Setup Windows builder
|
- name: Setup Windows builder
|
||||||
run: |
|
run: |
|
||||||
@@ -240,7 +242,7 @@ jobs:
|
|||||||
choco install reshack --no-progress
|
choco install reshack --no-progress
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -353,14 +355,14 @@ jobs:
|
|||||||
-t sha256 | Out-File ./dist-cli/bwdc-windows-sha256-${env:_PACKAGE_VERSION}.txt
|
-t sha256 | Out-File ./dist-cli/bwdc-windows-sha256-${env:_PACKAGE_VERSION}.txt
|
||||||
|
|
||||||
- name: Upload Windows Zip to GitHub
|
- name: Upload Windows Zip to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-windows-${{ env._PACKAGE_VERSION }}.zip
|
name: bwdc-windows-${{ env._PACKAGE_VERSION }}.zip
|
||||||
path: ./dist-cli/bwdc-windows-${{ env._PACKAGE_VERSION }}.zip
|
path: ./dist-cli/bwdc-windows-${{ env._PACKAGE_VERSION }}.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload Windows checksum to GitHub
|
- name: Upload Windows checksum to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: bwdc-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
name: bwdc-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
path: ./dist-cli/bwdc-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
path: ./dist-cli/bwdc-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
||||||
@@ -377,10 +379,10 @@ jobs:
|
|||||||
HUSKY: 0
|
HUSKY: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -413,28 +415,28 @@ jobs:
|
|||||||
SIGNING_CERT_NAME: ${{ secrets.SIGNING_CERT_NAME }}
|
SIGNING_CERT_NAME: ${{ secrets.SIGNING_CERT_NAME }}
|
||||||
|
|
||||||
- name: Upload Portable Executable to GitHub
|
- name: Upload Portable Executable to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-Portable-${{ env._PACKAGE_VERSION }}.exe
|
name: Bitwarden-Connector-Portable-${{ env._PACKAGE_VERSION }}.exe
|
||||||
path: ./dist/Bitwarden-Connector-Portable-${{ env._PACKAGE_VERSION }}.exe
|
path: ./dist/Bitwarden-Connector-Portable-${{ env._PACKAGE_VERSION }}.exe
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload Installer Executable to GitHub
|
- name: Upload Installer Executable to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe
|
name: Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe
|
||||||
path: ./dist/Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe
|
path: ./dist/Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload Installer Executable Blockmap to GitHub
|
- name: Upload Installer Executable Blockmap to GitHub
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe.blockmap
|
name: Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe.blockmap
|
||||||
path: ./dist/Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe.blockmap
|
path: ./dist/Bitwarden-Connector-Installer-${{ env._PACKAGE_VERSION }}.exe.blockmap
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload latest auto-update artifact
|
- name: Upload latest auto-update artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: latest.yml
|
name: latest.yml
|
||||||
path: ./dist/latest.yml
|
path: ./dist/latest.yml
|
||||||
@@ -451,10 +453,10 @@ jobs:
|
|||||||
HUSKY: 0
|
HUSKY: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -481,14 +483,14 @@ jobs:
|
|||||||
run: npm run dist:lin
|
run: npm run dist:lin
|
||||||
|
|
||||||
- name: Upload AppImage
|
- name: Upload AppImage
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-x86_64.AppImage
|
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-x86_64.AppImage
|
||||||
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-x86_64.AppImage
|
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-x86_64.AppImage
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload latest auto-update artifact
|
- name: Upload latest auto-update artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: latest-linux.yml
|
name: latest-linux.yml
|
||||||
path: ./dist/latest-linux.yml
|
path: ./dist/latest-linux.yml
|
||||||
@@ -505,10 +507,10 @@ jobs:
|
|||||||
HUSKY: 0
|
HUSKY: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -592,28 +594,28 @@ jobs:
|
|||||||
CSC_FOR_PULL_REQUEST: true
|
CSC_FOR_PULL_REQUEST: true
|
||||||
|
|
||||||
- name: Upload .zip artifact
|
- name: Upload .zip artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-mac.zip
|
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-mac.zip
|
||||||
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-mac.zip
|
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}-mac.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload .dmg artifact
|
- name: Upload .dmg artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg
|
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg
|
||||||
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg
|
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload .dmg Blockmap artifact
|
- name: Upload .dmg Blockmap artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg.blockmap
|
name: Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg.blockmap
|
||||||
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg.blockmap
|
path: ./dist/Bitwarden-Connector-${{ env._PACKAGE_VERSION }}.dmg.blockmap
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload latest auto-update artifact
|
- name: Upload latest auto-update artifact
|
||||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||||
with:
|
with:
|
||||||
name: latest-mac.yml
|
name: latest-mac.yml
|
||||||
path: ./dist/latest-mac.yml
|
path: ./dist/latest-mac.yml
|
||||||
@@ -634,7 +636,11 @@ jobs:
|
|||||||
- macos-gui
|
- macos-gui
|
||||||
steps:
|
steps:
|
||||||
- name: Check if any job failed
|
- name: Check if any job failed
|
||||||
if: github.ref == 'refs/heads/main' && contains(needs.*.result, 'failure')
|
if: |
|
||||||
|
(github.ref == 'refs/heads/main'
|
||||||
|
|| github.ref == 'refs/heads/rc'
|
||||||
|
|| github.ref == 'refs/heads/hotfix-rc')
|
||||||
|
&& contains(needs.*.result, 'failure')
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
||||||
- name: Login to Azure - CI subscription
|
- name: Login to Azure - CI subscription
|
||||||
|
|||||||
36
.github/workflows/integration-test.yml
vendored
36
.github/workflows/integration-test.yml
vendored
@@ -8,39 +8,21 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- ".github/workflows/integration-test.yml" # this file
|
- ".github/workflows/integration-test.yml" # this file
|
||||||
- "src/services/ldap-directory.service*" # we only have integration for LDAP testing at the moment
|
- "src/services/ldap-directory.service*" # we only have integration for LDAP testing at the moment
|
||||||
- "./openldap*" # any change to test fixtures
|
- "./openldap/**/*" # any change to test fixtures
|
||||||
- "./docker-compose.yml" # any change to Docker configuration
|
- "./docker-compose.yml" # any change to Docker configuration
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/integration-test.yml" # this file
|
- ".github/workflows/integration-test.yml" # this file
|
||||||
- "src/services/ldap-directory.service*" # we only have integration for LDAP testing at the moment
|
- "src/services/ldap-directory.service*" # we only have integration for LDAP testing at the moment
|
||||||
- "./openldap*" # any change to test fixtures
|
- "./openldap/**/*" # any change to test fixtures
|
||||||
- "./docker-compose.yml" # any change to Docker configuration
|
- "./docker-compose.yml" # any change to Docker configuration
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-test-secrets:
|
|
||||||
name: Check for test secrets
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
outputs:
|
|
||||||
available: ${{ steps.check-test-secrets.outputs.available }}
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check
|
|
||||||
id: check-test-secrets
|
|
||||||
run: |
|
|
||||||
if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then
|
|
||||||
echo "available=true" >> $GITHUB_OUTPUT;
|
|
||||||
else
|
|
||||||
echo "available=false" >> $GITHUB_OUTPUT;
|
|
||||||
fi
|
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
if: ${{ startsWith(github.head_ref, 'version_bump_') == false }}
|
if: ${{ startsWith(github.head_ref, 'version_bump_') == false }}
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs: check-test-secrets
|
|
||||||
permissions:
|
permissions:
|
||||||
checks: write
|
checks: write
|
||||||
contents: read
|
contents: read
|
||||||
@@ -48,7 +30,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Get Node version
|
- name: Get Node version
|
||||||
id: retrieve-node-version
|
id: retrieve-node-version
|
||||||
@@ -58,7 +40,7 @@ jobs:
|
|||||||
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -80,7 +62,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Report test results
|
- name: Report test results
|
||||||
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
|
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }}
|
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !cancelled() }}
|
||||||
with:
|
with:
|
||||||
name: Test Results
|
name: Test Results
|
||||||
path: "junit.xml"
|
path: "junit.xml"
|
||||||
@@ -88,13 +70,9 @@ jobs:
|
|||||||
fail-on-error: true
|
fail-on-error: true
|
||||||
|
|
||||||
- name: Upload coverage to codecov.io
|
- name: Upload coverage to codecov.io
|
||||||
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
|
uses: codecov/codecov-action@5a605bd92782ce0810fa3b8acc235c921b497052 # v5.2.0
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
|
|
||||||
env:
|
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
|
|
||||||
- name: Upload results to codecov.io
|
- name: Upload results to codecov.io
|
||||||
uses: codecov/test-results-action@1b5b448b98e58ba90d1a1a1d9fcb72ca2263be46 # v1.0.0
|
uses: codecov/test-results-action@4e79e65778be1cecd5df25e14af1eafb6df80ea9 # v1.0.2
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
|
|
||||||
env:
|
env:
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
@@ -18,17 +18,17 @@ jobs:
|
|||||||
name: Setup
|
name: Setup
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
outputs:
|
outputs:
|
||||||
release-version: ${{ steps.version.outputs.version }}
|
release_version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Branch check
|
- name: Branch check
|
||||||
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
|
||||||
echo "==================================="
|
echo "==================================="
|
||||||
echo "[!] Can only release from the 'main' branch"
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
|
||||||
echo "==================================="
|
echo "==================================="
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
id: version
|
id: version
|
||||||
uses: bitwarden/gh-actions/release-version-check@main
|
uses: bitwarden/gh-actions/release-version-check@main
|
||||||
with:
|
with:
|
||||||
release-type: ${{ github.event.inputs.release_type }}
|
release-type: ${{ inputs.release_type }}
|
||||||
project-type: ts
|
project-type: ts
|
||||||
file: package.json
|
file: package.json
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
needs: setup
|
needs: setup
|
||||||
steps:
|
steps:
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
||||||
uses: bitwarden/gh-actions/download-artifacts@main
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
with:
|
with:
|
||||||
workflow: build.yml
|
workflow: build.yml
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
branch: ${{ github.ref_name }}
|
branch: ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Dry Run - Download all artifacts
|
- name: Dry Run - Download all artifacts
|
||||||
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
if: ${{ inputs.release_type == 'Dry Run' }}
|
||||||
uses: bitwarden/gh-actions/download-artifacts@main
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
with:
|
with:
|
||||||
workflow: build.yml
|
workflow: build.yml
|
||||||
@@ -63,10 +63,10 @@ jobs:
|
|||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
||||||
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
|
uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0
|
||||||
env:
|
env:
|
||||||
PKG_VERSION: ${{ needs.setup.outputs.release-version }}
|
PKG_VERSION: ${{ needs.setup.outputs.release_version }}
|
||||||
with:
|
with:
|
||||||
artifacts: "./bwdc-windows-${{ env.PKG_VERSION }}.zip,
|
artifacts: "./bwdc-windows-${{ env.PKG_VERSION }}.zip,
|
||||||
./bwdc-macos-${{ env.PKG_VERSION }}.zip,
|
./bwdc-macos-${{ env.PKG_VERSION }}.zip,
|
||||||
|
|||||||
14
.github/workflows/scan.yml
vendored
14
.github/workflows/scan.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Scan with Checkmarx
|
- name: Scan with Checkmarx
|
||||||
uses: checkmarx/ast-github-action@ed196cdaec9cd1bc5aacac4ca2010dd773b20893 # 2.0.35
|
uses: checkmarx/ast-github-action@184bf2f64f55d1c93fd6636d539edf274703e434 # 2.0.41
|
||||||
env:
|
env:
|
||||||
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
|
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
|
||||||
with:
|
with:
|
||||||
@@ -44,9 +44,11 @@ jobs:
|
|||||||
--output-path . ${{ env.INCREMENTAL }}
|
--output-path . ${{ env.INCREMENTAL }}
|
||||||
|
|
||||||
- name: Upload Checkmarx results to GitHub
|
- name: Upload Checkmarx results to GitHub
|
||||||
uses: github/codeql-action/upload-sarif@e2b3eafc8d227b0241d48be5f425d47c2d750a13 # v3.26.10
|
uses: github/codeql-action/upload-sarif@dd196fa9ce80b6bacc74ca1c32bd5b0ba22efca7 # v3.28.3
|
||||||
with:
|
with:
|
||||||
sarif_file: cx_result.sarif
|
sarif_file: cx_result.sarif
|
||||||
|
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
|
||||||
|
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
|
||||||
|
|
||||||
quality:
|
quality:
|
||||||
name: Quality scan
|
name: Quality scan
|
||||||
@@ -58,16 +60,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Scan with SonarCloud
|
- name: Scan with SonarCloud
|
||||||
uses: sonarsource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b # v3.0.0
|
uses: sonarsource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 # v4.2.1
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
with:
|
||||||
args: >
|
args: >
|
||||||
-Dsonar.organization=${{ github.repository_owner }}
|
-Dsonar.organization=${{ github.repository_owner }}
|
||||||
@@ -76,3 +77,4 @@ jobs:
|
|||||||
-Dsonar.sources=.
|
-Dsonar.sources=.
|
||||||
-Dsonar.test.inclusions=**/*.spec.ts
|
-Dsonar.test.inclusions=**/*.spec.ts
|
||||||
-Dsonar.exclusions=**/*.spec.ts
|
-Dsonar.exclusions=**/*.spec.ts
|
||||||
|
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
|
||||||
|
|||||||
34
.github/workflows/test.yml
vendored
34
.github/workflows/test.yml
vendored
@@ -5,32 +5,16 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
- "rc"
|
||||||
|
- "hotfix-rc"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-test-secrets:
|
|
||||||
name: Check for test secrets
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
outputs:
|
|
||||||
available: ${{ steps.check-test-secrets.outputs.available }}
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check
|
|
||||||
id: check-test-secrets
|
|
||||||
run: |
|
|
||||||
if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then
|
|
||||||
echo "available=true" >> $GITHUB_OUTPUT;
|
|
||||||
else
|
|
||||||
echo "available=false" >> $GITHUB_OUTPUT;
|
|
||||||
fi
|
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
if: ${{ startsWith(github.head_ref, 'version_bump_') == false }}
|
if: ${{ startsWith(github.head_ref, 'version_bump_') == false }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: check-test-secrets
|
|
||||||
permissions:
|
permissions:
|
||||||
checks: write
|
checks: write
|
||||||
contents: read
|
contents: read
|
||||||
@@ -38,7 +22,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Get Node version
|
- name: Get Node version
|
||||||
id: retrieve-node-version
|
id: retrieve-node-version
|
||||||
@@ -48,7 +32,7 @@ jobs:
|
|||||||
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
cache-dependency-path: '**/package-lock.json'
|
cache-dependency-path: '**/package-lock.json'
|
||||||
@@ -68,7 +52,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Report test results
|
- name: Report test results
|
||||||
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
|
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }}
|
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !cancelled() }}
|
||||||
with:
|
with:
|
||||||
name: Test Results
|
name: Test Results
|
||||||
path: "junit.xml"
|
path: "junit.xml"
|
||||||
@@ -76,13 +60,9 @@ jobs:
|
|||||||
fail-on-error: true
|
fail-on-error: true
|
||||||
|
|
||||||
- name: Upload coverage to codecov.io
|
- name: Upload coverage to codecov.io
|
||||||
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
|
uses: codecov/codecov-action@5a605bd92782ce0810fa3b8acc235c921b497052 # v5.2.0
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
|
|
||||||
env:
|
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
|
|
||||||
- name: Upload results to codecov.io
|
- name: Upload results to codecov.io
|
||||||
uses: codecov/test-results-action@1b5b448b98e58ba90d1a1a1d9fcb72ca2263be46 # v1.0.0
|
uses: codecov/test-results-action@4e79e65778be1cecd5df25e14af1eafb6df80ea9 # v1.0.2
|
||||||
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
|
|
||||||
env:
|
env:
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
4
.github/workflows/version-bump.yml
vendored
4
.github/workflows/version-bump.yml
vendored
@@ -20,14 +20,14 @@ jobs:
|
|||||||
version: ${{ inputs.version_number_override }}
|
version: ${{ inputs.version_number_override }}
|
||||||
|
|
||||||
- name: Generate GH App token
|
- name: Generate GH App token
|
||||||
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
|
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ secrets.BW_GHAPP_ID }}
|
app-id: ${{ secrets.BW_GHAPP_ID }}
|
||||||
private-key: ${{ secrets.BW_GHAPP_KEY }}
|
private-key: ${{ secrets.BW_GHAPP_KEY }}
|
||||||
|
|
||||||
- name: Checkout Branch
|
- name: Checkout Branch
|
||||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { ApiTokenRequest } from "../models/request/identityToken/apiTokenRequest
|
|||||||
import { PasswordTokenRequest } from "../models/request/identityToken/passwordTokenRequest";
|
import { PasswordTokenRequest } from "../models/request/identityToken/passwordTokenRequest";
|
||||||
import { SsoTokenRequest } from "../models/request/identityToken/ssoTokenRequest";
|
import { SsoTokenRequest } from "../models/request/identityToken/ssoTokenRequest";
|
||||||
import { OrganizationImportRequest } from "../models/request/organizationImportRequest";
|
import { OrganizationImportRequest } from "../models/request/organizationImportRequest";
|
||||||
import { IdentityCaptchaResponse } from '../models/response/identityCaptchaResponse';
|
import { IdentityCaptchaResponse } from "../models/response/identityCaptchaResponse";
|
||||||
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
|
import { IdentityTokenResponse } from "../models/response/identityTokenResponse";
|
||||||
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
import { IdentityTwoFactorResponse } from "../models/response/identityTwoFactorResponse";
|
||||||
|
|
||||||
export abstract class ApiService {
|
export abstract class ApiService {
|
||||||
postIdentityToken: (
|
postIdentityToken: (
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ export class TrayMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupWindowListeners(win: BrowserWindow) {
|
setupWindowListeners(win: BrowserWindow) {
|
||||||
win.on("minimize", async (e: Event) => {
|
win.on("minimize", async () => {
|
||||||
if (await this.stateService.getEnableMinimizeToTray()) {
|
if (await this.stateService.getEnableMinimizeToTray()) {
|
||||||
e.preventDefault();
|
|
||||||
this.hideToTray();
|
this.hideToTray();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
340708
openldap/example-ldifs/directory-11000.ldif
Normal file
340708
openldap/example-ldifs/directory-11000.ldif
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,5 +6,5 @@ fi
|
|||||||
|
|
||||||
mkcert -install
|
mkcert -install
|
||||||
mkdir -p ./openldap/certs
|
mkdir -p ./openldap/certs
|
||||||
cp $(mkcert -CAROOT)/rootCA.pem ./openldap/certs/rootCA.pem
|
cp "$(mkcert -CAROOT)/rootCA.pem" ./openldap/certs/rootCA.pem
|
||||||
mkcert -key-file ./openldap/certs/openldap-key.pem -cert-file ./openldap/certs/openldap.pem localhost openldap
|
mkcert -key-file ./openldap/certs/openldap-key.pem -cert-file ./openldap/certs/openldap.pem localhost openldap
|
||||||
|
|||||||
5155
package-lock.json
generated
5155
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
57
package.json
57
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "@bitwarden/directory-connector",
|
"name": "@bitwarden/directory-connector",
|
||||||
"productName": "Bitwarden Directory Connector",
|
"productName": "Bitwarden Directory Connector",
|
||||||
"description": "Sync your user directory to your Bitwarden organization.",
|
"description": "Sync your user directory to your Bitwarden organization.",
|
||||||
"version": "2024.10.0",
|
"version": "2025.3.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"bitwarden",
|
"bitwarden",
|
||||||
"password",
|
"password",
|
||||||
@@ -85,28 +85,28 @@
|
|||||||
"@types/inquirer": "8.2.10",
|
"@types/inquirer": "8.2.10",
|
||||||
"@types/jest": "29.5.14",
|
"@types/jest": "29.5.14",
|
||||||
"@types/lowdb": "1.0.15",
|
"@types/lowdb": "1.0.15",
|
||||||
"@types/node": "20.17.9",
|
"@types/node": "22.13.1",
|
||||||
"@types/node-fetch": "2.6.12",
|
"@types/node-fetch": "2.6.12",
|
||||||
"@types/node-forge": "1.3.11",
|
"@types/node-forge": "1.3.11",
|
||||||
"@types/proper-lockfile": "4.1.4",
|
"@types/proper-lockfile": "4.1.4",
|
||||||
"@types/tldjs": "2.3.4",
|
"@types/tldjs": "2.3.4",
|
||||||
"@typescript-eslint/eslint-plugin": "5.62.0",
|
"@typescript-eslint/eslint-plugin": "8.23.0",
|
||||||
"@typescript-eslint/parser": "5.62.0",
|
"@typescript-eslint/parser": "8.23.0",
|
||||||
"clean-webpack-plugin": "4.0.0",
|
"clean-webpack-plugin": "4.0.0",
|
||||||
"concurrently": "9.1.0",
|
"concurrently": "9.1.2",
|
||||||
"copy-webpack-plugin": "12.0.2",
|
"copy-webpack-plugin": "12.0.2",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"css-loader": "7.1.2",
|
"css-loader": "7.1.2",
|
||||||
"dotenv": "16.4.5",
|
"dotenv": "16.4.7",
|
||||||
"electron": "28.3.3",
|
"electron": "34.1.1",
|
||||||
"electron-builder": "24.13.3",
|
"electron-builder": "24.13.3",
|
||||||
"electron-log": "5.2.4",
|
"electron-log": "5.2.4",
|
||||||
"electron-reload": "2.0.0-alpha.1",
|
"electron-reload": "2.0.0-alpha.1",
|
||||||
"electron-store": "8.2.0",
|
"electron-store": "8.2.0",
|
||||||
"electron-updater": "6.3.9",
|
"electron-updater": "6.3.9",
|
||||||
"eslint": "8.57.1",
|
"eslint": "8.57.1",
|
||||||
"eslint-config-prettier": "9.1.0",
|
"eslint-config-prettier": "10.0.1",
|
||||||
"eslint-import-resolver-typescript": "3.6.3",
|
"eslint-import-resolver-typescript": "3.7.0",
|
||||||
"eslint-plugin-import": "2.31.0",
|
"eslint-plugin-import": "2.31.0",
|
||||||
"eslint-plugin-rxjs": "5.0.3",
|
"eslint-plugin-rxjs": "5.0.3",
|
||||||
"eslint-plugin-rxjs-angular": "2.0.1",
|
"eslint-plugin-rxjs-angular": "2.0.1",
|
||||||
@@ -117,28 +117,29 @@
|
|||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"jest-junit": "16.0.0",
|
"jest-junit": "16.0.0",
|
||||||
"jest-mock-extended": "3.0.7",
|
"jest-mock-extended": "3.0.7",
|
||||||
"jest-preset-angular": "14.4.2",
|
"jest-preset-angular": "14.5.0",
|
||||||
"lint-staged": "15.2.10",
|
"lint-staged": "15.4.1",
|
||||||
"mini-css-extract-plugin": "2.9.2",
|
"mini-css-extract-plugin": "2.9.2",
|
||||||
|
"minimatch": "3.1.2",
|
||||||
|
"node-abi": "3.74.0",
|
||||||
"node-forge": "1.3.1",
|
"node-forge": "1.3.1",
|
||||||
"node-loader": "2.1.0",
|
"node-loader": "2.1.0",
|
||||||
"pkg": "5.8.1",
|
"pkg": "5.8.1",
|
||||||
"prettier": "3.3.3",
|
"prettier": "3.4.2",
|
||||||
"rimraf": "5.0.10",
|
"rimraf": "6.0.1",
|
||||||
"rxjs": "7.8.1",
|
"rxjs": "7.8.1",
|
||||||
"sass": "1.79.4",
|
"sass": "1.79.4",
|
||||||
"sass-loader": "16.0.4",
|
"sass-loader": "16.0.4",
|
||||||
"ts-jest": "29.2.5",
|
"ts-jest": "29.2.5",
|
||||||
"ts-loader": "9.5.1",
|
"ts-loader": "9.5.2",
|
||||||
"tsconfig-paths-webpack-plugin": "4.2.0",
|
"tsconfig-paths-webpack-plugin": "4.2.0",
|
||||||
"type-fest": "4.30.0",
|
"type-fest": "4.32.0",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.4.5",
|
||||||
"typescript-transform-paths": "3.5.2",
|
"webpack": "5.97.1",
|
||||||
"webpack": "5.95.0",
|
"webpack-cli": "6.0.1",
|
||||||
"webpack-cli": "5.1.4",
|
|
||||||
"webpack-merge": "6.0.1",
|
"webpack-merge": "6.0.1",
|
||||||
"zone.js": "0.14.10",
|
"webpack-node-externals": "3.0.0",
|
||||||
"webpack-node-externals": "3.0.0"
|
"zone.js": "0.14.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "17.3.12",
|
"@angular/animations": "17.3.12",
|
||||||
@@ -155,17 +156,17 @@
|
|||||||
"bootstrap": "5.3.3",
|
"bootstrap": "5.3.3",
|
||||||
"browser-hrtime": "1.1.8",
|
"browser-hrtime": "1.1.8",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"commander": "12.1.0",
|
"commander": "13.1.0",
|
||||||
"core-js": "3.38.1",
|
"core-js": "3.40.0",
|
||||||
"form-data": "4.0.1",
|
"form-data": "4.0.1",
|
||||||
"google-auth-library": "7.14.1",
|
"google-auth-library": "9.15.1",
|
||||||
"googleapis": "73.0.0",
|
"googleapis": "144.0.0",
|
||||||
"https-proxy-agent": "7.0.5",
|
"https-proxy-agent": "7.0.6",
|
||||||
"inquirer": "8.2.6",
|
"inquirer": "8.2.6",
|
||||||
"keytar": "7.9.0",
|
"keytar": "7.9.0",
|
||||||
"ldapts": "7.2.1",
|
"ldapts": "7.3.1",
|
||||||
"lowdb": "1.0.0",
|
"lowdb": "1.0.0",
|
||||||
"ngx-toastr": "17.0.2",
|
"ngx-toastr": "19.0.0",
|
||||||
"node-fetch": "2.7.0",
|
"node-fetch": "2.7.0",
|
||||||
"proper-lockfile": "4.1.2",
|
"proper-lockfile": "4.1.2",
|
||||||
"rxjs": "7.8.1",
|
"rxjs": "7.8.1",
|
||||||
@@ -173,7 +174,7 @@
|
|||||||
"zone.js": "0.14.10"
|
"zone.js": "0.14.10"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "~20.18.0",
|
"node": "~22.13.0",
|
||||||
"npm": "~10"
|
"npm": "~10"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|||||||
2
src-cli/package-lock.json
generated
2
src-cli/package-lock.json
generated
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@bitwarden/directory-connector",
|
"name": "@bitwarden/directory-connector",
|
||||||
"version": "2.9.5",
|
"version": "2.9.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
|||||||
6
src/abstractions/directory-factory.service.ts
Normal file
6
src/abstractions/directory-factory.service.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { DirectoryType } from "@/src/enums/directoryType";
|
||||||
|
import { IDirectoryService } from "@/src/services/directory.service";
|
||||||
|
|
||||||
|
export abstract class DirectoryFactoryService {
|
||||||
|
abstract createService(type: DirectoryType): IDirectoryService;
|
||||||
|
}
|
||||||
13
src/abstractions/request-builder.service.ts
Normal file
13
src/abstractions/request-builder.service.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
||||||
|
|
||||||
|
import { GroupEntry } from "@/src/models/groupEntry";
|
||||||
|
import { UserEntry } from "@/src/models/userEntry";
|
||||||
|
|
||||||
|
export abstract class RequestBuilder {
|
||||||
|
buildRequest: (
|
||||||
|
groups: GroupEntry[],
|
||||||
|
users: UserEntry[],
|
||||||
|
removeDisabled: boolean,
|
||||||
|
overwriteExisting: boolean,
|
||||||
|
) => OrganizationImportRequest[];
|
||||||
|
}
|
||||||
@@ -25,6 +25,11 @@ import { ElectronRendererStorageService } from "@/jslib/electron/src/services/el
|
|||||||
import { NodeApiService } from "@/jslib/node/src/services/nodeApi.service";
|
import { NodeApiService } from "@/jslib/node/src/services/nodeApi.service";
|
||||||
import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service";
|
import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service";
|
||||||
|
|
||||||
|
import { DirectoryFactoryService } from "@/src/abstractions/directory-factory.service";
|
||||||
|
import { BatchRequestBuilder } from "@/src/services/batch-request-builder";
|
||||||
|
import { DefaultDirectoryFactoryService } from "@/src/services/directory-factory.service";
|
||||||
|
import { SingleRequestBuilder } from "@/src/services/single-request-builder";
|
||||||
|
|
||||||
import { AuthService as AuthServiceAbstraction } from "../../abstractions/auth.service";
|
import { AuthService as AuthServiceAbstraction } from "../../abstractions/auth.service";
|
||||||
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
||||||
import { Account } from "../../models/account";
|
import { Account } from "../../models/account";
|
||||||
@@ -168,13 +173,15 @@ export function initFactory(
|
|||||||
provide: SyncService,
|
provide: SyncService,
|
||||||
useClass: SyncService,
|
useClass: SyncService,
|
||||||
deps: [
|
deps: [
|
||||||
LogServiceAbstraction,
|
|
||||||
CryptoFunctionServiceAbstraction,
|
CryptoFunctionServiceAbstraction,
|
||||||
ApiServiceAbstraction,
|
ApiServiceAbstraction,
|
||||||
MessagingServiceAbstraction,
|
MessagingServiceAbstraction,
|
||||||
I18nServiceAbstraction,
|
I18nServiceAbstraction,
|
||||||
EnvironmentServiceAbstraction,
|
EnvironmentServiceAbstraction,
|
||||||
StateServiceAbstraction,
|
StateServiceAbstraction,
|
||||||
|
BatchRequestBuilder,
|
||||||
|
SingleRequestBuilder,
|
||||||
|
DirectoryFactoryService,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
safeProvider(AuthGuardService),
|
safeProvider(AuthGuardService),
|
||||||
@@ -215,6 +222,19 @@ export function initFactory(
|
|||||||
StateMigrationServiceAbstraction,
|
StateMigrationServiceAbstraction,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: SingleRequestBuilder,
|
||||||
|
deps: [],
|
||||||
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: BatchRequestBuilder,
|
||||||
|
deps: [],
|
||||||
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: DirectoryFactoryService,
|
||||||
|
useClass: DefaultDirectoryFactoryService,
|
||||||
|
deps: [LogServiceAbstraction, I18nServiceAbstraction, StateServiceAbstraction],
|
||||||
|
}),
|
||||||
] satisfies SafeProvider[],
|
] satisfies SafeProvider[],
|
||||||
})
|
})
|
||||||
export class ServicesModule {}
|
export class ServicesModule {}
|
||||||
|
|||||||
20
src/bwdc.ts
20
src/bwdc.ts
@@ -17,12 +17,16 @@ import { ConsoleLogService } from "@/jslib/node/src/cli/services/consoleLog.serv
|
|||||||
import { NodeApiService } from "@/jslib/node/src/services/nodeApi.service";
|
import { NodeApiService } from "@/jslib/node/src/services/nodeApi.service";
|
||||||
import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service";
|
import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service";
|
||||||
|
|
||||||
|
import { DirectoryFactoryService } from "./abstractions/directory-factory.service";
|
||||||
import { Account } from "./models/account";
|
import { Account } from "./models/account";
|
||||||
import { Program } from "./program";
|
import { Program } from "./program";
|
||||||
import { AuthService } from "./services/auth.service";
|
import { AuthService } from "./services/auth.service";
|
||||||
|
import { BatchRequestBuilder } from "./services/batch-request-builder";
|
||||||
|
import { DefaultDirectoryFactoryService } from "./services/directory-factory.service";
|
||||||
import { I18nService } from "./services/i18n.service";
|
import { I18nService } from "./services/i18n.service";
|
||||||
import { KeytarSecureStorageService } from "./services/keytarSecureStorage.service";
|
import { KeytarSecureStorageService } from "./services/keytarSecureStorage.service";
|
||||||
import { LowdbStorageService } from "./services/lowdbStorage.service";
|
import { LowdbStorageService } from "./services/lowdbStorage.service";
|
||||||
|
import { SingleRequestBuilder } from "./services/single-request-builder";
|
||||||
import { StateService } from "./services/state.service";
|
import { StateService } from "./services/state.service";
|
||||||
import { StateMigrationService } from "./services/stateMigration.service";
|
import { StateMigrationService } from "./services/stateMigration.service";
|
||||||
import { SyncService } from "./services/sync.service";
|
import { SyncService } from "./services/sync.service";
|
||||||
@@ -51,6 +55,9 @@ export class Main {
|
|||||||
syncService: SyncService;
|
syncService: SyncService;
|
||||||
stateService: StateService;
|
stateService: StateService;
|
||||||
stateMigrationService: StateMigrationService;
|
stateMigrationService: StateMigrationService;
|
||||||
|
directoryFactoryService: DirectoryFactoryService;
|
||||||
|
batchRequestBuilder: BatchRequestBuilder;
|
||||||
|
singleRequestBuilder: SingleRequestBuilder;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const applicationName = "Bitwarden Directory Connector";
|
const applicationName = "Bitwarden Directory Connector";
|
||||||
@@ -146,14 +153,25 @@ export class Main {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncService = new SyncService(
|
this.directoryFactoryService = new DefaultDirectoryFactoryService(
|
||||||
this.logService,
|
this.logService,
|
||||||
|
this.i18nService,
|
||||||
|
this.stateService,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.batchRequestBuilder = new BatchRequestBuilder();
|
||||||
|
this.singleRequestBuilder = new SingleRequestBuilder();
|
||||||
|
|
||||||
|
this.syncService = new SyncService(
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
|
this.batchRequestBuilder,
|
||||||
|
this.singleRequestBuilder,
|
||||||
|
this.directoryFactoryService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.program = new Program(this);
|
this.program = new Program(this);
|
||||||
|
|||||||
70
src/services/batch-request-builder.ts
Normal file
70
src/services/batch-request-builder.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
||||||
|
|
||||||
|
import { GroupEntry } from "@/src/models/groupEntry";
|
||||||
|
import { UserEntry } from "@/src/models/userEntry";
|
||||||
|
|
||||||
|
import { RequestBuilder } from "../abstractions/request-builder.service";
|
||||||
|
|
||||||
|
import { batchSize } from "./sync.service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is responsible for batching large sync requests (>2k users) into multiple smaller
|
||||||
|
* requests to the /import endpoint. This is done to ensure we are under the default
|
||||||
|
* maximum packet size for NGINX web servers to avoid the request potentially timing out
|
||||||
|
* */
|
||||||
|
export class BatchRequestBuilder implements RequestBuilder {
|
||||||
|
buildRequest(
|
||||||
|
groups: GroupEntry[],
|
||||||
|
users: UserEntry[],
|
||||||
|
removeDisabled: boolean,
|
||||||
|
overwriteExisting: boolean,
|
||||||
|
): OrganizationImportRequest[] {
|
||||||
|
const requests: OrganizationImportRequest[] = [];
|
||||||
|
|
||||||
|
if (users.length > 0) {
|
||||||
|
const usersRequest = users.map((u) => {
|
||||||
|
return {
|
||||||
|
email: u.email,
|
||||||
|
externalId: u.externalId,
|
||||||
|
deleted: u.deleted || (removeDisabled && u.disabled),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Partition users
|
||||||
|
for (let i = 0; i < usersRequest.length; i += batchSize) {
|
||||||
|
const u = usersRequest.slice(i, i + batchSize);
|
||||||
|
const req = new OrganizationImportRequest({
|
||||||
|
groups: [],
|
||||||
|
users: u,
|
||||||
|
largeImport: true,
|
||||||
|
overwriteExisting,
|
||||||
|
});
|
||||||
|
requests.push(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groups.length > 0) {
|
||||||
|
const groupRequest = groups.map((g) => {
|
||||||
|
return {
|
||||||
|
name: g.name,
|
||||||
|
externalId: g.externalId,
|
||||||
|
memberExternalIds: Array.from(g.userMemberExternalIds),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Partition groups
|
||||||
|
for (let i = 0; i < groupRequest.length; i += batchSize) {
|
||||||
|
const g = groupRequest.slice(i, i + batchSize);
|
||||||
|
const req = new OrganizationImportRequest({
|
||||||
|
groups: g,
|
||||||
|
users: [],
|
||||||
|
largeImport: true,
|
||||||
|
overwriteExisting,
|
||||||
|
});
|
||||||
|
requests.push(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/services/batch-requests-builder.spec.ts
Normal file
47
src/services/batch-requests-builder.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { GroupEntry } from "@/src/models/groupEntry";
|
||||||
|
import { UserEntry } from "@/src/models/userEntry";
|
||||||
|
|
||||||
|
import { BatchRequestBuilder } from "./batch-request-builder";
|
||||||
|
import { SingleRequestBuilder } from "./single-request-builder";
|
||||||
|
|
||||||
|
describe("BatchRequestBuilder", () => {
|
||||||
|
let batchRequestBuilder: BatchRequestBuilder;
|
||||||
|
let singleRequestBuilder: SingleRequestBuilder;
|
||||||
|
|
||||||
|
function userSimulator(userCount: number) {
|
||||||
|
return Array(userCount).fill(new UserEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupSimulator(groupCount: number) {
|
||||||
|
return Array(groupCount).fill(new GroupEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
batchRequestBuilder = new BatchRequestBuilder();
|
||||||
|
singleRequestBuilder = new SingleRequestBuilder();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("BatchRequestBuilder batches requests for > 2000 users", () => {
|
||||||
|
const mockGroups = groupSimulator(11000);
|
||||||
|
const mockUsers = userSimulator(11000);
|
||||||
|
|
||||||
|
const requests = batchRequestBuilder.buildRequest(mockGroups, mockUsers, true, true);
|
||||||
|
|
||||||
|
expect(requests.length).toEqual(12);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("SingleRequestBuilder returns single request for 200 users", () => {
|
||||||
|
const mockGroups = groupSimulator(200);
|
||||||
|
const mockUsers = userSimulator(200);
|
||||||
|
|
||||||
|
const requests = singleRequestBuilder.buildRequest(mockGroups, mockUsers, true, true);
|
||||||
|
|
||||||
|
expect(requests.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("BatchRequestBuilder retuns an empty array when there are no users or groups", () => {
|
||||||
|
const requests = batchRequestBuilder.buildRequest([], [], true, true);
|
||||||
|
|
||||||
|
expect(requests).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
37
src/services/directory-factory.service.ts
Normal file
37
src/services/directory-factory.service.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
|
||||||
|
import { LogService } from "@/jslib/common/src/abstractions/log.service";
|
||||||
|
|
||||||
|
import { DirectoryFactoryService } from "../abstractions/directory-factory.service";
|
||||||
|
import { StateService } from "../abstractions/state.service";
|
||||||
|
import { DirectoryType } from "../enums/directoryType";
|
||||||
|
|
||||||
|
import { AzureDirectoryService } from "./azure-directory.service";
|
||||||
|
import { GSuiteDirectoryService } from "./gsuite-directory.service";
|
||||||
|
import { LdapDirectoryService } from "./ldap-directory.service";
|
||||||
|
import { OktaDirectoryService } from "./okta-directory.service";
|
||||||
|
import { OneLoginDirectoryService } from "./onelogin-directory.service";
|
||||||
|
|
||||||
|
export class DefaultDirectoryFactoryService implements DirectoryFactoryService {
|
||||||
|
constructor(
|
||||||
|
private logService: LogService,
|
||||||
|
private i18nService: I18nService,
|
||||||
|
private stateService: StateService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
createService(directoryType: DirectoryType) {
|
||||||
|
switch (directoryType) {
|
||||||
|
case DirectoryType.GSuite:
|
||||||
|
return new GSuiteDirectoryService(this.logService, this.i18nService, this.stateService);
|
||||||
|
case DirectoryType.AzureActiveDirectory:
|
||||||
|
return new AzureDirectoryService(this.logService, this.i18nService, this.stateService);
|
||||||
|
case DirectoryType.Ldap:
|
||||||
|
return new LdapDirectoryService(this.logService, this.i18nService, this.stateService);
|
||||||
|
case DirectoryType.Okta:
|
||||||
|
return new OktaDirectoryService(this.logService, this.i18nService, this.stateService);
|
||||||
|
case DirectoryType.OneLogin:
|
||||||
|
return new OneLoginDirectoryService(this.logService, this.i18nService, this.stateService);
|
||||||
|
default:
|
||||||
|
throw new Error("Invalid Directory Type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -141,7 +141,7 @@ export class GSuiteDirectoryService extends BaseDirectoryService implements IDir
|
|||||||
entry.referenceId = user.id;
|
entry.referenceId = user.id;
|
||||||
entry.externalId = user.id;
|
entry.externalId = user.id;
|
||||||
entry.email = user.primaryEmail != null ? user.primaryEmail.trim().toLowerCase() : null;
|
entry.email = user.primaryEmail != null ? user.primaryEmail.trim().toLowerCase() : null;
|
||||||
entry.disabled = user.suspended || false;
|
entry.disabled = user.suspended || user.archived || false;
|
||||||
entry.deleted = deleted;
|
entry.deleted = deleted;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import { LogService } from "../../jslib/common/src/abstractions/log.service";
|
|||||||
import { groupFixtures } from "../../openldap/group-fixtures";
|
import { groupFixtures } from "../../openldap/group-fixtures";
|
||||||
import { userFixtures } from "../../openldap/user-fixtures";
|
import { userFixtures } from "../../openldap/user-fixtures";
|
||||||
import { DirectoryType } from "../enums/directoryType";
|
import { DirectoryType } from "../enums/directoryType";
|
||||||
import { LdapConfiguration } from "../models/ldapConfiguration";
|
import { getLdapConfiguration, getSyncConfiguration } from "../utils/test-fixtures";
|
||||||
import { SyncConfiguration } from "../models/syncConfiguration";
|
|
||||||
|
|
||||||
import { LdapDirectoryService } from "./ldap-directory.service";
|
import { LdapDirectoryService } from "./ldap-directory.service";
|
||||||
import { StateService } from "./state.service";
|
import { StateService } from "./state.service";
|
||||||
@@ -154,54 +153,3 @@ describe("ldapDirectoryService", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns a basic ldap configuration without TLS/SSL enabled. Can be overridden by passing in a partial configuration.
|
|
||||||
*/
|
|
||||||
const getLdapConfiguration = (config?: Partial<LdapConfiguration>): LdapConfiguration => ({
|
|
||||||
ssl: false,
|
|
||||||
startTls: false,
|
|
||||||
tlsCaPath: null,
|
|
||||||
sslAllowUnauthorized: false,
|
|
||||||
sslCertPath: null,
|
|
||||||
sslKeyPath: null,
|
|
||||||
sslCaPath: null,
|
|
||||||
hostname: "localhost",
|
|
||||||
port: 1389,
|
|
||||||
domain: null,
|
|
||||||
rootPath: "dc=bitwarden,dc=com",
|
|
||||||
currentUser: false,
|
|
||||||
username: "cn=admin,dc=bitwarden,dc=com",
|
|
||||||
password: "admin",
|
|
||||||
ad: false,
|
|
||||||
pagedSearch: false,
|
|
||||||
...(config ?? {}),
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns a basic sync configuration. Can be overridden by passing in a partial configuration.
|
|
||||||
*/
|
|
||||||
const getSyncConfiguration = (config?: Partial<SyncConfiguration>): SyncConfiguration => ({
|
|
||||||
users: false,
|
|
||||||
groups: false,
|
|
||||||
interval: 5,
|
|
||||||
userFilter: null,
|
|
||||||
groupFilter: null,
|
|
||||||
removeDisabled: false,
|
|
||||||
overwriteExisting: false,
|
|
||||||
largeImport: false,
|
|
||||||
// Ldap properties
|
|
||||||
groupObjectClass: "posixGroup",
|
|
||||||
userObjectClass: "person",
|
|
||||||
groupPath: null,
|
|
||||||
userPath: null,
|
|
||||||
groupNameAttribute: "cn",
|
|
||||||
userEmailAttribute: "mail",
|
|
||||||
memberAttribute: "memberUid",
|
|
||||||
useEmailPrefixSuffix: false,
|
|
||||||
emailPrefixAttribute: "sAMAccountName",
|
|
||||||
emailSuffix: null,
|
|
||||||
creationDateAttribute: "whenCreated",
|
|
||||||
revisionDateAttribute: "whenChanged",
|
|
||||||
...(config ?? {}),
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ import { IDirectoryService } from "./directory.service";
|
|||||||
|
|
||||||
const UserControlAccountDisabled = 2;
|
const UserControlAccountDisabled = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute name for the unique identifier used by Active Directory.
|
||||||
|
*/
|
||||||
|
const ActiveDirectoryExternalId = "objectGUID";
|
||||||
|
|
||||||
export class LdapDirectoryService implements IDirectoryService {
|
export class LdapDirectoryService implements IDirectoryService {
|
||||||
private client: ldapts.Client;
|
private client: ldapts.Client;
|
||||||
private dirConfig: LdapConfiguration;
|
private dirConfig: LdapConfiguration;
|
||||||
@@ -240,7 +245,7 @@ export class LdapDirectoryService implements IDirectoryService {
|
|||||||
* otherwise it falls back to the provided referenceId.
|
* otherwise it falls back to the provided referenceId.
|
||||||
*/
|
*/
|
||||||
private getExternalId(searchEntry: ldapts.Entry, referenceId: string) {
|
private getExternalId(searchEntry: ldapts.Entry, referenceId: string) {
|
||||||
const attr = this.getAttr<Buffer>(searchEntry, "objectGUID");
|
const attr = this.getAttr<Buffer>(searchEntry, ActiveDirectoryExternalId);
|
||||||
if (attr != null) {
|
if (attr != null) {
|
||||||
return this.bufToGuid(attr);
|
return this.bufToGuid(attr);
|
||||||
} else {
|
} else {
|
||||||
@@ -358,6 +363,9 @@ export class LdapDirectoryService implements IDirectoryService {
|
|||||||
filter: filter,
|
filter: filter,
|
||||||
scope: "sub",
|
scope: "sub",
|
||||||
paged: this.dirConfig.pagedSearch,
|
paged: this.dirConfig.pagedSearch,
|
||||||
|
// We need to expressly tell ldapts what attributes to return as Buffer objects,
|
||||||
|
// otherwise they are returned as strings
|
||||||
|
explicitBufferAttributes: [ActiveDirectoryExternalId],
|
||||||
};
|
};
|
||||||
const { searchEntries } = await this.client.search(path, options, controls);
|
const { searchEntries } = await this.client.search(path, options, controls);
|
||||||
return searchEntries.map((e) => processEntry(e)).filter((e) => e != null);
|
return searchEntries.map((e) => processEntry(e)).filter((e) => e != null);
|
||||||
|
|||||||
42
src/services/single-request-builder.ts
Normal file
42
src/services/single-request-builder.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
||||||
|
|
||||||
|
import { GroupEntry } from "@/src/models/groupEntry";
|
||||||
|
import { UserEntry } from "@/src/models/userEntry";
|
||||||
|
|
||||||
|
import { RequestBuilder } from "../abstractions/request-builder.service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is responsible for building small (<2k users) syncs as a single
|
||||||
|
* request to the /import endpoint. This is done to be backwards compatible with
|
||||||
|
* existing functionality for sync requests that are sufficiently small enough to not
|
||||||
|
* exceed default maximum packet size limits on NGINX web servers.
|
||||||
|
* */
|
||||||
|
export class SingleRequestBuilder implements RequestBuilder {
|
||||||
|
buildRequest(
|
||||||
|
groups: GroupEntry[],
|
||||||
|
users: UserEntry[],
|
||||||
|
removeDisabled: boolean,
|
||||||
|
overwriteExisting: boolean,
|
||||||
|
): OrganizationImportRequest[] {
|
||||||
|
return [
|
||||||
|
new OrganizationImportRequest({
|
||||||
|
groups: (groups ?? []).map((g) => {
|
||||||
|
return {
|
||||||
|
name: g.name,
|
||||||
|
externalId: g.externalId,
|
||||||
|
memberExternalIds: Array.from(g.userMemberExternalIds),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
users: (users ?? []).map((u) => {
|
||||||
|
return {
|
||||||
|
email: u.email,
|
||||||
|
externalId: u.externalId,
|
||||||
|
deleted: u.deleted || (removeDisabled && u.disabled),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
overwriteExisting: overwriteExisting,
|
||||||
|
largeImport: false,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
132
src/services/sync.service.spec.ts
Normal file
132
src/services/sync.service.spec.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
|
||||||
|
import { CryptoFunctionService } from "@/jslib/common/src/abstractions/cryptoFunction.service";
|
||||||
|
import { EnvironmentService } from "@/jslib/common/src/abstractions/environment.service";
|
||||||
|
import { MessagingService } from "@/jslib/common/src/abstractions/messaging.service";
|
||||||
|
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
||||||
|
import { ApiService } from "@/jslib/common/src/services/api.service";
|
||||||
|
|
||||||
|
import { DirectoryFactoryService } from "../abstractions/directory-factory.service";
|
||||||
|
import { DirectoryType } from "../enums/directoryType";
|
||||||
|
import { getSyncConfiguration } from "../utils/test-fixtures";
|
||||||
|
|
||||||
|
import { BatchRequestBuilder } from "./batch-request-builder";
|
||||||
|
import { I18nService } from "./i18n.service";
|
||||||
|
import { LdapDirectoryService } from "./ldap-directory.service";
|
||||||
|
import { SingleRequestBuilder } from "./single-request-builder";
|
||||||
|
import { StateService } from "./state.service";
|
||||||
|
import { SyncService } from "./sync.service";
|
||||||
|
import * as constants from "./sync.service";
|
||||||
|
|
||||||
|
import { groupFixtures } from "@/openldap/group-fixtures";
|
||||||
|
import { userFixtures } from "@/openldap/user-fixtures";
|
||||||
|
|
||||||
|
describe("SyncService", () => {
|
||||||
|
let cryptoFunctionService: MockProxy<CryptoFunctionService>;
|
||||||
|
let apiService: MockProxy<ApiService>;
|
||||||
|
let messagingService: MockProxy<MessagingService>;
|
||||||
|
let i18nService: MockProxy<I18nService>;
|
||||||
|
let environmentService: MockProxy<EnvironmentService>;
|
||||||
|
let stateService: MockProxy<StateService>;
|
||||||
|
let directoryFactory: MockProxy<DirectoryFactoryService>;
|
||||||
|
let batchRequestBuilder: MockProxy<BatchRequestBuilder>;
|
||||||
|
let singleRequestBuilder: MockProxy<SingleRequestBuilder>;
|
||||||
|
|
||||||
|
let syncService: SyncService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cryptoFunctionService = mock();
|
||||||
|
apiService = mock();
|
||||||
|
messagingService = mock();
|
||||||
|
i18nService = mock();
|
||||||
|
environmentService = mock();
|
||||||
|
stateService = mock();
|
||||||
|
directoryFactory = mock();
|
||||||
|
batchRequestBuilder = mock();
|
||||||
|
singleRequestBuilder = mock();
|
||||||
|
|
||||||
|
stateService.getDirectoryType.mockResolvedValue(DirectoryType.Ldap);
|
||||||
|
stateService.getOrganizationId.mockResolvedValue("fakeId");
|
||||||
|
const mockDirectoryService = mock<LdapDirectoryService>();
|
||||||
|
mockDirectoryService.getEntries.mockResolvedValue([groupFixtures, userFixtures]);
|
||||||
|
directoryFactory.createService.mockReturnValue(mockDirectoryService);
|
||||||
|
|
||||||
|
syncService = new SyncService(
|
||||||
|
cryptoFunctionService,
|
||||||
|
apiService,
|
||||||
|
messagingService,
|
||||||
|
i18nService,
|
||||||
|
environmentService,
|
||||||
|
stateService,
|
||||||
|
batchRequestBuilder,
|
||||||
|
singleRequestBuilder,
|
||||||
|
directoryFactory,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Sync posts single request successfully for unique hashes", async () => {
|
||||||
|
stateService.getSync.mockResolvedValue(getSyncConfiguration({ groups: true, users: true }));
|
||||||
|
cryptoFunctionService.hash.mockResolvedValue(new ArrayBuffer(1));
|
||||||
|
// This arranges the last hash to be differet from the ArrayBuffer after it is converted to b64
|
||||||
|
stateService.getLastSyncHash.mockResolvedValue("unique hash");
|
||||||
|
|
||||||
|
const mockRequest: OrganizationImportRequest[] = [
|
||||||
|
{
|
||||||
|
members: [],
|
||||||
|
groups: [],
|
||||||
|
overwriteExisting: true,
|
||||||
|
largeImport: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
singleRequestBuilder.buildRequest.mockReturnValue(mockRequest);
|
||||||
|
|
||||||
|
await syncService.sync(true, false);
|
||||||
|
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Sync posts multiple request successfully for unique hashes", async () => {
|
||||||
|
stateService.getSync.mockResolvedValue(
|
||||||
|
getSyncConfiguration({ groups: true, users: true, largeImport: true }),
|
||||||
|
);
|
||||||
|
cryptoFunctionService.hash.mockResolvedValue(new ArrayBuffer(1));
|
||||||
|
// This arranges the last hash to be differet from the ArrayBuffer after it is converted to b64
|
||||||
|
stateService.getLastSyncHash.mockResolvedValue("unique hash");
|
||||||
|
|
||||||
|
// @ts-expect-error This is a workaround to make the batchsize smaller to trigger the batching logic since its a const.
|
||||||
|
constants.batchSize = 4;
|
||||||
|
|
||||||
|
const mockRequests = new Array(6).fill({
|
||||||
|
members: [],
|
||||||
|
groups: [],
|
||||||
|
overwriteExisting: true,
|
||||||
|
largeImport: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
batchRequestBuilder.buildRequest.mockReturnValue(mockRequests);
|
||||||
|
|
||||||
|
await syncService.sync(true, false);
|
||||||
|
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledTimes(6);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[0]);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[1]);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[2]);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[3]);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[4]);
|
||||||
|
expect(apiService.postPublicImportDirectory).toHaveBeenCalledWith(mockRequests[5]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not post for the same hash", async () => {
|
||||||
|
// @ts-expect-error this sets the batch size back to its expexted value for this test.
|
||||||
|
constants.batchSize = 2000;
|
||||||
|
stateService.getSync.mockResolvedValue(getSyncConfiguration({ groups: true, users: true }));
|
||||||
|
cryptoFunctionService.hash.mockResolvedValue(new ArrayBuffer(1));
|
||||||
|
// This arranges the last hash to be the same as the ArrayBuffer after it is converted to b64
|
||||||
|
stateService.getLastSyncHash.mockResolvedValue("AA==");
|
||||||
|
|
||||||
|
await syncService.sync(true, false);
|
||||||
|
|
||||||
|
expect(apiService.postPublicImportDirectory).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,35 +2,40 @@ import { ApiService } from "@/jslib/common/src/abstractions/api.service";
|
|||||||
import { CryptoFunctionService } from "@/jslib/common/src/abstractions/cryptoFunction.service";
|
import { CryptoFunctionService } from "@/jslib/common/src/abstractions/cryptoFunction.service";
|
||||||
import { EnvironmentService } from "@/jslib/common/src/abstractions/environment.service";
|
import { EnvironmentService } from "@/jslib/common/src/abstractions/environment.service";
|
||||||
import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
|
import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
|
||||||
import { LogService } from "@/jslib/common/src/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@/jslib/common/src/abstractions/messaging.service";
|
import { MessagingService } from "@/jslib/common/src/abstractions/messaging.service";
|
||||||
import { Utils } from "@/jslib/common/src/misc/utils";
|
import { Utils } from "@/jslib/common/src/misc/utils";
|
||||||
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
import { OrganizationImportRequest } from "@/jslib/common/src/models/request/organizationImportRequest";
|
||||||
|
|
||||||
|
import { DirectoryFactoryService } from "../abstractions/directory-factory.service";
|
||||||
import { StateService } from "../abstractions/state.service";
|
import { StateService } from "../abstractions/state.service";
|
||||||
import { DirectoryType } from "../enums/directoryType";
|
import { DirectoryType } from "../enums/directoryType";
|
||||||
import { GroupEntry } from "../models/groupEntry";
|
import { GroupEntry } from "../models/groupEntry";
|
||||||
import { SyncConfiguration } from "../models/syncConfiguration";
|
import { SyncConfiguration } from "../models/syncConfiguration";
|
||||||
import { UserEntry } from "../models/userEntry";
|
import { UserEntry } from "../models/userEntry";
|
||||||
|
|
||||||
import { AzureDirectoryService } from "./azure-directory.service";
|
import { BatchRequestBuilder } from "./batch-request-builder";
|
||||||
import { IDirectoryService } from "./directory.service";
|
import { SingleRequestBuilder } from "./single-request-builder";
|
||||||
import { GSuiteDirectoryService } from "./gsuite-directory.service";
|
|
||||||
import { LdapDirectoryService } from "./ldap-directory.service";
|
export interface HashResult {
|
||||||
import { OktaDirectoryService } from "./okta-directory.service";
|
hash: string;
|
||||||
import { OneLoginDirectoryService } from "./onelogin-directory.service";
|
hashLegacy: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const batchSize = 2000;
|
||||||
|
|
||||||
export class SyncService {
|
export class SyncService {
|
||||||
private dirType: DirectoryType;
|
private dirType: DirectoryType;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private logService: LogService,
|
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
|
private batchRequestBuilder: BatchRequestBuilder,
|
||||||
|
private singleRequestBuilder: SingleRequestBuilder,
|
||||||
|
private directoryFactory: DirectoryFactoryService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async sync(force: boolean, test: boolean): Promise<[GroupEntry[], UserEntry[]]> {
|
async sync(force: boolean, test: boolean): Promise<[GroupEntry[], UserEntry[]]> {
|
||||||
@@ -39,7 +44,7 @@ export class SyncService {
|
|||||||
throw new Error("No directory configured.");
|
throw new Error("No directory configured.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const directoryService = this.getDirectoryService();
|
const directoryService = this.directoryFactory.createService(this.dirType);
|
||||||
if (directoryService == null) {
|
if (directoryService == null) {
|
||||||
throw new Error("Cannot load directory service.");
|
throw new Error("Cannot load directory service.");
|
||||||
}
|
}
|
||||||
@@ -78,15 +83,42 @@ export class SyncService {
|
|||||||
return [groups, users];
|
return [groups, users];
|
||||||
}
|
}
|
||||||
|
|
||||||
const req = this.buildRequest(
|
const reqs = this.buildRequest(
|
||||||
groups,
|
groups,
|
||||||
users,
|
users,
|
||||||
syncConfig.removeDisabled,
|
syncConfig.removeDisabled,
|
||||||
syncConfig.overwriteExisting,
|
syncConfig.overwriteExisting,
|
||||||
syncConfig.largeImport,
|
syncConfig.largeImport,
|
||||||
);
|
);
|
||||||
const reqJson = JSON.stringify(req);
|
|
||||||
|
|
||||||
|
const result: HashResult = await this.generateHash(reqs);
|
||||||
|
|
||||||
|
if (result.hash && (await this.isNewHash(result))) {
|
||||||
|
for (const req of reqs) {
|
||||||
|
await this.apiService.postPublicImportDirectory(req);
|
||||||
|
}
|
||||||
|
await this.stateService.setLastSyncHash(result.hash);
|
||||||
|
} else {
|
||||||
|
groups = null;
|
||||||
|
users = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.saveSyncTimes(syncConfig, now);
|
||||||
|
this.messagingService.send("dirSyncCompleted", { successfully: true });
|
||||||
|
return [groups, users];
|
||||||
|
} catch (e) {
|
||||||
|
if (!test) {
|
||||||
|
await this.stateService.setGroupDelta(startingGroupDelta);
|
||||||
|
await this.stateService.setUserDelta(startingUserDelta);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.messagingService.send("dirSyncCompleted", { successfully: false });
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async generateHash(reqs: OrganizationImportRequest[]): Promise<HashResult> {
|
||||||
|
const reqJson = JSON.stringify(reqs?.length === 1 ? reqs[0] : reqs);
|
||||||
const orgId = await this.stateService.getOrganizationId();
|
const orgId = await this.stateService.getOrganizationId();
|
||||||
if (orgId == null) {
|
if (orgId == null) {
|
||||||
throw new Error("Organization not set.");
|
throw new Error("Organization not set.");
|
||||||
@@ -109,28 +141,14 @@ export class SyncService {
|
|||||||
if (hashBuff != null) {
|
if (hashBuff != null) {
|
||||||
hash = Utils.fromBufferToB64(hashBuff);
|
hash = Utils.fromBufferToB64(hashBuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { hash, hashLegacy };
|
||||||
|
}
|
||||||
|
|
||||||
|
async isNewHash(hashResult: HashResult): Promise<boolean> {
|
||||||
const lastHash = await this.stateService.getLastSyncHash();
|
const lastHash = await this.stateService.getLastSyncHash();
|
||||||
|
|
||||||
if (lastHash == null || (hash !== lastHash && hashLegacy !== lastHash)) {
|
return lastHash == null || (hashResult.hash !== lastHash && hashResult.hashLegacy !== lastHash);
|
||||||
await this.apiService.postPublicImportDirectory(req);
|
|
||||||
await this.stateService.setLastSyncHash(hash);
|
|
||||||
} else {
|
|
||||||
groups = null;
|
|
||||||
users = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.saveSyncTimes(syncConfig, now);
|
|
||||||
this.messagingService.send("dirSyncCompleted", { successfully: true });
|
|
||||||
return [groups, users];
|
|
||||||
} catch (e) {
|
|
||||||
if (!test) {
|
|
||||||
await this.stateService.setGroupDelta(startingGroupDelta);
|
|
||||||
await this.stateService.setUserDelta(startingUserDelta);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.messagingService.send("dirSyncCompleted", { successfully: false });
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeDuplicateUsers(users: UserEntry[]) {
|
private removeDuplicateUsers(users: UserEntry[]) {
|
||||||
@@ -198,48 +216,28 @@ export class SyncService {
|
|||||||
return allUsers;
|
return allUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDirectoryService(): IDirectoryService {
|
|
||||||
switch (this.dirType) {
|
|
||||||
case DirectoryType.GSuite:
|
|
||||||
return new GSuiteDirectoryService(this.logService, this.i18nService, this.stateService);
|
|
||||||
case DirectoryType.AzureActiveDirectory:
|
|
||||||
return new AzureDirectoryService(this.logService, this.i18nService, this.stateService);
|
|
||||||
case DirectoryType.Ldap:
|
|
||||||
return new LdapDirectoryService(this.logService, this.i18nService, this.stateService);
|
|
||||||
case DirectoryType.Okta:
|
|
||||||
return new OktaDirectoryService(this.logService, this.i18nService, this.stateService);
|
|
||||||
case DirectoryType.OneLogin:
|
|
||||||
return new OneLoginDirectoryService(this.logService, this.i18nService, this.stateService);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildRequest(
|
private buildRequest(
|
||||||
groups: GroupEntry[],
|
groups: GroupEntry[],
|
||||||
users: UserEntry[],
|
users: UserEntry[],
|
||||||
removeDisabled: boolean,
|
removeDisabled: boolean,
|
||||||
overwriteExisting: boolean,
|
overwriteExisting: boolean,
|
||||||
largeImport = false,
|
largeImport = false,
|
||||||
) {
|
): OrganizationImportRequest[] {
|
||||||
return new OrganizationImportRequest({
|
if (largeImport && groups.length + users.length > batchSize) {
|
||||||
groups: (groups ?? []).map((g) => {
|
return this.batchRequestBuilder.buildRequest(
|
||||||
return {
|
groups,
|
||||||
name: g.name,
|
users,
|
||||||
externalId: g.externalId,
|
overwriteExisting,
|
||||||
memberExternalIds: Array.from(g.userMemberExternalIds),
|
removeDisabled,
|
||||||
};
|
);
|
||||||
}),
|
} else {
|
||||||
users: (users ?? []).map((u) => {
|
return this.singleRequestBuilder.buildRequest(
|
||||||
return {
|
groups,
|
||||||
email: u.email,
|
users,
|
||||||
externalId: u.externalId,
|
overwriteExisting,
|
||||||
deleted: u.deleted || (removeDisabled && u.disabled),
|
removeDisabled,
|
||||||
};
|
);
|
||||||
}),
|
}
|
||||||
overwriteExisting: overwriteExisting,
|
|
||||||
largeImport: largeImport,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async saveSyncTimes(syncConfig: SyncConfiguration, time: Date) {
|
private async saveSyncTimes(syncConfig: SyncConfiguration, time: Date) {
|
||||||
|
|||||||
53
src/utils/test-fixtures.ts
Normal file
53
src/utils/test-fixtures.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { LdapConfiguration } from "../models/ldapConfiguration";
|
||||||
|
import { SyncConfiguration } from "../models/syncConfiguration";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns a basic ldap configuration without TLS/SSL enabled. Can be overridden by passing in a partial configuration.
|
||||||
|
*/
|
||||||
|
export const getLdapConfiguration = (config?: Partial<LdapConfiguration>): LdapConfiguration => ({
|
||||||
|
ssl: false,
|
||||||
|
startTls: false,
|
||||||
|
tlsCaPath: null,
|
||||||
|
sslAllowUnauthorized: false,
|
||||||
|
sslCertPath: null,
|
||||||
|
sslKeyPath: null,
|
||||||
|
sslCaPath: null,
|
||||||
|
hostname: "localhost",
|
||||||
|
port: 1389,
|
||||||
|
domain: null,
|
||||||
|
rootPath: "dc=bitwarden,dc=com",
|
||||||
|
currentUser: false,
|
||||||
|
username: "cn=admin,dc=bitwarden,dc=com",
|
||||||
|
password: "admin",
|
||||||
|
ad: false,
|
||||||
|
pagedSearch: false,
|
||||||
|
...(config ?? {}),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns a basic sync configuration. Can be overridden by passing in a partial configuration.
|
||||||
|
*/
|
||||||
|
export const getSyncConfiguration = (config?: Partial<SyncConfiguration>): SyncConfiguration => ({
|
||||||
|
users: false,
|
||||||
|
groups: false,
|
||||||
|
interval: 5,
|
||||||
|
userFilter: null,
|
||||||
|
groupFilter: null,
|
||||||
|
removeDisabled: false,
|
||||||
|
overwriteExisting: false,
|
||||||
|
largeImport: false,
|
||||||
|
// Ldap properties
|
||||||
|
groupObjectClass: "posixGroup",
|
||||||
|
userObjectClass: "person",
|
||||||
|
groupPath: null,
|
||||||
|
userPath: null,
|
||||||
|
groupNameAttribute: "cn",
|
||||||
|
userEmailAttribute: "mail",
|
||||||
|
memberAttribute: "memberUid",
|
||||||
|
useEmailPrefixSuffix: false,
|
||||||
|
emailPrefixAttribute: "sAMAccountName",
|
||||||
|
emailSuffix: null,
|
||||||
|
creationDateAttribute: "whenCreated",
|
||||||
|
revisionDateAttribute: "whenChanged",
|
||||||
|
...(config ?? {}),
|
||||||
|
});
|
||||||
@@ -17,12 +17,7 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"tldjs": ["@/jslib/src/misc/tldjs.noop"],
|
"tldjs": ["@/jslib/src/misc/tldjs.noop"],
|
||||||
"@/*": ["./*"]
|
"@/*": ["./*"]
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"transform": "typescript-transform-paths"
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"include": ["src", "jslib", "scripts", "./*.ts"]
|
"include": ["src", "jslib", "scripts", "./*.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user