diff --git a/.github/workflows/update-be-new-migration-latest-timestamp.yml b/.github/workflows/update-be-new-migration-latest-timestamp.yml
index 160828473e..684c786541 100644
--- a/.github/workflows/update-be-new-migration-latest-timestamp.yml
+++ b/.github/workflows/update-be-new-migration-latest-timestamp.yml
@@ -38,6 +38,16 @@ jobs:
rm added_files.txt
git commit -m "chore: renamed new migration files to latest timestamp (gh-action)"
+ - name: Get PR details
+ id: pr_details
+ run: |
+ PR_NUMBER=${{ github.event.pull_request.number }}
+ PR_MERGER=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | jq -r '.merged_by.login')
+
+ echo "PR Number: $PR_NUMBER"
+ echo "PR Merger: $PR_MERGER"
+ echo "pr_merger=$PR_MERGER" >> $GITHUB_OUTPUT
+
- name: Create Pull Request
if: env.SKIP_RENAME != 'true'
uses: peter-evans/create-pull-request@v6
@@ -46,3 +56,4 @@ jobs:
commit-message: 'chore: renamed new migration files to latest UTC (gh-action)'
title: 'GH Action: rename new migration file timestamp'
branch-suffix: timestamp
+ reviewers: ${{ steps.pr_details.outputs.pr_merger }}
diff --git a/.infisicalignore b/.infisicalignore
index d5cc9f15df..855047fe4c 100644
--- a/.infisicalignore
+++ b/.infisicalignore
@@ -4,3 +4,4 @@ frontend/src/views/Project/MembersPage/components/IdentityTab/components/Identit
frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/MemberRbacSection.tsx:generic-api-key:206
frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx:generic-api-key:292
docs/self-hosting/configuration/envars.mdx:generic-api-key:106
+frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx:generic-api-key:451
diff --git a/backend/package-lock.json b/backend/package-lock.json
index b51573688e..5928f64a5d 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -1207,6 +1207,58 @@
"node": ">=14.0.0"
}
},
+ "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/client-sts": {
+ "version": "3.504.0",
+ "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.504.0.tgz",
+ "integrity": "sha512-IESs8FkL7B/uY+ml4wgoRkrr6xYo4PizcNw6JX17eveq1gRBCPKeGMjE6HTDOcIYZZ8rqz/UeuH3JD4UhrMOnA==",
+ "dependencies": {
+ "@aws-crypto/sha256-browser": "3.0.0",
+ "@aws-crypto/sha256-js": "3.0.0",
+ "@aws-sdk/core": "3.496.0",
+ "@aws-sdk/middleware-host-header": "3.502.0",
+ "@aws-sdk/middleware-logger": "3.502.0",
+ "@aws-sdk/middleware-recursion-detection": "3.502.0",
+ "@aws-sdk/middleware-user-agent": "3.502.0",
+ "@aws-sdk/region-config-resolver": "3.502.0",
+ "@aws-sdk/types": "3.502.0",
+ "@aws-sdk/util-endpoints": "3.502.0",
+ "@aws-sdk/util-user-agent-browser": "3.502.0",
+ "@aws-sdk/util-user-agent-node": "3.502.0",
+ "@smithy/config-resolver": "^2.1.1",
+ "@smithy/core": "^1.3.1",
+ "@smithy/fetch-http-handler": "^2.4.1",
+ "@smithy/hash-node": "^2.1.1",
+ "@smithy/invalid-dependency": "^2.1.1",
+ "@smithy/middleware-content-length": "^2.1.1",
+ "@smithy/middleware-endpoint": "^2.4.1",
+ "@smithy/middleware-retry": "^2.1.1",
+ "@smithy/middleware-serde": "^2.1.1",
+ "@smithy/middleware-stack": "^2.1.1",
+ "@smithy/node-config-provider": "^2.2.1",
+ "@smithy/node-http-handler": "^2.3.1",
+ "@smithy/protocol-http": "^3.1.1",
+ "@smithy/smithy-client": "^2.3.1",
+ "@smithy/types": "^2.9.1",
+ "@smithy/url-parser": "^2.1.1",
+ "@smithy/util-base64": "^2.1.1",
+ "@smithy/util-body-length-browser": "^2.1.1",
+ "@smithy/util-body-length-node": "^2.2.1",
+ "@smithy/util-defaults-mode-browser": "^2.1.1",
+ "@smithy/util-defaults-mode-node": "^2.1.1",
+ "@smithy/util-endpoints": "^1.1.1",
+ "@smithy/util-middleware": "^2.1.1",
+ "@smithy/util-retry": "^2.1.1",
+ "@smithy/util-utf8": "^2.1.1",
+ "fast-xml-parser": "4.2.5",
+ "tslib": "^2.5.0"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "@aws-sdk/credential-provider-node": "^3.504.0"
+ }
+ },
"node_modules/@aws-sdk/client-secrets-manager/node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
@@ -1314,7 +1366,7 @@
"@aws-sdk/credential-provider-node": "^3.504.0"
}
},
- "node_modules/@aws-sdk/client-sts": {
+ "node_modules/@aws-sdk/client-sso-oidc/node_modules/@aws-sdk/client-sts": {
"version": "3.504.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.504.0.tgz",
"integrity": "sha512-IESs8FkL7B/uY+ml4wgoRkrr6xYo4PizcNw6JX17eveq1gRBCPKeGMjE6HTDOcIYZZ8rqz/UeuH3JD4UhrMOnA==",
@@ -1436,6 +1488,58 @@
"node": ">=14.0.0"
}
},
+ "node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/client-sts": {
+ "version": "3.504.0",
+ "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.504.0.tgz",
+ "integrity": "sha512-IESs8FkL7B/uY+ml4wgoRkrr6xYo4PizcNw6JX17eveq1gRBCPKeGMjE6HTDOcIYZZ8rqz/UeuH3JD4UhrMOnA==",
+ "dependencies": {
+ "@aws-crypto/sha256-browser": "3.0.0",
+ "@aws-crypto/sha256-js": "3.0.0",
+ "@aws-sdk/core": "3.496.0",
+ "@aws-sdk/middleware-host-header": "3.502.0",
+ "@aws-sdk/middleware-logger": "3.502.0",
+ "@aws-sdk/middleware-recursion-detection": "3.502.0",
+ "@aws-sdk/middleware-user-agent": "3.502.0",
+ "@aws-sdk/region-config-resolver": "3.502.0",
+ "@aws-sdk/types": "3.502.0",
+ "@aws-sdk/util-endpoints": "3.502.0",
+ "@aws-sdk/util-user-agent-browser": "3.502.0",
+ "@aws-sdk/util-user-agent-node": "3.502.0",
+ "@smithy/config-resolver": "^2.1.1",
+ "@smithy/core": "^1.3.1",
+ "@smithy/fetch-http-handler": "^2.4.1",
+ "@smithy/hash-node": "^2.1.1",
+ "@smithy/invalid-dependency": "^2.1.1",
+ "@smithy/middleware-content-length": "^2.1.1",
+ "@smithy/middleware-endpoint": "^2.4.1",
+ "@smithy/middleware-retry": "^2.1.1",
+ "@smithy/middleware-serde": "^2.1.1",
+ "@smithy/middleware-stack": "^2.1.1",
+ "@smithy/node-config-provider": "^2.2.1",
+ "@smithy/node-http-handler": "^2.3.1",
+ "@smithy/protocol-http": "^3.1.1",
+ "@smithy/smithy-client": "^2.3.1",
+ "@smithy/types": "^2.9.1",
+ "@smithy/url-parser": "^2.1.1",
+ "@smithy/util-base64": "^2.1.1",
+ "@smithy/util-body-length-browser": "^2.1.1",
+ "@smithy/util-body-length-node": "^2.2.1",
+ "@smithy/util-defaults-mode-browser": "^2.1.1",
+ "@smithy/util-defaults-mode-node": "^2.1.1",
+ "@smithy/util-endpoints": "^1.1.1",
+ "@smithy/util-middleware": "^2.1.1",
+ "@smithy/util-retry": "^2.1.1",
+ "@smithy/util-utf8": "^2.1.1",
+ "fast-xml-parser": "4.2.5",
+ "tslib": "^2.5.0"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "@aws-sdk/credential-provider-node": "^3.504.0"
+ }
+ },
"node_modules/@aws-sdk/credential-provider-node": {
"version": "3.504.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.504.0.tgz",
@@ -1505,6 +1609,58 @@
"node": ">=14.0.0"
}
},
+ "node_modules/@aws-sdk/credential-provider-web-identity/node_modules/@aws-sdk/client-sts": {
+ "version": "3.504.0",
+ "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.504.0.tgz",
+ "integrity": "sha512-IESs8FkL7B/uY+ml4wgoRkrr6xYo4PizcNw6JX17eveq1gRBCPKeGMjE6HTDOcIYZZ8rqz/UeuH3JD4UhrMOnA==",
+ "dependencies": {
+ "@aws-crypto/sha256-browser": "3.0.0",
+ "@aws-crypto/sha256-js": "3.0.0",
+ "@aws-sdk/core": "3.496.0",
+ "@aws-sdk/middleware-host-header": "3.502.0",
+ "@aws-sdk/middleware-logger": "3.502.0",
+ "@aws-sdk/middleware-recursion-detection": "3.502.0",
+ "@aws-sdk/middleware-user-agent": "3.502.0",
+ "@aws-sdk/region-config-resolver": "3.502.0",
+ "@aws-sdk/types": "3.502.0",
+ "@aws-sdk/util-endpoints": "3.502.0",
+ "@aws-sdk/util-user-agent-browser": "3.502.0",
+ "@aws-sdk/util-user-agent-node": "3.502.0",
+ "@smithy/config-resolver": "^2.1.1",
+ "@smithy/core": "^1.3.1",
+ "@smithy/fetch-http-handler": "^2.4.1",
+ "@smithy/hash-node": "^2.1.1",
+ "@smithy/invalid-dependency": "^2.1.1",
+ "@smithy/middleware-content-length": "^2.1.1",
+ "@smithy/middleware-endpoint": "^2.4.1",
+ "@smithy/middleware-retry": "^2.1.1",
+ "@smithy/middleware-serde": "^2.1.1",
+ "@smithy/middleware-stack": "^2.1.1",
+ "@smithy/node-config-provider": "^2.2.1",
+ "@smithy/node-http-handler": "^2.3.1",
+ "@smithy/protocol-http": "^3.1.1",
+ "@smithy/smithy-client": "^2.3.1",
+ "@smithy/types": "^2.9.1",
+ "@smithy/url-parser": "^2.1.1",
+ "@smithy/util-base64": "^2.1.1",
+ "@smithy/util-body-length-browser": "^2.1.1",
+ "@smithy/util-body-length-node": "^2.2.1",
+ "@smithy/util-defaults-mode-browser": "^2.1.1",
+ "@smithy/util-defaults-mode-node": "^2.1.1",
+ "@smithy/util-endpoints": "^1.1.1",
+ "@smithy/util-middleware": "^2.1.1",
+ "@smithy/util-retry": "^2.1.1",
+ "@smithy/util-utf8": "^2.1.1",
+ "fast-xml-parser": "4.2.5",
+ "tslib": "^2.5.0"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "@aws-sdk/credential-provider-node": "^3.504.0"
+ }
+ },
"node_modules/@aws-sdk/middleware-host-header": {
"version": "3.502.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.502.0.tgz",
@@ -3657,60 +3813,60 @@
}
},
"node_modules/@smithy/abort-controller": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-2.1.3.tgz",
- "integrity": "sha512-c2aYH2Wu1RVE3rLlVgg2kQOBJGM0WbjReQi5DnPTm2Zb7F0gk7J2aeQeaX2u/lQZoHl6gv8Oac7mt9alU3+f4A==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-2.2.0.tgz",
+ "integrity": "sha512-wRlta7GuLWpTqtFfGo+nZyOO1vEvewdNR1R4rTxpC8XU6vG/NDyrFBhwLZsqg1NUoR1noVaXJPC/7ZK47QCySw==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/config-resolver": {
- "version": "2.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-2.1.4.tgz",
- "integrity": "sha512-AW2WUZmBAzgO3V3ovKtsUbI3aBNMeQKFDumoqkNxaVDWF/xfnxAWqBKDr/NuG7c06N2Rm4xeZLPiJH/d+na0HA==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-2.2.0.tgz",
+ "integrity": "sha512-fsiMgd8toyUba6n1WRmr+qACzXltpdDkPTAaDqc8QqPBUzO+/JKwL6bUBseHVi8tu9l+3JOK+tSf7cay+4B3LA==",
"dependencies": {
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/types": "^2.10.1",
- "@smithy/util-config-provider": "^2.2.1",
- "@smithy/util-middleware": "^2.1.3",
- "tslib": "^2.5.0"
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-config-provider": "^2.3.0",
+ "@smithy/util-middleware": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/core": {
- "version": "1.3.5",
- "resolved": "https://registry.npmjs.org/@smithy/core/-/core-1.3.5.tgz",
- "integrity": "sha512-Rrc+e2Jj6Gu7Xbn0jvrzZlSiP2CZocIOfZ9aNUA82+1sa6GBnxqL9+iZ9EKHeD9aqD1nU8EK4+oN2EiFpSv7Yw==",
+ "version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/@smithy/core/-/core-1.4.2.tgz",
+ "integrity": "sha512-2fek3I0KZHWJlRLvRTqxTEri+qV0GRHrJIoLFuBMZB4EMg4WgeBGfF0X6abnrNYpq55KJ6R4D6x4f0vLnhzinA==",
"dependencies": {
- "@smithy/middleware-endpoint": "^2.4.4",
- "@smithy/middleware-retry": "^2.1.4",
- "@smithy/middleware-serde": "^2.1.3",
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/smithy-client": "^2.4.2",
- "@smithy/types": "^2.10.1",
- "@smithy/util-middleware": "^2.1.3",
- "tslib": "^2.5.0"
+ "@smithy/middleware-endpoint": "^2.5.1",
+ "@smithy/middleware-retry": "^2.3.1",
+ "@smithy/middleware-serde": "^2.3.0",
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/smithy-client": "^2.5.1",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-middleware": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/credential-provider-imds": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-2.2.4.tgz",
- "integrity": "sha512-DdatjmBZQnhGe1FhI8gO98f7NmvQFSDiZTwC3WMvLTCKQUY+Y1SVkhJqIuLu50Eb7pTheoXQmK+hKYUgpUWsNA==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-2.3.0.tgz",
+ "integrity": "sha512-BWB9mIukO1wjEOo1Ojgl6LrG4avcaC7T/ZP6ptmAaW4xluhSIPZhY+/PI5YKzlk+jsm+4sQZB45Bt1OfMeQa3w==",
"dependencies": {
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/property-provider": "^2.1.3",
- "@smithy/types": "^2.10.1",
- "@smithy/url-parser": "^2.1.3",
- "tslib": "^2.5.0"
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/property-provider": "^2.2.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/url-parser": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
@@ -3779,459 +3935,451 @@
}
},
"node_modules/@smithy/fetch-http-handler": {
- "version": "2.4.3",
- "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.4.3.tgz",
- "integrity": "sha512-Fn/KYJFo6L5I4YPG8WQb2hOmExgRmNpVH5IK2zU3JKrY5FKW7y9ar5e0BexiIC9DhSKqKX+HeWq/Y18fq7Dkpw==",
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.5.0.tgz",
+ "integrity": "sha512-BOWEBeppWhLn/no/JxUL/ghTfANTjT7kg3Ww2rPqTUY9R4yHPXxJ9JhMe3Z03LN3aPwiwlpDIUcVw1xDyHqEhw==",
"dependencies": {
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/querystring-builder": "^2.1.3",
- "@smithy/types": "^2.10.1",
- "@smithy/util-base64": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/querystring-builder": "^2.2.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-base64": "^2.3.0",
+ "tslib": "^2.6.2"
}
},
"node_modules/@smithy/hash-node": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.1.3.tgz",
- "integrity": "sha512-FsAPCUj7VNJIdHbSxMd5uiZiF20G2zdSDgrgrDrHqIs/VMxK85Vqk5kMVNNDMCZmMezp6UKnac0B4nAyx7HJ9g==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.2.0.tgz",
+ "integrity": "sha512-zLWaC/5aWpMrHKpoDF6nqpNtBhlAYKF/7+9yMN7GpdR8CzohnWfGtMznPybnwSS8saaXBMxIGwJqR4HmRp6b3g==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "@smithy/util-buffer-from": "^2.1.1",
- "@smithy/util-utf8": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-buffer-from": "^2.2.0",
+ "@smithy/util-utf8": "^2.3.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/invalid-dependency": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-2.1.3.tgz",
- "integrity": "sha512-wkra7d/G4CbngV4xsjYyAYOvdAhahQje/WymuQdVEnXFExJopEu7fbL5AEAlBPgWHXwu94VnCSG00gVzRfExyg==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-2.2.0.tgz",
+ "integrity": "sha512-nEDASdbKFKPXN2O6lOlTgrEEOO9NHIeO+HVvZnkqc8h5U9g3BIhWsvzFo+UcUbliMHvKNPD/zVxDrkP1Sbgp8Q==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
}
},
"node_modules/@smithy/is-array-buffer": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.1.1.tgz",
- "integrity": "sha512-xozSQrcUinPpNPNPds4S7z/FakDTh1MZWtRP/2vQtYB/u3HYrX2UXuZs+VhaKBd6Vc7g2XPr2ZtwGBNDN6fNKQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz",
+ "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/middleware-content-length": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-2.1.3.tgz",
- "integrity": "sha512-aJduhkC+dcXxdnv5ZpM3uMmtGmVFKx412R1gbeykS5HXDmRU6oSsyy2SoHENCkfOGKAQOjVE2WVqDJibC0d21g==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-2.2.0.tgz",
+ "integrity": "sha512-5bl2LG1Ah/7E5cMSC+q+h3IpVHMeOkG0yLRyQT1p2aMJkSrZG7RlXHPuAgb7EyaFeidKEnnd/fNaLLaKlHGzDQ==",
"dependencies": {
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/middleware-endpoint": {
- "version": "2.4.4",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.4.4.tgz",
- "integrity": "sha512-4yjHyHK2Jul4JUDBo2sTsWY9UshYUnXeb/TAK/MTaPEb8XQvDmpwSFnfIRDU45RY1a6iC9LCnmJNg/yHyfxqkw==",
+ "version": "2.5.1",
+ "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.5.1.tgz",
+ "integrity": "sha512-1/8kFp6Fl4OsSIVTWHnNjLnTL8IqpIb/D3sTSczrKFnrE9VMNWxnrRKNvpUHOJ6zpGD5f62TPm7+17ilTJpiCQ==",
"dependencies": {
- "@smithy/middleware-serde": "^2.1.3",
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/shared-ini-file-loader": "^2.3.4",
- "@smithy/types": "^2.10.1",
- "@smithy/url-parser": "^2.1.3",
- "@smithy/util-middleware": "^2.1.3",
- "tslib": "^2.5.0"
+ "@smithy/middleware-serde": "^2.3.0",
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/shared-ini-file-loader": "^2.4.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/url-parser": "^2.2.0",
+ "@smithy/util-middleware": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/middleware-retry": {
- "version": "2.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-2.1.4.tgz",
- "integrity": "sha512-Cyolv9YckZTPli1EkkaS39UklonxMd08VskiuMhURDjC0HHa/AD6aK/YoD21CHv9s0QLg0WMLvk9YeLTKkXaFQ==",
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-2.3.1.tgz",
+ "integrity": "sha512-P2bGufFpFdYcWvqpyqqmalRtwFUNUA8vHjJR5iGqbfR6mp65qKOLcUd6lTr4S9Gn/enynSrSf3p3FVgVAf6bXA==",
"dependencies": {
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/service-error-classification": "^2.1.3",
- "@smithy/smithy-client": "^2.4.2",
- "@smithy/types": "^2.10.1",
- "@smithy/util-middleware": "^2.1.3",
- "@smithy/util-retry": "^2.1.3",
- "tslib": "^2.5.0",
- "uuid": "^8.3.2"
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/service-error-classification": "^2.1.5",
+ "@smithy/smithy-client": "^2.5.1",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-middleware": "^2.2.0",
+ "@smithy/util-retry": "^2.2.0",
+ "tslib": "^2.6.2",
+ "uuid": "^9.0.1"
},
"engines": {
"node": ">=14.0.0"
}
},
- "node_modules/@smithy/middleware-retry/node_modules/uuid": {
- "version": "8.3.2",
- "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
- "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
- "bin": {
- "uuid": "dist/bin/uuid"
- }
- },
"node_modules/@smithy/middleware-serde": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-2.1.3.tgz",
- "integrity": "sha512-s76LId+TwASrHhUa9QS4k/zeXDUAuNuddKklQzRgumbzge5BftVXHXIqL4wQxKGLocPwfgAOXWx+HdWhQk9hTg==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-2.3.0.tgz",
+ "integrity": "sha512-sIADe7ojwqTyvEQBe1nc/GXB9wdHhi9UwyX0lTyttmUWDJLP655ZYE1WngnNyXREme8I27KCaUhyhZWRXL0q7Q==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/middleware-stack": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-2.1.3.tgz",
- "integrity": "sha512-opMFufVQgvBSld/b7mD7OOEBxF6STyraVr1xel1j0abVILM8ALJvRoFbqSWHGmaDlRGIiV9Q5cGbWi0sdiEaLQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-2.2.0.tgz",
+ "integrity": "sha512-Qntc3jrtwwrsAC+X8wms8zhrTr0sFXnyEGhZd9sLtsJ/6gGQKFzNB+wWbOcpJd7BR8ThNCoKt76BuQahfMvpeA==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/node-config-provider": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-2.2.4.tgz",
- "integrity": "sha512-nqazHCp8r4KHSFhRQ+T0VEkeqvA0U+RhehBSr1gunUuNW3X7j0uDrWBxB2gE9eutzy6kE3Y7L+Dov/UXT871vg==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-2.3.0.tgz",
+ "integrity": "sha512-0elK5/03a1JPWMDPaS726Iw6LpQg80gFut1tNpPfxFuChEEklo2yL823V94SpTZTxmKlXFtFgsP55uh3dErnIg==",
"dependencies": {
- "@smithy/property-provider": "^2.1.3",
- "@smithy/shared-ini-file-loader": "^2.3.4",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/property-provider": "^2.2.0",
+ "@smithy/shared-ini-file-loader": "^2.4.0",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/node-http-handler": {
- "version": "2.4.1",
- "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-2.4.1.tgz",
- "integrity": "sha512-HCkb94soYhJMxPCa61wGKgmeKpJ3Gftx1XD6bcWEB2wMV1L9/SkQu/6/ysKBnbOzWRE01FGzwrTxucHypZ8rdg==",
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-2.5.0.tgz",
+ "integrity": "sha512-mVGyPBzkkGQsPoxQUbxlEfRjrj6FPyA3u3u2VXGr9hT8wilsoQdZdvKpMBFMB8Crfhv5dNkKHIW0Yyuc7eABqA==",
"dependencies": {
- "@smithy/abort-controller": "^2.1.3",
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/querystring-builder": "^2.1.3",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/abort-controller": "^2.2.0",
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/querystring-builder": "^2.2.0",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/property-provider": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-2.1.3.tgz",
- "integrity": "sha512-bMz3se+ySKWNrgm7eIiQMa2HO/0fl2D0HvLAdg9pTMcpgp4SqOAh6bz7Ik6y7uQqSrk4rLjIKgbQ6yzYgGehCQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-2.2.0.tgz",
+ "integrity": "sha512-+xiil2lFhtTRzXkx8F053AV46QnIw6e7MV8od5Mi68E1ICOjCeCHw2XfLnDEUHnT9WGUIkwcqavXjfwuJbGlpg==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/protocol-http": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-3.2.1.tgz",
- "integrity": "sha512-KLrQkEw4yJCeAmAH7hctE8g9KwA7+H2nSJwxgwIxchbp/L0B5exTdOQi9D5HinPLlothoervGmhpYKelZ6AxIA==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-3.3.0.tgz",
+ "integrity": "sha512-Xy5XK1AFWW2nlY/biWZXu6/krgbaf2dg0q492D8M5qthsnU2H+UgFeZLbM76FnH7s6RO/xhQRkj+T6KBO3JzgQ==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/querystring-builder": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-2.1.3.tgz",
- "integrity": "sha512-kFD3PnNqKELe6m9GRHQw/ftFFSZpnSeQD4qvgDB6BQN6hREHELSosVFUMPN4M3MDKN2jAwk35vXHLoDrNfKu0A==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-2.2.0.tgz",
+ "integrity": "sha512-L1kSeviUWL+emq3CUVSgdogoM/D9QMFaqxL/dd0X7PCNWmPXqt+ExtrBjqT0V7HLN03Vs9SuiLrG3zy3JGnE5A==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "@smithy/util-uri-escape": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-uri-escape": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/querystring-parser": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-2.1.3.tgz",
- "integrity": "sha512-3+CWJoAqcBMR+yvz6D+Fc5VdoGFtfenW6wqSWATWajrRMGVwJGPT3Vy2eb2bnMktJc4HU4bpjeovFa566P3knQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-2.2.0.tgz",
+ "integrity": "sha512-BvHCDrKfbG5Yhbpj4vsbuPV2GgcpHiAkLeIlcA1LtfpMz3jrqizP1+OguSNSj1MwBHEiN+jwNisXLGdajGDQJA==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/service-error-classification": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-2.1.3.tgz",
- "integrity": "sha512-iUrpSsem97bbXHHT/v3s7vaq8IIeMo6P6cXdeYHrx0wOJpMeBGQF7CB0mbJSiTm3//iq3L55JiEm8rA7CTVI8A==",
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-2.1.5.tgz",
+ "integrity": "sha512-uBDTIBBEdAQryvHdc5W8sS5YX7RQzF683XrHePVdFmAgKiMofU15FLSM0/HU03hKTnazdNRFa0YHS7+ArwoUSQ==",
"dependencies": {
- "@smithy/types": "^2.10.1"
+ "@smithy/types": "^2.12.0"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/shared-ini-file-loader": {
- "version": "2.3.4",
- "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-2.3.4.tgz",
- "integrity": "sha512-CiZmPg9GeDKbKmJGEFvJBsJcFnh0AQRzOtQAzj1XEa8N/0/uSN/v1LYzgO7ry8hhO8+9KB7+DhSW0weqBra4Aw==",
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-2.4.0.tgz",
+ "integrity": "sha512-WyujUJL8e1B6Z4PBfAqC/aGY1+C7T0w20Gih3yrvJSk97gpiVfB+y7c46T4Nunk+ZngLq0rOIdeVeIklk0R3OA==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/signature-v4": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-2.1.3.tgz",
- "integrity": "sha512-Jq4iPPdCmJojZTsPePn4r1ULShh6ONkokLuxp1Lnk4Sq7r7rJp4HlA1LbPBq4bD64TIzQezIpr1X+eh5NYkNxw==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-2.3.0.tgz",
+ "integrity": "sha512-ui/NlpILU+6HAQBfJX8BBsDXuKSNrjTSuOYArRblcrErwKFutjrCNb/OExfVRyj9+26F9J+ZmfWT+fKWuDrH3Q==",
"dependencies": {
- "@smithy/eventstream-codec": "^2.1.3",
- "@smithy/is-array-buffer": "^2.1.1",
- "@smithy/types": "^2.10.1",
- "@smithy/util-hex-encoding": "^2.1.1",
- "@smithy/util-middleware": "^2.1.3",
- "@smithy/util-uri-escape": "^2.1.1",
- "@smithy/util-utf8": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/is-array-buffer": "^2.2.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-hex-encoding": "^2.2.0",
+ "@smithy/util-middleware": "^2.2.0",
+ "@smithy/util-uri-escape": "^2.2.0",
+ "@smithy/util-utf8": "^2.3.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/smithy-client": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.4.2.tgz",
- "integrity": "sha512-ntAFYN51zu3N3mCd95YFcFi/8rmvm//uX+HnK24CRbI6k5Rjackn0JhgKz5zOx/tbNvOpgQIwhSX+1EvEsBLbA==",
+ "version": "2.5.1",
+ "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.5.1.tgz",
+ "integrity": "sha512-jrbSQrYCho0yDaaf92qWgd+7nAeap5LtHTI51KXqmpIFCceKU3K9+vIVTUH72bOJngBMqa4kyu1VJhRcSrk/CQ==",
"dependencies": {
- "@smithy/middleware-endpoint": "^2.4.4",
- "@smithy/middleware-stack": "^2.1.3",
- "@smithy/protocol-http": "^3.2.1",
- "@smithy/types": "^2.10.1",
- "@smithy/util-stream": "^2.1.3",
- "tslib": "^2.5.0"
+ "@smithy/middleware-endpoint": "^2.5.1",
+ "@smithy/middleware-stack": "^2.2.0",
+ "@smithy/protocol-http": "^3.3.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-stream": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/types": {
- "version": "2.10.1",
- "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.10.1.tgz",
- "integrity": "sha512-hjQO+4ru4cQ58FluQvKKiyMsFg0A6iRpGm2kqdH8fniyNd2WyanoOsYJfMX/IFLuLxEoW6gnRkNZy1y6fUUhtA==",
+ "version": "2.12.0",
+ "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.12.0.tgz",
+ "integrity": "sha512-QwYgloJ0sVNBeBuBs65cIkTbfzV/Q6ZNPCJ99EICFEdJYG50nGIY/uYXp+TbsdJReIuPr0a0kXmCvren3MbRRw==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/url-parser": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-2.1.3.tgz",
- "integrity": "sha512-X1NRA4WzK/ihgyzTpeGvI9Wn45y8HmqF4AZ/FazwAv8V203Ex+4lXqcYI70naX9ETqbqKVzFk88W6WJJzCggTQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-2.2.0.tgz",
+ "integrity": "sha512-hoA4zm61q1mNTpksiSWp2nEl1dt3j726HdRhiNgVJQMj7mLp7dprtF57mOB6JvEk/x9d2bsuL5hlqZbBuHQylQ==",
"dependencies": {
- "@smithy/querystring-parser": "^2.1.3",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/querystring-parser": "^2.2.0",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
}
},
"node_modules/@smithy/util-base64": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-2.1.1.tgz",
- "integrity": "sha512-UfHVpY7qfF/MrgndI5PexSKVTxSZIdz9InghTFa49QOvuu9I52zLPLUHXvHpNuMb1iD2vmc6R+zbv/bdMipR/g==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-2.3.0.tgz",
+ "integrity": "sha512-s3+eVwNeJuXUwuMbusncZNViuhv2LjVJ1nMwTqSA0XAC7gjKhqqxRdJPhR8+YrkoZ9IiIbFk/yK6ACe/xlF+hw==",
"dependencies": {
- "@smithy/util-buffer-from": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/util-buffer-from": "^2.2.0",
+ "@smithy/util-utf8": "^2.3.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-body-length-browser": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-2.1.1.tgz",
- "integrity": "sha512-ekOGBLvs1VS2d1zM2ER4JEeBWAvIOUKeaFch29UjjJsxmZ/f0L3K3x0dEETgh3Q9bkZNHgT+rkdl/J/VUqSRag==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-2.2.0.tgz",
+ "integrity": "sha512-dtpw9uQP7W+n3vOtx0CfBD5EWd7EPdIdsQnWTDoFf77e3VUf05uA7R7TGipIo8e4WL2kuPdnsr3hMQn9ziYj5w==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
}
},
"node_modules/@smithy/util-body-length-node": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-2.2.1.tgz",
- "integrity": "sha512-/ggJG+ta3IDtpNVq4ktmEUtOkH1LW64RHB5B0hcr5ZaWBmo96UX2cIOVbjCqqDickTXqBWZ4ZO0APuaPrD7Abg==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-2.3.0.tgz",
+ "integrity": "sha512-ITWT1Wqjubf2CJthb0BuT9+bpzBfXeMokH/AAa5EJQgbv9aPMVfnM76iFIZVFf50hYXGbtiV71BHAthNWd6+dw==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-buffer-from": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.1.1.tgz",
- "integrity": "sha512-clhNjbyfqIv9Md2Mg6FffGVrJxw7bgK7s3Iax36xnfVj6cg0fUG7I4RH0XgXJF8bxi+saY5HR21g2UPKSxVCXg==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz",
+ "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==",
"dependencies": {
- "@smithy/is-array-buffer": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/is-array-buffer": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-config-provider": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-2.2.1.tgz",
- "integrity": "sha512-50VL/tx9oYYcjJn/qKqNy7sCtpD0+s8XEBamIFo4mFFTclKMNp+rsnymD796uybjiIquB7VCB/DeafduL0y2kw==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-2.3.0.tgz",
+ "integrity": "sha512-HZkzrRcuFN1k70RLqlNK4FnPXKOpkik1+4JaBoHNJn+RnJGYqaa3c5/+XtLOXhlKzlRgNvyaLieHTW2VwGN0VQ==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-defaults-mode-browser": {
- "version": "2.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.1.4.tgz",
- "integrity": "sha512-J6XAVY+/g7jf03QMnvqPyU+8jqGrrtXoKWFVOS+n1sz0Lg8HjHJ1ANqaDN+KTTKZRZlvG8nU5ZrJOUL6VdwgcQ==",
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.2.1.tgz",
+ "integrity": "sha512-RtKW+8j8skk17SYowucwRUjeh4mCtnm5odCL0Lm2NtHQBsYKrNW0od9Rhopu9wF1gHMfHeWF7i90NwBz/U22Kw==",
"dependencies": {
- "@smithy/property-provider": "^2.1.3",
- "@smithy/smithy-client": "^2.4.2",
- "@smithy/types": "^2.10.1",
+ "@smithy/property-provider": "^2.2.0",
+ "@smithy/smithy-client": "^2.5.1",
+ "@smithy/types": "^2.12.0",
"bowser": "^2.11.0",
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/@smithy/util-defaults-mode-node": {
- "version": "2.2.3",
- "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.2.3.tgz",
- "integrity": "sha512-ttUISrv1uVOjTlDa3nznX33f0pthoUlP+4grhTvOzcLhzArx8qHB94/untGACOG3nlf8vU20nI2iWImfzoLkYA==",
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.3.1.tgz",
+ "integrity": "sha512-vkMXHQ0BcLFysBMWgSBLSk3+leMpFSyyFj8zQtv5ZyUBx8/owVh1/pPEkzmW/DR/Gy/5c8vjLDD9gZjXNKbrpA==",
"dependencies": {
- "@smithy/config-resolver": "^2.1.4",
- "@smithy/credential-provider-imds": "^2.2.4",
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/property-provider": "^2.1.3",
- "@smithy/smithy-client": "^2.4.2",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/config-resolver": "^2.2.0",
+ "@smithy/credential-provider-imds": "^2.3.0",
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/property-provider": "^2.2.0",
+ "@smithy/smithy-client": "^2.5.1",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/@smithy/util-endpoints": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-1.1.4.tgz",
- "integrity": "sha512-/qAeHmK5l4yQ4/bCIJ9p49wDe9rwWtOzhPHblu386fwPNT3pxmodgcs9jDCV52yK9b4rB8o9Sj31P/7Vzka1cg==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-1.2.0.tgz",
+ "integrity": "sha512-BuDHv8zRjsE5zXd3PxFXFknzBG3owCpjq8G3FcsXW3CykYXuEqM3nTSsmLzw5q+T12ZYuDlVUZKBdpNbhVtlrQ==",
"dependencies": {
- "@smithy/node-config-provider": "^2.2.4",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/node-config-provider": "^2.3.0",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">= 14.0.0"
}
},
"node_modules/@smithy/util-hex-encoding": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-2.1.1.tgz",
- "integrity": "sha512-3UNdP2pkYUUBGEXzQI9ODTDK+Tcu1BlCyDBaRHwyxhA+8xLP8agEKQq4MGmpjqb4VQAjq9TwlCQX0kP6XDKYLg==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-2.2.0.tgz",
+ "integrity": "sha512-7iKXR+/4TpLK194pVjKiasIyqMtTYJsgKgM242Y9uzt5dhHnUDvMNb+3xIhRJ9QhvqGii/5cRUt4fJn3dtXNHQ==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-middleware": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-2.1.3.tgz",
- "integrity": "sha512-/+2fm7AZ2ozl5h8wM++ZP0ovE9/tiUUAHIbCfGfb3Zd3+Dyk17WODPKXBeJ/TnK5U+x743QmA0xHzlSm8I/qhw==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-2.2.0.tgz",
+ "integrity": "sha512-L1qpleXf9QD6LwLCJ5jddGkgWyuSvWBkJwWAZ6kFkdifdso+sk3L3O1HdmPvCdnCK3IS4qWyPxev01QMnfHSBw==",
"dependencies": {
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-retry": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-2.1.3.tgz",
- "integrity": "sha512-Kbvd+GEMuozbNUU3B89mb99tbufwREcyx2BOX0X2+qHjq6Gvsah8xSDDgxISDwcOHoDqUWO425F0Uc/QIRhYkg==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-2.2.0.tgz",
+ "integrity": "sha512-q9+pAFPTfftHXRytmZ7GzLFFrEGavqapFc06XxzZFcSIGERXMerXxCitjOG1prVDR9QdjqotF40SWvbqcCpf8g==",
"dependencies": {
- "@smithy/service-error-classification": "^2.1.3",
- "@smithy/types": "^2.10.1",
- "tslib": "^2.5.0"
+ "@smithy/service-error-classification": "^2.1.5",
+ "@smithy/types": "^2.12.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">= 14.0.0"
}
},
"node_modules/@smithy/util-stream": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.1.3.tgz",
- "integrity": "sha512-HvpEQbP8raTy9n86ZfXiAkf3ezp1c3qeeO//zGqwZdrfaoOpGKQgF2Sv1IqZp7wjhna7pvczWaGUHjcOPuQwKw==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.2.0.tgz",
+ "integrity": "sha512-17faEXbYWIRst1aU9SvPZyMdWmqIrduZjVOqCPMIsWFNxs5yQQgFrJL6b2SdiCzyW9mJoDjFtgi53xx7EH+BXA==",
"dependencies": {
- "@smithy/fetch-http-handler": "^2.4.3",
- "@smithy/node-http-handler": "^2.4.1",
- "@smithy/types": "^2.10.1",
- "@smithy/util-base64": "^2.1.1",
- "@smithy/util-buffer-from": "^2.1.1",
- "@smithy/util-hex-encoding": "^2.1.1",
- "@smithy/util-utf8": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/fetch-http-handler": "^2.5.0",
+ "@smithy/node-http-handler": "^2.5.0",
+ "@smithy/types": "^2.12.0",
+ "@smithy/util-base64": "^2.3.0",
+ "@smithy/util-buffer-from": "^2.2.0",
+ "@smithy/util-hex-encoding": "^2.2.0",
+ "@smithy/util-utf8": "^2.3.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-uri-escape": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-2.1.1.tgz",
- "integrity": "sha512-saVzI1h6iRBUVSqtnlOnc9ssU09ypo7n+shdQ8hBTZno/9rZ3AuRYvoHInV57VF7Qn7B+pFJG7qTzFiHxWlWBw==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-2.2.0.tgz",
+ "integrity": "sha512-jtmJMyt1xMD/d8OtbVJ2gFZOSKc+ueYJZPW20ULW1GOp/q/YIM0wNh+u8ZFao9UaIGz4WoPW8hC64qlWLIfoDA==",
"dependencies": {
- "tslib": "^2.5.0"
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@smithy/util-utf8": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.1.1.tgz",
- "integrity": "sha512-BqTpzYEcUMDwAKr7/mVRUtHDhs6ZoXDi9NypMvMfOr/+u1NW7JgqodPDECiiLboEm6bobcPcECxzjtQh865e9A==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz",
+ "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==",
"dependencies": {
- "@smithy/util-buffer-from": "^2.1.1",
- "tslib": "^2.5.0"
+ "@smithy/util-buffer-from": "^2.2.0",
+ "tslib": "^2.6.2"
},
"engines": {
"node": ">=14.0.0"
diff --git a/backend/package.json b/backend/package.json
index 31b9fdb145..113fa4d5b7 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -110,7 +110,7 @@
"libsodium-wrappers": "^0.7.13",
"lodash.isequal": "^4.5.0",
"ms": "^2.1.3",
- "mysql2": "^3.9.4",
+ "mysql2": "^3.9.7",
"nanoid": "^5.0.4",
"nodemailer": "^6.9.9",
"ora": "^7.0.1",
diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts
index 923f7cc4bb..278aa7401e 100644
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@ -1,6 +1,8 @@
import "fastify";
import { TUsers } from "@app/db/schemas";
+import { TAccessApprovalPolicyServiceFactory } from "@app/ee/services/access-approval-policy/access-approval-policy-service";
+import { TAccessApprovalRequestServiceFactory } from "@app/ee/services/access-approval-request/access-approval-request-service";
import { TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-service";
import { TCreateAuditLogDTO } from "@app/ee/services/audit-log/audit-log-types";
import { TAuditLogStreamServiceFactory } from "@app/ee/services/audit-log-stream/audit-log-stream-service";
@@ -30,6 +32,7 @@ import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-se
import { TGroupProjectServiceFactory } from "@app/services/group-project/group-project-service";
import { TIdentityServiceFactory } from "@app/services/identity/identity-service";
import { TIdentityAccessTokenServiceFactory } from "@app/services/identity-access-token/identity-access-token-service";
+import { TIdentityAwsIamAuthServiceFactory } from "@app/services/identity-aws-iam-auth/identity-aws-iam-auth-service";
import { TIdentityGcpIamAuthServiceFactory } from "@app/services/identity-gcp-iam-auth/identity-gcp-iam-auth-service";
import { TIdentityProjectServiceFactory } from "@app/services/identity-project/identity-project-service";
import { TIdentityUaServiceFactory } from "@app/services/identity-ua/identity-ua-service";
@@ -115,6 +118,9 @@ declare module "fastify" {
identityProject: TIdentityProjectServiceFactory;
identityUa: TIdentityUaServiceFactory;
identityGcpIamAuth: TIdentityGcpIamAuthServiceFactory;
+ identityAwsIamAuth: TIdentityAwsIamAuthServiceFactory;
+ accessApprovalPolicy: TAccessApprovalPolicyServiceFactory;
+ accessApprovalRequest: TAccessApprovalRequestServiceFactory;
secretApprovalPolicy: TSecretApprovalPolicyServiceFactory;
secretApprovalRequest: TSecretApprovalRequestServiceFactory;
secretRotation: TSecretRotationServiceFactory;
diff --git a/backend/src/@types/knex.d.ts b/backend/src/@types/knex.d.ts
index acf4934aa6..7d1df5003e 100644
--- a/backend/src/@types/knex.d.ts
+++ b/backend/src/@types/knex.d.ts
@@ -2,6 +2,18 @@ import { Knex } from "knex";
import {
TableName,
+ TAccessApprovalPolicies,
+ TAccessApprovalPoliciesApprovers,
+ TAccessApprovalPoliciesApproversInsert,
+ TAccessApprovalPoliciesApproversUpdate,
+ TAccessApprovalPoliciesInsert,
+ TAccessApprovalPoliciesUpdate,
+ TAccessApprovalRequests,
+ TAccessApprovalRequestsInsert,
+ TAccessApprovalRequestsReviewers,
+ TAccessApprovalRequestsReviewersInsert,
+ TAccessApprovalRequestsReviewersUpdate,
+ TAccessApprovalRequestsUpdate,
TApiKeys,
TApiKeysInsert,
TApiKeysUpdate,
@@ -47,6 +59,9 @@ import {
TIdentityAccessTokens,
TIdentityAccessTokensInsert,
TIdentityAccessTokensUpdate,
+ TIdentityAwsIamAuths,
+ TIdentityAwsIamAuthsInsert,
+ TIdentityAwsIamAuthsUpdate,
TIdentityGcpIamAuths,
TIdentityGcpIamAuthsInsert,
TIdentityGcpIamAuthsUpdate,
@@ -322,6 +337,11 @@ declare module "knex/types/tables" {
TIdentityGcpIamAuthsInsert,
TIdentityGcpIamAuthsUpdate
>;
+ [TableName.IdentityAwsIamAuth]: Knex.CompositeTableType<
+ TIdentityAwsIamAuths,
+ TIdentityAwsIamAuthsInsert,
+ TIdentityAwsIamAuthsUpdate
+ >;
[TableName.IdentityUaClientSecret]: Knex.CompositeTableType<
TIdentityUaClientSecrets,
TIdentityUaClientSecretsInsert,
@@ -352,6 +372,31 @@ declare module "knex/types/tables" {
TIdentityProjectAdditionalPrivilegeInsert,
TIdentityProjectAdditionalPrivilegeUpdate
>;
+
+ [TableName.AccessApprovalPolicy]: Knex.CompositeTableType<
+ TAccessApprovalPolicies,
+ TAccessApprovalPoliciesInsert,
+ TAccessApprovalPoliciesUpdate
+ >;
+
+ [TableName.AccessApprovalPolicyApprover]: Knex.CompositeTableType<
+ TAccessApprovalPoliciesApprovers,
+ TAccessApprovalPoliciesApproversInsert,
+ TAccessApprovalPoliciesApproversUpdate
+ >;
+
+ [TableName.AccessApprovalRequest]: Knex.CompositeTableType<
+ TAccessApprovalRequests,
+ TAccessApprovalRequestsInsert,
+ TAccessApprovalRequestsUpdate
+ >;
+
+ [TableName.AccessApprovalRequestReviewer]: Knex.CompositeTableType<
+ TAccessApprovalRequestsReviewers,
+ TAccessApprovalRequestsReviewersInsert,
+ TAccessApprovalRequestsReviewersUpdate
+ >;
+
[TableName.ScimToken]: Knex.CompositeTableType;
[TableName.SecretApprovalPolicy]: Knex.CompositeTableType<
TSecretApprovalPolicies,
diff --git a/backend/src/db/migrations/20240405000045_org-memberships-unique-constraint.ts b/backend/src/db/migrations/20240330075120_org-memberships-unique-constraint.ts
similarity index 100%
rename from backend/src/db/migrations/20240405000045_org-memberships-unique-constraint.ts
rename to backend/src/db/migrations/20240330075120_org-memberships-unique-constraint.ts
diff --git a/backend/src/db/migrations/20240506163405_trusted-saml-ldap-emails.ts b/backend/src/db/migrations/20240507032811_trusted-saml-ldap-emails.ts
similarity index 76%
rename from backend/src/db/migrations/20240506163405_trusted-saml-ldap-emails.ts
rename to backend/src/db/migrations/20240507032811_trusted-saml-ldap-emails.ts
index 63aa75ad8f..410ee0f00e 100644
--- a/backend/src/db/migrations/20240506163405_trusted-saml-ldap-emails.ts
+++ b/backend/src/db/migrations/20240507032811_trusted-saml-ldap-emails.ts
@@ -5,9 +5,16 @@ import { TableName } from "../schemas";
export async function up(knex: Knex): Promise {
const isUsersTablePresent = await knex.schema.hasTable(TableName.Users);
if (isUsersTablePresent) {
- await knex.schema.alterTable(TableName.Users, (t) => {
- t.boolean("isEmailVerified");
- });
+ const hasIsEmailVerifiedColumn = await knex.schema.hasColumn(TableName.Users, "isEmailVerified");
+
+ if (!hasIsEmailVerifiedColumn) {
+ await knex.schema.alterTable(TableName.Users, (t) => {
+ t.boolean("isEmailVerified").defaultTo(false);
+ });
+ }
+
+ // Backfilling the isEmailVerified to true where isAccepted is true
+ await knex(TableName.Users).update({ isEmailVerified: true }).where("isAccepted", true);
}
const isUserAliasTablePresent = await knex.schema.hasTable(TableName.UserAliases);
diff --git a/backend/src/db/migrations/20240507055915_identity-aws-iam-auth.ts b/backend/src/db/migrations/20240507055915_identity-aws-iam-auth.ts
new file mode 100644
index 0000000000..0728d4f286
--- /dev/null
+++ b/backend/src/db/migrations/20240507055915_identity-aws-iam-auth.ts
@@ -0,0 +1,29 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+
+export async function up(knex: Knex): Promise {
+ if (!(await knex.schema.hasTable(TableName.IdentityAwsIamAuth))) {
+ await knex.schema.createTable(TableName.IdentityAwsIamAuth, (t) => {
+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+ t.bigInteger("accessTokenTTL").defaultTo(7200).notNullable();
+ t.bigInteger("accessTokenMaxTTL").defaultTo(7200).notNullable();
+ t.bigInteger("accessTokenNumUsesLimit").defaultTo(0).notNullable();
+ t.jsonb("accessTokenTrustedIps").notNullable();
+ t.timestamps(true, true, true);
+ t.uuid("identityId").notNullable().unique();
+ t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("CASCADE");
+ t.string("stsEndpoint").notNullable();
+ t.string("allowedPrincipalArns").notNullable();
+ t.string("allowedAccountIds").notNullable();
+ });
+ }
+
+ await createOnUpdateTrigger(knex, TableName.IdentityAwsIamAuth);
+}
+
+export async function down(knex: Knex): Promise {
+ await knex.schema.dropTableIfExists(TableName.IdentityAwsIamAuth);
+ await dropOnUpdateTrigger(knex, TableName.IdentityAwsIamAuth);
+}
diff --git a/backend/src/db/migrations/20240507162140_access-approval-policy.ts b/backend/src/db/migrations/20240507162140_access-approval-policy.ts
new file mode 100644
index 0000000000..feeecd25b6
--- /dev/null
+++ b/backend/src/db/migrations/20240507162140_access-approval-policy.ts
@@ -0,0 +1,41 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+
+export async function up(knex: Knex): Promise {
+ if (!(await knex.schema.hasTable(TableName.AccessApprovalPolicy))) {
+ await knex.schema.createTable(TableName.AccessApprovalPolicy, (t) => {
+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+ t.string("name").notNullable();
+ t.integer("approvals").defaultTo(1).notNullable();
+ t.string("secretPath");
+
+ t.uuid("envId").notNullable();
+ t.foreign("envId").references("id").inTable(TableName.Environment).onDelete("CASCADE");
+ t.timestamps(true, true, true);
+ });
+ await createOnUpdateTrigger(knex, TableName.AccessApprovalPolicy);
+ }
+
+ if (!(await knex.schema.hasTable(TableName.AccessApprovalPolicyApprover))) {
+ await knex.schema.createTable(TableName.AccessApprovalPolicyApprover, (t) => {
+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+ t.uuid("approverId").notNullable();
+ t.foreign("approverId").references("id").inTable(TableName.ProjectMembership).onDelete("CASCADE");
+
+ t.uuid("policyId").notNullable();
+ t.foreign("policyId").references("id").inTable(TableName.AccessApprovalPolicy).onDelete("CASCADE");
+ t.timestamps(true, true, true);
+ });
+ await createOnUpdateTrigger(knex, TableName.AccessApprovalPolicyApprover);
+ }
+}
+
+export async function down(knex: Knex): Promise {
+ await knex.schema.dropTableIfExists(TableName.AccessApprovalPolicyApprover);
+ await knex.schema.dropTableIfExists(TableName.AccessApprovalPolicy);
+
+ await dropOnUpdateTrigger(knex, TableName.AccessApprovalPolicyApprover);
+ await dropOnUpdateTrigger(knex, TableName.AccessApprovalPolicy);
+}
diff --git a/backend/src/db/migrations/20240507162141_access.ts b/backend/src/db/migrations/20240507162141_access.ts
new file mode 100644
index 0000000000..901be9a78e
--- /dev/null
+++ b/backend/src/db/migrations/20240507162141_access.ts
@@ -0,0 +1,51 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+
+export async function up(knex: Knex): Promise {
+ if (!(await knex.schema.hasTable(TableName.AccessApprovalRequest))) {
+ await knex.schema.createTable(TableName.AccessApprovalRequest, (t) => {
+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+
+ t.uuid("policyId").notNullable();
+ t.foreign("policyId").references("id").inTable(TableName.AccessApprovalPolicy).onDelete("CASCADE");
+
+ t.uuid("privilegeId").nullable();
+ t.foreign("privilegeId").references("id").inTable(TableName.ProjectUserAdditionalPrivilege).onDelete("CASCADE");
+
+ t.uuid("requestedBy").notNullable();
+ t.foreign("requestedBy").references("id").inTable(TableName.ProjectMembership).onDelete("CASCADE");
+
+ // We use these values to create the actual privilege at a later point in time.
+ t.boolean("isTemporary").notNullable();
+ t.string("temporaryRange").nullable();
+
+ t.jsonb("permissions").notNullable();
+
+ t.timestamps(true, true, true);
+ });
+ }
+ await createOnUpdateTrigger(knex, TableName.AccessApprovalRequest);
+
+ if (!(await knex.schema.hasTable(TableName.AccessApprovalRequestReviewer))) {
+ await knex.schema.createTable(TableName.AccessApprovalRequestReviewer, (t) => {
+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+ t.uuid("member").notNullable();
+ t.foreign("member").references("id").inTable(TableName.ProjectMembership).onDelete("CASCADE");
+ t.string("status").notNullable();
+ t.uuid("requestId").notNullable();
+ t.foreign("requestId").references("id").inTable(TableName.AccessApprovalRequest).onDelete("CASCADE");
+ t.timestamps(true, true, true);
+ });
+ }
+ await createOnUpdateTrigger(knex, TableName.AccessApprovalRequestReviewer);
+}
+
+export async function down(knex: Knex): Promise {
+ await knex.schema.dropTableIfExists(TableName.AccessApprovalRequestReviewer);
+ await knex.schema.dropTableIfExists(TableName.AccessApprovalRequest);
+
+ await dropOnUpdateTrigger(knex, TableName.AccessApprovalRequestReviewer);
+ await dropOnUpdateTrigger(knex, TableName.AccessApprovalRequest);
+}
diff --git a/backend/src/db/schemas/access-approval-policies-approvers.ts b/backend/src/db/schemas/access-approval-policies-approvers.ts
new file mode 100644
index 0000000000..4ebbfa9aec
--- /dev/null
+++ b/backend/src/db/schemas/access-approval-policies-approvers.ts
@@ -0,0 +1,25 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const AccessApprovalPoliciesApproversSchema = z.object({
+ id: z.string().uuid(),
+ approverId: z.string().uuid(),
+ policyId: z.string().uuid(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+});
+
+export type TAccessApprovalPoliciesApprovers = z.infer;
+export type TAccessApprovalPoliciesApproversInsert = Omit<
+ z.input,
+ TImmutableDBKeys
+>;
+export type TAccessApprovalPoliciesApproversUpdate = Partial<
+ Omit, TImmutableDBKeys>
+>;
diff --git a/backend/src/db/schemas/access-approval-policies.ts b/backend/src/db/schemas/access-approval-policies.ts
new file mode 100644
index 0000000000..bf7e74ff2c
--- /dev/null
+++ b/backend/src/db/schemas/access-approval-policies.ts
@@ -0,0 +1,24 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const AccessApprovalPoliciesSchema = z.object({
+ id: z.string().uuid(),
+ name: z.string(),
+ approvals: z.number().default(1),
+ envId: z.string().uuid(),
+ secretPath: z.string().nullable().optional(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+});
+
+export type TAccessApprovalPolicies = z.infer;
+export type TAccessApprovalPoliciesInsert = Omit, TImmutableDBKeys>;
+export type TAccessApprovalPoliciesUpdate = Partial<
+ Omit, TImmutableDBKeys>
+>;
diff --git a/backend/src/db/schemas/access-approval-requests-reviewers.ts b/backend/src/db/schemas/access-approval-requests-reviewers.ts
new file mode 100644
index 0000000000..509fd74259
--- /dev/null
+++ b/backend/src/db/schemas/access-approval-requests-reviewers.ts
@@ -0,0 +1,26 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const AccessApprovalRequestsReviewersSchema = z.object({
+ id: z.string().uuid(),
+ member: z.string().uuid(),
+ status: z.string(),
+ requestId: z.string().uuid(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+});
+
+export type TAccessApprovalRequestsReviewers = z.infer;
+export type TAccessApprovalRequestsReviewersInsert = Omit<
+ z.input,
+ TImmutableDBKeys
+>;
+export type TAccessApprovalRequestsReviewersUpdate = Partial<
+ Omit, TImmutableDBKeys>
+>;
diff --git a/backend/src/db/schemas/access-approval-requests.ts b/backend/src/db/schemas/access-approval-requests.ts
new file mode 100644
index 0000000000..bd598bac6e
--- /dev/null
+++ b/backend/src/db/schemas/access-approval-requests.ts
@@ -0,0 +1,26 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const AccessApprovalRequestsSchema = z.object({
+ id: z.string().uuid(),
+ policyId: z.string().uuid(),
+ privilegeId: z.string().uuid().nullable().optional(),
+ requestedBy: z.string().uuid(),
+ isTemporary: z.boolean(),
+ temporaryRange: z.string().nullable().optional(),
+ permissions: z.unknown(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+});
+
+export type TAccessApprovalRequests = z.infer;
+export type TAccessApprovalRequestsInsert = Omit, TImmutableDBKeys>;
+export type TAccessApprovalRequestsUpdate = Partial<
+ Omit, TImmutableDBKeys>
+>;
diff --git a/backend/src/db/schemas/identity-aws-iam-auths.ts b/backend/src/db/schemas/identity-aws-iam-auths.ts
new file mode 100644
index 0000000000..8912c71b39
--- /dev/null
+++ b/backend/src/db/schemas/identity-aws-iam-auths.ts
@@ -0,0 +1,26 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const IdentityAwsIamAuthsSchema = z.object({
+ id: z.string().uuid(),
+ accessTokenTTL: z.coerce.number().default(7200),
+ accessTokenMaxTTL: z.coerce.number().default(7200),
+ accessTokenNumUsesLimit: z.coerce.number().default(0),
+ accessTokenTrustedIps: z.unknown(),
+ createdAt: z.date(),
+ updatedAt: z.date(),
+ identityId: z.string().uuid(),
+ stsEndpoint: z.string(),
+ allowedPrincipalArns: z.string(),
+ allowedAccountIds: z.string()
+});
+
+export type TIdentityAwsIamAuths = z.infer;
+export type TIdentityAwsIamAuthsInsert = Omit, TImmutableDBKeys>;
+export type TIdentityAwsIamAuthsUpdate = Partial, TImmutableDBKeys>>;
diff --git a/backend/src/db/schemas/index.ts b/backend/src/db/schemas/index.ts
index 7a365b18c0..0b8f1c22e4 100644
--- a/backend/src/db/schemas/index.ts
+++ b/backend/src/db/schemas/index.ts
@@ -1,3 +1,7 @@
+export * from "./access-approval-policies";
+export * from "./access-approval-policies-approvers";
+export * from "./access-approval-requests";
+export * from "./access-approval-requests-reviewers";
export * from "./api-keys";
export * from "./audit-log-streams";
export * from "./audit-logs";
@@ -13,6 +17,7 @@ export * from "./group-project-memberships";
export * from "./groups";
export * from "./identities";
export * from "./identity-access-tokens";
+export * from "./identity-aws-iam-auths";
export * from "./identity-gcp-iam-auths";
export * from "./identity-org-memberships";
export * from "./identity-project-additional-privilege";
diff --git a/backend/src/db/schemas/models.ts b/backend/src/db/schemas/models.ts
index b1006f51dc..2a4c2d9e6a 100644
--- a/backend/src/db/schemas/models.ts
+++ b/backend/src/db/schemas/models.ts
@@ -46,11 +46,16 @@ export enum TableName {
IdentityUniversalAuth = "identity_universal_auths",
IdentityGcpIamAuth = "identity_gcp_iam_auths",
IdentityUaClientSecret = "identity_ua_client_secrets",
+ IdentityAwsIamAuth = "identity_aws_iam_auths",
IdentityOrgMembership = "identity_org_memberships",
IdentityProjectMembership = "identity_project_memberships",
IdentityProjectMembershipRole = "identity_project_membership_role",
IdentityProjectAdditionalPrivilege = "identity_project_additional_privilege",
ScimToken = "scim_tokens",
+ AccessApprovalPolicy = "access_approval_policies",
+ AccessApprovalPolicyApprover = "access_approval_policies_approvers",
+ AccessApprovalRequest = "access_approval_requests",
+ AccessApprovalRequestReviewer = "access_approval_requests_reviewers",
SecretApprovalPolicy = "secret_approval_policies",
SecretApprovalPolicyApprover = "secret_approval_policies_approvers",
SecretApprovalRequest = "secret_approval_requests",
@@ -140,5 +145,6 @@ export enum ProjectUpgradeStatus {
export enum IdentityAuthMethod {
Univeral = "universal-auth",
- GCP_IAM_AUTH = "gcp-iam-auth"
+ GCP_IAM_AUTH = "gcp-iam-auth",
+ AWS_IAM_AUTH = "aws-iam-auth"
}
diff --git a/backend/src/ee/routes/v1/access-approval-policy-router.ts b/backend/src/ee/routes/v1/access-approval-policy-router.ts
new file mode 100644
index 0000000000..3b8949d3bb
--- /dev/null
+++ b/backend/src/ee/routes/v1/access-approval-policy-router.ts
@@ -0,0 +1,168 @@
+import { nanoid } from "nanoid";
+import { z } from "zod";
+
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { sapPubSchema } from "@app/server/routes/sanitizedSchemas";
+import { AuthMode } from "@app/services/auth/auth-type";
+
+export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ url: "/",
+ method: "POST",
+ schema: {
+ body: z
+ .object({
+ projectSlug: z.string().trim(),
+ name: z.string().optional(),
+ secretPath: z.string().trim().default("/"),
+ environment: z.string(),
+ approvers: z.string().array().min(1),
+ approvals: z.number().min(1).default(1)
+ })
+ .refine((data) => data.approvals <= data.approvers.length, {
+ path: ["approvals"],
+ message: "The number of approvals should be lower than the number of approvers."
+ }),
+ response: {
+ 200: z.object({
+ approval: sapPubSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const approval = await server.services.accessApprovalPolicy.createAccessApprovalPolicy({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ ...req.body,
+ projectSlug: req.body.projectSlug,
+ name: req.body.name ?? `${req.body.environment}-${nanoid(3)}`
+ });
+ return { approval };
+ }
+ });
+
+ server.route({
+ url: "/",
+ method: "GET",
+ schema: {
+ querystring: z.object({
+ projectSlug: z.string().trim()
+ }),
+ response: {
+ 200: z.object({
+ approvals: sapPubSchema.extend({ approvers: z.string().array(), secretPath: z.string().optional() }).array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const approvals = await server.services.accessApprovalPolicy.getAccessApprovalPolicyByProjectSlug({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectSlug: req.query.projectSlug
+ });
+ return { approvals };
+ }
+ });
+
+ server.route({
+ url: "/count",
+ method: "GET",
+ schema: {
+ querystring: z.object({
+ projectSlug: z.string(),
+ envSlug: z.string()
+ }),
+ response: {
+ 200: z.object({
+ count: z.number()
+ })
+ }
+ },
+
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const { count } = await server.services.accessApprovalPolicy.getAccessPolicyCountByEnvSlug({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ projectSlug: req.query.projectSlug,
+ actorOrgId: req.permission.orgId,
+ envSlug: req.query.envSlug
+ });
+ return { count };
+ }
+ });
+
+ server.route({
+ url: "/:policyId",
+ method: "PATCH",
+ schema: {
+ params: z.object({
+ policyId: z.string()
+ }),
+ body: z
+ .object({
+ name: z.string().optional(),
+ secretPath: z
+ .string()
+ .trim()
+ .optional()
+ .transform((val) => (val === "" ? "/" : val)),
+ approvers: z.string().array().min(1),
+ approvals: z.number().min(1).default(1)
+ })
+ .refine((data) => data.approvals <= data.approvers.length, {
+ path: ["approvals"],
+ message: "The number of approvals should be lower than the number of approvers."
+ }),
+ response: {
+ 200: z.object({
+ approval: sapPubSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ await server.services.accessApprovalPolicy.updateAccessApprovalPolicy({
+ policyId: req.params.policyId,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ ...req.body
+ });
+ }
+ });
+
+ server.route({
+ url: "/:policyId",
+ method: "DELETE",
+ schema: {
+ params: z.object({
+ policyId: z.string()
+ }),
+ response: {
+ 200: z.object({
+ approval: sapPubSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const approval = await server.services.accessApprovalPolicy.deleteAccessApprovalPolicy({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ policyId: req.params.policyId
+ });
+ return { approval };
+ }
+ });
+};
diff --git a/backend/src/ee/routes/v1/access-approval-request-router.ts b/backend/src/ee/routes/v1/access-approval-request-router.ts
new file mode 100644
index 0000000000..4b173cfa76
--- /dev/null
+++ b/backend/src/ee/routes/v1/access-approval-request-router.ts
@@ -0,0 +1,160 @@
+import { z } from "zod";
+
+import { AccessApprovalRequestsReviewersSchema, AccessApprovalRequestsSchema } from "@app/db/schemas";
+import { ApprovalStatus } from "@app/ee/services/access-approval-request/access-approval-request-types";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+
+export const registerAccessApprovalRequestRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ url: "/",
+ method: "POST",
+ schema: {
+ body: z.object({
+ permissions: z.any().array(),
+ isTemporary: z.boolean(),
+ temporaryRange: z.string().optional()
+ }),
+ querystring: z.object({
+ projectSlug: z.string().trim()
+ }),
+ response: {
+ 200: z.object({
+ approval: AccessApprovalRequestsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const { request } = await server.services.accessApprovalRequest.createAccessApprovalRequest({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ permissions: req.body.permissions,
+ actorOrgId: req.permission.orgId,
+ projectSlug: req.query.projectSlug,
+ temporaryRange: req.body.temporaryRange,
+ isTemporary: req.body.isTemporary
+ });
+ return { approval: request };
+ }
+ });
+
+ server.route({
+ url: "/count",
+ method: "GET",
+ schema: {
+ querystring: z.object({
+ projectSlug: z.string().trim()
+ }),
+ response: {
+ 200: z.object({
+ pendingCount: z.number(),
+ finalizedCount: z.number()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const { count } = await server.services.accessApprovalRequest.getCount({
+ projectSlug: req.query.projectSlug,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
+
+ return { ...count };
+ }
+ });
+
+ server.route({
+ url: "/",
+ method: "GET",
+ schema: {
+ querystring: z.object({
+ projectSlug: z.string().trim(),
+ authorProjectMembershipId: z.string().trim().optional(),
+ envSlug: z.string().trim().optional()
+ }),
+ response: {
+ 200: z.object({
+ requests: AccessApprovalRequestsSchema.extend({
+ environmentName: z.string(),
+ isApproved: z.boolean(),
+ privilege: z
+ .object({
+ membershipId: z.string(),
+ isTemporary: z.boolean(),
+ temporaryMode: z.string().nullish(),
+ temporaryRange: z.string().nullish(),
+ temporaryAccessStartTime: z.date().nullish(),
+ temporaryAccessEndTime: z.date().nullish(),
+ permissions: z.unknown()
+ })
+ .nullable(),
+ policy: z.object({
+ id: z.string(),
+ name: z.string(),
+ approvals: z.number(),
+ approvers: z.string().array(),
+ secretPath: z.string().nullish(),
+ envId: z.string()
+ }),
+ reviewers: z
+ .object({
+ member: z.string(),
+ status: z.string()
+ })
+ .array()
+ }).array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const { requests } = await server.services.accessApprovalRequest.listApprovalRequests({
+ projectSlug: req.query.projectSlug,
+ authorProjectMembershipId: req.query.authorProjectMembershipId,
+ envSlug: req.query.envSlug,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
+
+ return { requests };
+ }
+ });
+
+ server.route({
+ url: "/:requestId/review",
+ method: "POST",
+ schema: {
+ params: z.object({
+ requestId: z.string().trim()
+ }),
+ body: z.object({
+ status: z.enum([ApprovalStatus.APPROVED, ApprovalStatus.REJECTED])
+ }),
+ response: {
+ 200: z.object({
+ review: AccessApprovalRequestsReviewersSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const review = await server.services.accessApprovalRequest.reviewAccessRequest({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod,
+ requestId: req.params.requestId,
+ status: req.body.status
+ });
+
+ return { review };
+ }
+ });
+};
diff --git a/backend/src/ee/routes/v1/index.ts b/backend/src/ee/routes/v1/index.ts
index cf325b2e36..16e23eb887 100644
--- a/backend/src/ee/routes/v1/index.ts
+++ b/backend/src/ee/routes/v1/index.ts
@@ -1,3 +1,5 @@
+import { registerAccessApprovalPolicyRouter } from "./access-approval-policy-router";
+import { registerAccessApprovalRequestRouter } from "./access-approval-request-router";
import { registerAuditLogStreamRouter } from "./audit-log-stream-router";
import { registerDynamicSecretLeaseRouter } from "./dynamic-secret-lease-router";
import { registerDynamicSecretRouter } from "./dynamic-secret-router";
@@ -41,6 +43,9 @@ export const registerV1EERoutes = async (server: FastifyZodProvider) => {
prefix: "/secret-rotation-providers"
});
+ await server.register(registerAccessApprovalPolicyRouter, { prefix: "/access-approvals/policies" });
+ await server.register(registerAccessApprovalRequestRouter, { prefix: "/access-approvals/requests" });
+
await server.register(
async (dynamicSecretRouter) => {
await dynamicSecretRouter.register(registerDynamicSecretRouter);
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-approver-dal.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-approver-dal.ts
new file mode 100644
index 0000000000..e14854d8ff
--- /dev/null
+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-approver-dal.ts
@@ -0,0 +1,10 @@
+import { TDbClient } from "@app/db";
+import { TableName } from "@app/db/schemas";
+import { ormify } from "@app/lib/knex";
+
+export type TAccessApprovalPolicyApproverDALFactory = ReturnType;
+
+export const accessApprovalPolicyApproverDALFactory = (db: TDbClient) => {
+ const accessApprovalPolicyApproverOrm = ormify(db, TableName.AccessApprovalPolicyApprover);
+ return { ...accessApprovalPolicyApproverOrm };
+};
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-dal.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-dal.ts
new file mode 100644
index 0000000000..88e2888329
--- /dev/null
+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-dal.ts
@@ -0,0 +1,76 @@
+import { Knex } from "knex";
+
+import { TDbClient } from "@app/db";
+import { TableName, TAccessApprovalPolicies } from "@app/db/schemas";
+import { DatabaseError } from "@app/lib/errors";
+import { buildFindFilter, mergeOneToManyRelation, ormify, selectAllTableCols, TFindFilter } from "@app/lib/knex";
+
+export type TAccessApprovalPolicyDALFactory = ReturnType;
+
+export const accessApprovalPolicyDALFactory = (db: TDbClient) => {
+ const accessApprovalPolicyOrm = ormify(db, TableName.AccessApprovalPolicy);
+
+ const accessApprovalPolicyFindQuery = async (tx: Knex, filter: TFindFilter) => {
+ const result = await tx(TableName.AccessApprovalPolicy)
+ // eslint-disable-next-line
+ .where(buildFindFilter(filter))
+ .join(TableName.Environment, `${TableName.AccessApprovalPolicy}.envId`, `${TableName.Environment}.id`)
+ .join(
+ TableName.AccessApprovalPolicyApprover,
+ `${TableName.AccessApprovalPolicy}.id`,
+ `${TableName.AccessApprovalPolicyApprover}.policyId`
+ )
+ .select(tx.ref("approverId").withSchema(TableName.AccessApprovalPolicyApprover))
+ .select(tx.ref("name").withSchema(TableName.Environment).as("envName"))
+ .select(tx.ref("slug").withSchema(TableName.Environment).as("envSlug"))
+ .select(tx.ref("id").withSchema(TableName.Environment).as("envId"))
+ .select(tx.ref("projectId").withSchema(TableName.Environment))
+ .select(selectAllTableCols(TableName.AccessApprovalPolicy));
+
+ return result;
+ };
+
+ const findById = async (id: string, tx?: Knex) => {
+ try {
+ const doc = await accessApprovalPolicyFindQuery(tx || db, {
+ [`${TableName.AccessApprovalPolicy}.id` as "id"]: id
+ });
+ const formatedDoc = mergeOneToManyRelation(
+ doc,
+ "id",
+ ({ approverId, envId, envName: name, envSlug: slug, ...el }) => ({
+ ...el,
+ envId,
+ environment: { id: envId, name, slug }
+ }),
+ ({ approverId }) => approverId,
+ "approvers"
+ );
+ return formatedDoc?.[0];
+ } catch (error) {
+ throw new DatabaseError({ error, name: "FindById" });
+ }
+ };
+
+ const find = async (filter: TFindFilter, tx?: Knex) => {
+ try {
+ const docs = await accessApprovalPolicyFindQuery(tx || db, filter);
+ const formatedDoc = mergeOneToManyRelation(
+ docs,
+ "id",
+ ({ approverId, envId, envName: name, envSlug: slug, ...el }) => ({
+ ...el,
+ envId,
+ environment: { id: envId, name, slug }
+ }),
+ ({ approverId }) => approverId,
+ "approvers"
+ );
+ return formatedDoc.map((policy) => ({ ...policy, secretPath: policy.secretPath || undefined }));
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Find" });
+ }
+ };
+
+ return { ...accessApprovalPolicyOrm, find, findById };
+};
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.ts
new file mode 100644
index 0000000000..7b0a2681fa
--- /dev/null
+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.ts
@@ -0,0 +1,36 @@
+import { ForbiddenError, subject } from "@casl/ability";
+
+import { BadRequestError } from "@app/lib/errors";
+import { ActorType } from "@app/services/auth/auth-type";
+
+import { ProjectPermissionActions, ProjectPermissionSub } from "../permission/project-permission";
+import { TVerifyApprovers } from "./access-approval-policy-types";
+
+export const verifyApprovers = async ({
+ userIds,
+ projectId,
+ orgId,
+ envSlug,
+ actorAuthMethod,
+ secretPath,
+ permissionService
+}: TVerifyApprovers) => {
+ for await (const userId of userIds) {
+ try {
+ const { permission: approverPermission } = await permissionService.getProjectPermission(
+ ActorType.USER,
+ userId,
+ projectId,
+ actorAuthMethod,
+ orgId
+ );
+
+ ForbiddenError.from(approverPermission).throwUnlessCan(
+ ProjectPermissionActions.Create,
+ subject(ProjectPermissionSub.Secrets, { environment: envSlug, secretPath })
+ );
+ } catch (err) {
+ throw new BadRequestError({ message: "One or more approvers doesn't have access to be specified secret path" });
+ }
+ }
+};
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-service.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-service.ts
new file mode 100644
index 0000000000..51a51abb5a
--- /dev/null
+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-service.ts
@@ -0,0 +1,273 @@
+import { ForbiddenError } from "@casl/ability";
+
+import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
+import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
+import { BadRequestError } from "@app/lib/errors";
+import { TProjectDALFactory } from "@app/services/project/project-dal";
+import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";
+import { TProjectMembershipDALFactory } from "@app/services/project-membership/project-membership-dal";
+
+import { TAccessApprovalPolicyApproverDALFactory } from "./access-approval-policy-approver-dal";
+import { TAccessApprovalPolicyDALFactory } from "./access-approval-policy-dal";
+import { verifyApprovers } from "./access-approval-policy-fns";
+import {
+ TCreateAccessApprovalPolicy,
+ TDeleteAccessApprovalPolicy,
+ TGetAccessPolicyCountByEnvironmentDTO,
+ TListAccessApprovalPoliciesDTO,
+ TUpdateAccessApprovalPolicy
+} from "./access-approval-policy-types";
+
+type TSecretApprovalPolicyServiceFactoryDep = {
+ projectDAL: TProjectDALFactory;
+ permissionService: Pick;
+ accessApprovalPolicyDAL: TAccessApprovalPolicyDALFactory;
+ projectEnvDAL: Pick;
+ accessApprovalPolicyApproverDAL: TAccessApprovalPolicyApproverDALFactory;
+ projectMembershipDAL: Pick;
+};
+
+export type TAccessApprovalPolicyServiceFactory = ReturnType;
+
+export const accessApprovalPolicyServiceFactory = ({
+ accessApprovalPolicyDAL,
+ accessApprovalPolicyApproverDAL,
+ permissionService,
+ projectEnvDAL,
+ projectDAL,
+ projectMembershipDAL
+}: TSecretApprovalPolicyServiceFactoryDep) => {
+ const createAccessApprovalPolicy = async ({
+ name,
+ actor,
+ actorId,
+ actorOrgId,
+ secretPath,
+ actorAuthMethod,
+ approvals,
+ approvers,
+ projectSlug,
+ environment
+ }: TCreateAccessApprovalPolicy) => {
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+ if (!project) throw new BadRequestError({ message: "Project not found" });
+
+ if (approvals > approvers.length)
+ throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
+
+ const { permission } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionActions.Create,
+ ProjectPermissionSub.SecretApproval
+ );
+ const env = await projectEnvDAL.findOne({ slug: environment, projectId: project.id });
+ if (!env) throw new BadRequestError({ message: "Environment not found" });
+
+ const secretApprovers = await projectMembershipDAL.find({
+ projectId: project.id,
+ $in: { id: approvers }
+ });
+
+ if (secretApprovers.length !== approvers.length) {
+ throw new BadRequestError({ message: "Approver not found in project" });
+ }
+
+ await verifyApprovers({
+ projectId: project.id,
+ orgId: actorOrgId,
+ envSlug: environment,
+ secretPath,
+ actorAuthMethod,
+ permissionService,
+ userIds: secretApprovers.map((approver) => approver.userId)
+ });
+
+ const accessApproval = await accessApprovalPolicyDAL.transaction(async (tx) => {
+ const doc = await accessApprovalPolicyDAL.create(
+ {
+ envId: env.id,
+ approvals,
+ secretPath,
+ name
+ },
+ tx
+ );
+ await accessApprovalPolicyApproverDAL.insertMany(
+ secretApprovers.map(({ id }) => ({
+ approverId: id,
+ policyId: doc.id
+ })),
+ tx
+ );
+ return doc;
+ });
+ return { ...accessApproval, environment: env, projectId: project.id };
+ };
+
+ const getAccessApprovalPolicyByProjectSlug = async ({
+ actorId,
+ actor,
+ actorOrgId,
+ actorAuthMethod,
+ projectSlug
+ }: TListAccessApprovalPoliciesDTO) => {
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+ if (!project) throw new BadRequestError({ message: "Project not found" });
+
+ // Anyone in the project should be able to get the policies.
+ /* const { permission } = */ await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ // ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval);
+
+ const accessApprovalPolicies = await accessApprovalPolicyDAL.find({ projectId: project.id });
+ return accessApprovalPolicies;
+ };
+
+ const updateAccessApprovalPolicy = async ({
+ policyId,
+ approvers,
+ secretPath,
+ name,
+ actorId,
+ actor,
+ actorOrgId,
+ actorAuthMethod,
+ approvals
+ }: TUpdateAccessApprovalPolicy) => {
+ const accessApprovalPolicy = await accessApprovalPolicyDAL.findById(policyId);
+ if (!accessApprovalPolicy) throw new BadRequestError({ message: "Secret approval policy not found" });
+ const { permission } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ accessApprovalPolicy.projectId,
+ actorAuthMethod,
+ actorOrgId
+ );
+
+ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretApproval);
+
+ const updatedPolicy = await accessApprovalPolicyDAL.transaction(async (tx) => {
+ const doc = await accessApprovalPolicyDAL.updateById(
+ accessApprovalPolicy.id,
+ {
+ approvals,
+ secretPath,
+ name
+ },
+ tx
+ );
+ if (approvers) {
+ // Find the workspace project memberships of the users passed in the approvers array
+ const secretApprovers = await projectMembershipDAL.find(
+ {
+ projectId: accessApprovalPolicy.projectId,
+ $in: { id: approvers }
+ },
+ { tx }
+ );
+
+ await verifyApprovers({
+ projectId: accessApprovalPolicy.projectId,
+ orgId: actorOrgId,
+ envSlug: accessApprovalPolicy.environment.slug,
+ secretPath: doc.secretPath!,
+ actorAuthMethod,
+ permissionService,
+ userIds: secretApprovers.map((approver) => approver.userId)
+ });
+
+ if (secretApprovers.length !== approvers.length)
+ throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
+ await accessApprovalPolicyApproverDAL.delete({ policyId: doc.id }, tx);
+ await accessApprovalPolicyApproverDAL.insertMany(
+ secretApprovers.map(({ id }) => ({
+ approverId: id,
+ policyId: doc.id
+ })),
+ tx
+ );
+ }
+ return doc;
+ });
+ return {
+ ...updatedPolicy,
+ environment: accessApprovalPolicy.environment,
+ projectId: accessApprovalPolicy.projectId
+ };
+ };
+
+ const deleteAccessApprovalPolicy = async ({
+ policyId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TDeleteAccessApprovalPolicy) => {
+ const policy = await accessApprovalPolicyDAL.findById(policyId);
+ if (!policy) throw new BadRequestError({ message: "Secret approval policy not found" });
+
+ const { permission } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ policy.projectId,
+ actorAuthMethod,
+ actorOrgId
+ );
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionActions.Delete,
+ ProjectPermissionSub.SecretApproval
+ );
+
+ await accessApprovalPolicyDAL.deleteById(policyId);
+ return policy;
+ };
+
+ const getAccessPolicyCountByEnvSlug = async ({
+ actor,
+ actorOrgId,
+ actorAuthMethod,
+ projectSlug,
+ actorId,
+ envSlug
+ }: TGetAccessPolicyCountByEnvironmentDTO) => {
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+
+ if (!project) throw new BadRequestError({ message: "Project not found" });
+
+ const { membership } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ if (!membership) throw new BadRequestError({ message: "User not found in project" });
+
+ const environment = await projectEnvDAL.findOne({ projectId: project.id, slug: envSlug });
+ if (!environment) throw new BadRequestError({ message: "Environment not found" });
+
+ const policies = await accessApprovalPolicyDAL.find({ envId: environment.id, projectId: project.id });
+ if (!policies) throw new BadRequestError({ message: "No policies found" });
+
+ return { count: policies.length };
+ };
+
+ return {
+ getAccessPolicyCountByEnvSlug,
+ createAccessApprovalPolicy,
+ deleteAccessApprovalPolicy,
+ updateAccessApprovalPolicy,
+ getAccessApprovalPolicyByProjectSlug
+ };
+};
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-types.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-types.ts
new file mode 100644
index 0000000000..601561b680
--- /dev/null
+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-types.ts
@@ -0,0 +1,44 @@
+import { TProjectPermission } from "@app/lib/types";
+import { ActorAuthMethod } from "@app/services/auth/auth-type";
+
+import { TPermissionServiceFactory } from "../permission/permission-service";
+
+export type TVerifyApprovers = {
+ userIds: string[];
+ permissionService: Pick;
+ envSlug: string;
+ actorAuthMethod: ActorAuthMethod;
+ secretPath: string;
+ projectId: string;
+ orgId: string;
+};
+
+export type TCreateAccessApprovalPolicy = {
+ approvals: number;
+ secretPath: string;
+ environment: string;
+ approvers: string[];
+ projectSlug: string;
+ name: string;
+} & Omit;
+
+export type TUpdateAccessApprovalPolicy = {
+ policyId: string;
+ approvals?: number;
+ approvers?: string[];
+ secretPath?: string;
+ name?: string;
+} & Omit;
+
+export type TDeleteAccessApprovalPolicy = {
+ policyId: string;
+} & Omit;
+
+export type TGetAccessPolicyCountByEnvironmentDTO = {
+ envSlug: string;
+ projectSlug: string;
+} & Omit;
+
+export type TListAccessApprovalPoliciesDTO = {
+ projectSlug: string;
+} & Omit;
diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-dal.ts b/backend/src/ee/services/access-approval-request/access-approval-request-dal.ts
new file mode 100644
index 0000000000..c3f4c72a66
--- /dev/null
+++ b/backend/src/ee/services/access-approval-request/access-approval-request-dal.ts
@@ -0,0 +1,266 @@
+import { Knex } from "knex";
+
+import { TDbClient } from "@app/db";
+import { AccessApprovalRequestsSchema, TableName, TAccessApprovalRequests } from "@app/db/schemas";
+import { DatabaseError } from "@app/lib/errors";
+import { ormify, selectAllTableCols, sqlNestRelationships, TFindFilter } from "@app/lib/knex";
+
+import { ApprovalStatus } from "./access-approval-request-types";
+
+export type TAccessApprovalRequestDALFactory = ReturnType;
+
+export const accessApprovalRequestDALFactory = (db: TDbClient) => {
+ const accessApprovalRequestOrm = ormify(db, TableName.AccessApprovalRequest);
+
+ const findRequestsWithPrivilegeByPolicyIds = async (policyIds: string[]) => {
+ try {
+ const docs = await db(TableName.AccessApprovalRequest)
+ .whereIn(`${TableName.AccessApprovalRequest}.policyId`, policyIds)
+
+ .leftJoin(
+ TableName.ProjectUserAdditionalPrivilege,
+ `${TableName.AccessApprovalRequest}.privilegeId`,
+ `${TableName.ProjectUserAdditionalPrivilege}.id`
+ )
+ .leftJoin(
+ TableName.AccessApprovalPolicy,
+ `${TableName.AccessApprovalRequest}.policyId`,
+ `${TableName.AccessApprovalPolicy}.id`
+ )
+
+ .leftJoin(
+ TableName.AccessApprovalRequestReviewer,
+ `${TableName.AccessApprovalRequest}.id`,
+ `${TableName.AccessApprovalRequestReviewer}.requestId`
+ )
+ .leftJoin(
+ TableName.AccessApprovalPolicyApprover,
+ `${TableName.AccessApprovalPolicy}.id`,
+ `${TableName.AccessApprovalPolicyApprover}.policyId`
+ )
+
+ .leftJoin(TableName.Environment, `${TableName.AccessApprovalPolicy}.envId`, `${TableName.Environment}.id`)
+
+ .select(selectAllTableCols(TableName.AccessApprovalRequest))
+ .select(
+ db.ref("id").withSchema(TableName.AccessApprovalPolicy).as("policyId"),
+ db.ref("name").withSchema(TableName.AccessApprovalPolicy).as("policyName"),
+ db.ref("approvals").withSchema(TableName.AccessApprovalPolicy).as("policyApprovals"),
+ db.ref("secretPath").withSchema(TableName.AccessApprovalPolicy).as("policySecretPath"),
+ db.ref("envId").withSchema(TableName.AccessApprovalPolicy).as("policyEnvId")
+ )
+
+ .select(db.ref("approverId").withSchema(TableName.AccessApprovalPolicyApprover))
+
+ .select(
+ db.ref("projectId").withSchema(TableName.Environment),
+ db.ref("slug").withSchema(TableName.Environment).as("envSlug"),
+ db.ref("name").withSchema(TableName.Environment).as("envName")
+ )
+
+ .select(
+ db.ref("member").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerMemberId"),
+ db.ref("status").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerStatus")
+ )
+
+ .select(
+ db
+ .ref("projectMembershipId")
+ .withSchema(TableName.ProjectUserAdditionalPrivilege)
+ .as("privilegeMembershipId"),
+ db.ref("isTemporary").withSchema(TableName.ProjectUserAdditionalPrivilege).as("privilegeIsTemporary"),
+ db.ref("temporaryMode").withSchema(TableName.ProjectUserAdditionalPrivilege).as("privilegeTemporaryMode"),
+ db.ref("temporaryRange").withSchema(TableName.ProjectUserAdditionalPrivilege).as("privilegeTemporaryRange"),
+ db
+ .ref("temporaryAccessStartTime")
+ .withSchema(TableName.ProjectUserAdditionalPrivilege)
+ .as("privilegeTemporaryAccessStartTime"),
+ db
+ .ref("temporaryAccessEndTime")
+ .withSchema(TableName.ProjectUserAdditionalPrivilege)
+ .as("privilegeTemporaryAccessEndTime"),
+
+ db.ref("permissions").withSchema(TableName.ProjectUserAdditionalPrivilege).as("privilegePermissions")
+ )
+ .orderBy(`${TableName.AccessApprovalRequest}.createdAt`, "desc");
+
+ const formattedDocs = sqlNestRelationships({
+ data: docs,
+ key: "id",
+ parentMapper: (doc) => ({
+ ...AccessApprovalRequestsSchema.parse(doc),
+ projectId: doc.projectId,
+ environment: doc.envSlug,
+ environmentName: doc.envName,
+ policy: {
+ id: doc.policyId,
+ name: doc.policyName,
+ approvals: doc.policyApprovals,
+ secretPath: doc.policySecretPath,
+ envId: doc.policyEnvId
+ },
+ privilege: doc.privilegeId
+ ? {
+ membershipId: doc.privilegeMembershipId,
+ isTemporary: doc.privilegeIsTemporary,
+ temporaryMode: doc.privilegeTemporaryMode,
+ temporaryRange: doc.privilegeTemporaryRange,
+ temporaryAccessStartTime: doc.privilegeTemporaryAccessStartTime,
+ temporaryAccessEndTime: doc.privilegeTemporaryAccessEndTime,
+ permissions: doc.privilegePermissions
+ }
+ : null,
+
+ isApproved: !!doc.privilegeId
+ }),
+ childrenMapper: [
+ {
+ key: "reviewerMemberId",
+ label: "reviewers" as const,
+ mapper: ({ reviewerMemberId: member, reviewerStatus: status }) => (member ? { member, status } : undefined)
+ },
+ { key: "approverId", label: "approvers" as const, mapper: ({ approverId }) => approverId }
+ ]
+ });
+
+ if (!formattedDocs) return [];
+
+ return formattedDocs.map((doc) => ({
+ ...doc,
+ policy: { ...doc.policy, approvers: doc.approvers }
+ }));
+ } catch (error) {
+ throw new DatabaseError({ error, name: "FindRequestsWithPrivilege" });
+ }
+ };
+
+ const findQuery = (filter: TFindFilter, tx: Knex) =>
+ tx(TableName.AccessApprovalRequest)
+ .where(filter)
+ .join(
+ TableName.AccessApprovalPolicy,
+ `${TableName.AccessApprovalRequest}.policyId`,
+ `${TableName.AccessApprovalPolicy}.id`
+ )
+
+ .join(
+ TableName.AccessApprovalPolicyApprover,
+ `${TableName.AccessApprovalPolicy}.id`,
+ `${TableName.AccessApprovalPolicyApprover}.policyId`
+ )
+ .leftJoin(
+ TableName.AccessApprovalRequestReviewer,
+ `${TableName.AccessApprovalRequest}.id`,
+ `${TableName.AccessApprovalRequestReviewer}.requestId`
+ )
+
+ .leftJoin(TableName.Environment, `${TableName.AccessApprovalPolicy}.envId`, `${TableName.Environment}.id`)
+ .select(selectAllTableCols(TableName.AccessApprovalRequest))
+ .select(
+ tx.ref("member").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerMemberId"),
+ tx.ref("status").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerStatus"),
+ tx.ref("id").withSchema(TableName.AccessApprovalPolicy).as("policyId"),
+ tx.ref("name").withSchema(TableName.AccessApprovalPolicy).as("policyName"),
+ tx.ref("projectId").withSchema(TableName.Environment),
+ tx.ref("slug").withSchema(TableName.Environment).as("environment"),
+ tx.ref("secretPath").withSchema(TableName.AccessApprovalPolicy).as("policySecretPath"),
+ tx.ref("approvals").withSchema(TableName.AccessApprovalPolicy).as("policyApprovals"),
+ tx.ref("approverId").withSchema(TableName.AccessApprovalPolicyApprover)
+ );
+
+ const findById = async (id: string, tx?: Knex) => {
+ try {
+ const sql = findQuery({ [`${TableName.AccessApprovalRequest}.id` as "id"]: id }, tx || db);
+ const docs = await sql;
+ const formatedDoc = sqlNestRelationships({
+ data: docs,
+ key: "id",
+ parentMapper: (el) => ({
+ ...AccessApprovalRequestsSchema.parse(el),
+ projectId: el.projectId,
+ environment: el.environment,
+ policy: {
+ id: el.policyId,
+ name: el.policyName,
+ approvals: el.policyApprovals,
+ secretPath: el.policySecretPath
+ }
+ }),
+ childrenMapper: [
+ {
+ key: "reviewerMemberId",
+ label: "reviewers" as const,
+ mapper: ({ reviewerMemberId: member, reviewerStatus: status }) => (member ? { member, status } : undefined)
+ },
+ { key: "approverId", label: "approvers" as const, mapper: ({ approverId }) => approverId }
+ ]
+ });
+ if (!formatedDoc?.[0]) return;
+ return {
+ ...formatedDoc[0],
+ policy: { ...formatedDoc[0].policy, approvers: formatedDoc[0].approvers }
+ };
+ } catch (error) {
+ throw new DatabaseError({ error, name: "FindByIdAccessApprovalRequest" });
+ }
+ };
+
+ const getCount = async ({ projectId }: { projectId: string }) => {
+ try {
+ const accessRequests = await db(TableName.AccessApprovalRequest)
+ .leftJoin(
+ TableName.AccessApprovalPolicy,
+ `${TableName.AccessApprovalRequest}.policyId`,
+ `${TableName.AccessApprovalPolicy}.id`
+ )
+ .leftJoin(TableName.Environment, `${TableName.AccessApprovalPolicy}.envId`, `${TableName.Environment}.id`)
+ .leftJoin(
+ TableName.ProjectUserAdditionalPrivilege,
+ `${TableName.AccessApprovalRequest}.privilegeId`,
+ `${TableName.ProjectUserAdditionalPrivilege}.id`
+ )
+
+ .leftJoin(
+ TableName.AccessApprovalRequestReviewer,
+ `${TableName.AccessApprovalRequest}.id`,
+ `${TableName.AccessApprovalRequestReviewer}.requestId`
+ )
+
+ .where(`${TableName.Environment}.projectId`, projectId)
+ .select(selectAllTableCols(TableName.AccessApprovalRequest))
+ .select(db.ref("status").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerStatus"))
+ .select(db.ref("member").withSchema(TableName.AccessApprovalRequestReviewer).as("reviewerMemberId"));
+
+ const formattedRequests = sqlNestRelationships({
+ data: accessRequests,
+ key: "id",
+ parentMapper: (doc) => ({
+ ...AccessApprovalRequestsSchema.parse(doc)
+ }),
+ childrenMapper: [
+ {
+ key: "reviewerMemberId",
+ label: "reviewers" as const,
+ mapper: ({ reviewerMemberId: member, reviewerStatus: status }) => (member ? { member, status } : undefined)
+ }
+ ]
+ });
+
+ // an approval is pending if there is no reviewer rejections and no privilege ID is set
+ const pendingApprovals = formattedRequests.filter(
+ (req) => !req.privilegeId && !req.reviewers.some((r) => r.status === ApprovalStatus.REJECTED)
+ );
+
+ // an approval is finalized if there are any rejections or a privilege ID is set
+ const finalizedApprovals = formattedRequests.filter(
+ (req) => req.privilegeId || req.reviewers.some((r) => r.status === ApprovalStatus.REJECTED)
+ );
+
+ return { pendingCount: pendingApprovals.length, finalizedCount: finalizedApprovals.length };
+ } catch (error) {
+ throw new DatabaseError({ error, name: "GetCountAccessApprovalRequest" });
+ }
+ };
+
+ return { ...accessApprovalRequestOrm, findById, findRequestsWithPrivilegeByPolicyIds, getCount };
+};
diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-fns.ts b/backend/src/ee/services/access-approval-request/access-approval-request-fns.ts
new file mode 100644
index 0000000000..90b42aaf7a
--- /dev/null
+++ b/backend/src/ee/services/access-approval-request/access-approval-request-fns.ts
@@ -0,0 +1,53 @@
+import { PackRule, unpackRules } from "@casl/ability/extra";
+
+import { UnauthorizedError } from "@app/lib/errors";
+
+import { TVerifyPermission } from "./access-approval-request-types";
+
+function filterUnique(value: string, index: number, array: string[]) {
+ return array.indexOf(value) === index;
+}
+
+export const verifyRequestedPermissions = ({ permissions }: TVerifyPermission) => {
+ const permission = unpackRules(
+ permissions as PackRule<{
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ conditions?: Record;
+ action: string;
+ subject: [string];
+ }>[]
+ );
+
+ if (!permission || !permission.length) {
+ throw new UnauthorizedError({ message: "No permission provided" });
+ }
+
+ const requestedPermissions: string[] = [];
+
+ for (const p of permission) {
+ if (p.action[0] === "read") requestedPermissions.push("Read Access");
+ if (p.action[0] === "create") requestedPermissions.push("Create Access");
+ if (p.action[0] === "delete") requestedPermissions.push("Delete Access");
+ if (p.action[0] === "edit") requestedPermissions.push("Edit Access");
+ }
+
+ const firstPermission = permission[0];
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
+ const permissionSecretPath = firstPermission.conditions?.secretPath?.$glob;
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-unsafe-assignment
+ const permissionEnv = firstPermission.conditions?.environment;
+
+ if (!permissionEnv || typeof permissionEnv !== "string") {
+ throw new UnauthorizedError({ message: "Permission environment is not a string" });
+ }
+ if (!permissionSecretPath || typeof permissionSecretPath !== "string") {
+ throw new UnauthorizedError({ message: "Permission path is not a string" });
+ }
+
+ return {
+ envSlug: permissionEnv,
+ secretPath: permissionSecretPath,
+ accessTypes: requestedPermissions.filter(filterUnique)
+ };
+};
diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-reviewer-dal.ts b/backend/src/ee/services/access-approval-request/access-approval-request-reviewer-dal.ts
new file mode 100644
index 0000000000..251015b22e
--- /dev/null
+++ b/backend/src/ee/services/access-approval-request/access-approval-request-reviewer-dal.ts
@@ -0,0 +1,10 @@
+import { TDbClient } from "@app/db";
+import { TableName } from "@app/db/schemas";
+import { ormify } from "@app/lib/knex";
+
+export type TAccessApprovalRequestReviewerDALFactory = ReturnType;
+
+export const accessApprovalRequestReviewerDALFactory = (db: TDbClient) => {
+ const secretApprovalRequestReviewerOrm = ormify(db, TableName.AccessApprovalRequestReviewer);
+ return secretApprovalRequestReviewerOrm;
+};
diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-service.ts b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts
new file mode 100644
index 0000000000..becdb78daf
--- /dev/null
+++ b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts
@@ -0,0 +1,369 @@
+import slugify from "@sindresorhus/slugify";
+import ms from "ms";
+
+import { ProjectMembershipRole } from "@app/db/schemas";
+import { getConfig } from "@app/lib/config/env";
+import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
+import { alphaNumericNanoId } from "@app/lib/nanoid";
+import { TProjectDALFactory } from "@app/services/project/project-dal";
+import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";
+import { TProjectMembershipDALFactory } from "@app/services/project-membership/project-membership-dal";
+import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service";
+import { TUserDALFactory } from "@app/services/user/user-dal";
+
+import { TAccessApprovalPolicyApproverDALFactory } from "../access-approval-policy/access-approval-policy-approver-dal";
+import { TAccessApprovalPolicyDALFactory } from "../access-approval-policy/access-approval-policy-dal";
+import { verifyApprovers } from "../access-approval-policy/access-approval-policy-fns";
+import { TPermissionServiceFactory } from "../permission/permission-service";
+import { TProjectUserAdditionalPrivilegeDALFactory } from "../project-user-additional-privilege/project-user-additional-privilege-dal";
+import { ProjectUserAdditionalPrivilegeTemporaryMode } from "../project-user-additional-privilege/project-user-additional-privilege-types";
+import { TAccessApprovalRequestDALFactory } from "./access-approval-request-dal";
+import { verifyRequestedPermissions } from "./access-approval-request-fns";
+import { TAccessApprovalRequestReviewerDALFactory } from "./access-approval-request-reviewer-dal";
+import {
+ ApprovalStatus,
+ TCreateAccessApprovalRequestDTO,
+ TGetAccessRequestCountDTO,
+ TListApprovalRequestsDTO,
+ TReviewAccessRequestDTO
+} from "./access-approval-request-types";
+
+type TSecretApprovalRequestServiceFactoryDep = {
+ additionalPrivilegeDAL: Pick;
+ permissionService: Pick;
+ accessApprovalPolicyApproverDAL: Pick;
+ projectEnvDAL: Pick;
+ projectDAL: Pick;
+ accessApprovalRequestDAL: Pick<
+ TAccessApprovalRequestDALFactory,
+ | "create"
+ | "find"
+ | "findRequestsWithPrivilegeByPolicyIds"
+ | "findById"
+ | "transaction"
+ | "updateById"
+ | "findOne"
+ | "getCount"
+ >;
+ accessApprovalPolicyDAL: Pick;
+ accessApprovalRequestReviewerDAL: Pick<
+ TAccessApprovalRequestReviewerDALFactory,
+ "create" | "find" | "findOne" | "transaction"
+ >;
+ projectMembershipDAL: Pick;
+ smtpService: Pick;
+ userDAL: Pick;
+};
+
+export type TAccessApprovalRequestServiceFactory = ReturnType;
+
+export const accessApprovalRequestServiceFactory = ({
+ projectDAL,
+ projectEnvDAL,
+ permissionService,
+ accessApprovalRequestDAL,
+ accessApprovalRequestReviewerDAL,
+ projectMembershipDAL,
+ accessApprovalPolicyDAL,
+ accessApprovalPolicyApproverDAL,
+ additionalPrivilegeDAL,
+ smtpService,
+ userDAL
+}: TSecretApprovalRequestServiceFactoryDep) => {
+ const createAccessApprovalRequest = async ({
+ isTemporary,
+ temporaryRange,
+ actorId,
+ permissions: requestedPermissions,
+ actor,
+ actorOrgId,
+ actorAuthMethod,
+ projectSlug
+ }: TCreateAccessApprovalRequestDTO) => {
+ const cfg = getConfig();
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+ if (!project) throw new UnauthorizedError({ message: "Project not found" });
+
+ // Anyone can create an access approval request.
+ const { membership } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ if (!membership) throw new UnauthorizedError({ message: "You are not a member of this project" });
+
+ const requestedByUser = await userDAL.findUserByProjectMembershipId(membership.id);
+ if (!requestedByUser) throw new UnauthorizedError({ message: "User not found" });
+
+ await projectDAL.checkProjectUpgradeStatus(project.id);
+
+ const { envSlug, secretPath, accessTypes } = verifyRequestedPermissions({ permissions: requestedPermissions });
+ const environment = await projectEnvDAL.findOne({ projectId: project.id, slug: envSlug });
+
+ if (!environment) throw new UnauthorizedError({ message: "Environment not found" });
+
+ const policy = await accessApprovalPolicyDAL.findOne({
+ envId: environment.id,
+ secretPath
+ });
+ if (!policy) throw new UnauthorizedError({ message: "No policy matching criteria was found." });
+
+ const approvers = await accessApprovalPolicyApproverDAL.find({
+ policyId: policy.id
+ });
+
+ const approverUsers = await userDAL.findUsersByProjectMembershipIds(
+ approvers.map((approver) => approver.approverId)
+ );
+
+ const duplicateRequests = await accessApprovalRequestDAL.find({
+ policyId: policy.id,
+ requestedBy: membership.id,
+ permissions: JSON.stringify(requestedPermissions),
+ isTemporary
+ });
+
+ if (duplicateRequests?.length > 0) {
+ for await (const duplicateRequest of duplicateRequests) {
+ if (duplicateRequest.privilegeId) {
+ const privilege = await additionalPrivilegeDAL.findById(duplicateRequest.privilegeId);
+
+ const isExpired = new Date() > new Date(privilege.temporaryAccessEndTime || ("" as string));
+
+ if (!isExpired || !privilege.isTemporary) {
+ throw new BadRequestError({ message: "You already have an active privilege with the same criteria" });
+ }
+ } else {
+ const reviewers = await accessApprovalRequestReviewerDAL.find({
+ requestId: duplicateRequest.id
+ });
+
+ const isRejected = reviewers.some((reviewer) => reviewer.status === ApprovalStatus.REJECTED);
+
+ if (!isRejected) {
+ throw new BadRequestError({ message: "You already have a pending access request with the same criteria" });
+ }
+ }
+ }
+ }
+
+ const approval = await accessApprovalRequestDAL.transaction(async (tx) => {
+ const approvalRequest = await accessApprovalRequestDAL.create(
+ {
+ policyId: policy.id,
+ requestedBy: membership.id,
+ temporaryRange: temporaryRange || null,
+ permissions: JSON.stringify(requestedPermissions),
+ isTemporary
+ },
+ tx
+ );
+
+ await smtpService.sendMail({
+ recipients: approverUsers.filter((approver) => approver.email).map((approver) => approver.email!),
+ subjectLine: "Access Approval Request",
+
+ substitutions: {
+ projectName: project.name,
+ requesterFullName: `${requestedByUser.firstName} ${requestedByUser.lastName}`,
+ requesterEmail: requestedByUser.email,
+ isTemporary,
+ ...(isTemporary && {
+ expiresIn: ms(ms(temporaryRange || ""), { long: true })
+ }),
+ secretPath,
+ environment: envSlug,
+ permissions: accessTypes,
+ approvalUrl: `${cfg.SITE_URL}/project/${project.id}/approval`
+ },
+ template: SmtpTemplates.AccessApprovalRequest
+ });
+
+ return approvalRequest;
+ });
+
+ return { request: approval };
+ };
+
+ const listApprovalRequests = async ({
+ projectSlug,
+ authorProjectMembershipId,
+ envSlug,
+ actor,
+ actorOrgId,
+ actorId,
+ actorAuthMethod
+ }: TListApprovalRequestsDTO) => {
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+ if (!project) throw new UnauthorizedError({ message: "Project not found" });
+
+ const { membership } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ if (!membership) throw new UnauthorizedError({ message: "You are not a member of this project" });
+
+ const policies = await accessApprovalPolicyDAL.find({ projectId: project.id });
+ let requests = await accessApprovalRequestDAL.findRequestsWithPrivilegeByPolicyIds(policies.map((p) => p.id));
+
+ if (authorProjectMembershipId) {
+ requests = requests.filter((request) => request.requestedBy === authorProjectMembershipId);
+ }
+
+ if (envSlug) {
+ requests = requests.filter((request) => request.environment === envSlug);
+ }
+
+ return { requests };
+ };
+
+ const reviewAccessRequest = async ({
+ requestId,
+ actor,
+ status,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TReviewAccessRequestDTO) => {
+ const accessApprovalRequest = await accessApprovalRequestDAL.findById(requestId);
+ if (!accessApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
+
+ const { policy } = accessApprovalRequest;
+ const { membership, hasRole } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ accessApprovalRequest.projectId,
+ actorAuthMethod,
+ actorOrgId
+ );
+
+ if (!membership) throw new UnauthorizedError({ message: "You are not a member of this project" });
+
+ if (
+ !hasRole(ProjectMembershipRole.Admin) &&
+ accessApprovalRequest.requestedBy !== membership.id && // The request wasn't made by the current user
+ !policy.approvers.find((approverId) => approverId === membership.id) // The request isn't performed by an assigned approver
+ ) {
+ throw new UnauthorizedError({ message: "You are not authorized to approve this request" });
+ }
+
+ const reviewerProjectMembership = await projectMembershipDAL.findById(membership.id);
+
+ await verifyApprovers({
+ projectId: accessApprovalRequest.projectId,
+ orgId: actorOrgId,
+ envSlug: accessApprovalRequest.environment,
+ secretPath: accessApprovalRequest.policy.secretPath!,
+ actorAuthMethod,
+ permissionService,
+ userIds: [reviewerProjectMembership.userId]
+ });
+
+ const existingReviews = await accessApprovalRequestReviewerDAL.find({ requestId: accessApprovalRequest.id });
+ if (existingReviews.some((review) => review.status === ApprovalStatus.REJECTED)) {
+ throw new BadRequestError({ message: "The request has already been rejected by another reviewer" });
+ }
+
+ const reviewStatus = await accessApprovalRequestReviewerDAL.transaction(async (tx) => {
+ const review = await accessApprovalRequestReviewerDAL.findOne(
+ {
+ requestId: accessApprovalRequest.id,
+ member: membership.id
+ },
+ tx
+ );
+ if (!review) {
+ const newReview = await accessApprovalRequestReviewerDAL.create(
+ {
+ status,
+ requestId: accessApprovalRequest.id,
+ member: membership.id
+ },
+ tx
+ );
+
+ const allReviews = [...existingReviews, newReview];
+
+ const approvedReviews = allReviews.filter((r) => r.status === ApprovalStatus.APPROVED);
+
+ // approvals is the required number of approvals. If the number of approved reviews is equal to the number of required approvals, then the request is approved.
+ if (approvedReviews.length === policy.approvals) {
+ if (accessApprovalRequest.isTemporary && !accessApprovalRequest.temporaryRange) {
+ throw new BadRequestError({ message: "Temporary range is required for temporary access" });
+ }
+
+ let privilegeId: string | null = null;
+
+ if (!accessApprovalRequest.isTemporary && !accessApprovalRequest.temporaryRange) {
+ // Permanent access
+ const privilege = await additionalPrivilegeDAL.create(
+ {
+ projectMembershipId: accessApprovalRequest.requestedBy,
+ slug: `requested-privilege-${slugify(alphaNumericNanoId(12))}`,
+ permissions: JSON.stringify(accessApprovalRequest.permissions)
+ },
+ tx
+ );
+ privilegeId = privilege.id;
+ } else {
+ // Temporary access
+ const relativeTempAllocatedTimeInMs = ms(accessApprovalRequest.temporaryRange!);
+ const startTime = new Date();
+
+ const privilege = await additionalPrivilegeDAL.create(
+ {
+ projectMembershipId: accessApprovalRequest.requestedBy,
+ slug: `requested-privilege-${slugify(alphaNumericNanoId(12))}`,
+ permissions: JSON.stringify(accessApprovalRequest.permissions),
+ isTemporary: true,
+ temporaryMode: ProjectUserAdditionalPrivilegeTemporaryMode.Relative,
+ temporaryRange: accessApprovalRequest.temporaryRange!,
+ temporaryAccessStartTime: startTime,
+ temporaryAccessEndTime: new Date(new Date(startTime).getTime() + relativeTempAllocatedTimeInMs)
+ },
+ tx
+ );
+ privilegeId = privilege.id;
+ }
+
+ await accessApprovalRequestDAL.updateById(accessApprovalRequest.id, { privilegeId }, tx);
+ }
+
+ return newReview;
+ }
+ throw new BadRequestError({ message: "You have already reviewed this request" });
+ });
+
+ return reviewStatus;
+ };
+
+ const getCount = async ({ projectSlug, actor, actorAuthMethod, actorId, actorOrgId }: TGetAccessRequestCountDTO) => {
+ const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
+ if (!project) throw new UnauthorizedError({ message: "Project not found" });
+
+ const { membership } = await permissionService.getProjectPermission(
+ actor,
+ actorId,
+ project.id,
+ actorAuthMethod,
+ actorOrgId
+ );
+ if (!membership) throw new BadRequestError({ message: "User not found in project" });
+
+ const count = await accessApprovalRequestDAL.getCount({ projectId: project.id });
+
+ return { count };
+ };
+
+ return {
+ createAccessApprovalRequest,
+ listApprovalRequests,
+ reviewAccessRequest,
+ getCount
+ };
+};
diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-types.ts b/backend/src/ee/services/access-approval-request/access-approval-request-types.ts
new file mode 100644
index 0000000000..e11ca58d53
--- /dev/null
+++ b/backend/src/ee/services/access-approval-request/access-approval-request-types.ts
@@ -0,0 +1,33 @@
+import { TProjectPermission } from "@app/lib/types";
+
+export enum ApprovalStatus {
+ PENDING = "pending",
+ APPROVED = "approved",
+ REJECTED = "rejected"
+}
+
+export type TVerifyPermission = {
+ permissions: unknown;
+};
+
+export type TGetAccessRequestCountDTO = {
+ projectSlug: string;
+} & Omit;
+
+export type TReviewAccessRequestDTO = {
+ requestId: string;
+ status: ApprovalStatus;
+} & Omit;
+
+export type TCreateAccessApprovalRequestDTO = {
+ projectSlug: string;
+ permissions: unknown;
+ isTemporary: boolean;
+ temporaryRange?: string;
+} & Omit;
+
+export type TListApprovalRequestsDTO = {
+ projectSlug: string;
+ authorProjectMembershipId?: string;
+ envSlug?: string;
+} & Omit;
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 196eab9ef7..aba6e73290 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -70,6 +70,10 @@ export enum EventType {
ADD_IDENTITY_GCP_IAM_AUTH = "add-identity-gcp-iam -auth",
UPDATE_IDENTITY_GCP_IAM_AUTH = "update-identity-gcp-iam-auth",
GET_IDENTITY_GCP_IAM_AUTH = "get-identity-gcp-iam-auth",
+ LOGIN_IDENTITY_AWS_IAM_AUTH = "login-identity-aws-iam-auth",
+ ADD_IDENTITY_AWS_IAM_AUTH = "add-identity-aws-iam-auth",
+ UPDATE_IDENTITY_AWS_IAM_AUTH = "update-identity-aws-iam-auth",
+ GET_IDENTITY_AWS_IAM_AUTH = "get-identity-aws-iam-auth",
CREATE_ENVIRONMENT = "create-environment",
UPDATE_ENVIRONMENT = "update-environment",
DELETE_ENVIRONMENT = "delete-environment",
@@ -452,6 +456,50 @@ interface GetIdentityGcpIamAuthEvent {
};
}
+interface LoginIdentityAwsIamAuthEvent {
+ type: EventType.LOGIN_IDENTITY_AWS_IAM_AUTH;
+ metadata: {
+ identityId: string;
+ identityAwsIamAuthId: string;
+ identityAccessTokenId: string;
+ };
+}
+
+interface AddIdentityAwsIamAuthEvent {
+ type: EventType.ADD_IDENTITY_AWS_IAM_AUTH;
+ metadata: {
+ identityId: string;
+ stsEndpoint: string;
+ allowedPrincipalArns: string;
+ allowedAccountIds: string;
+ accessTokenTTL: number;
+ accessTokenMaxTTL: number;
+ accessTokenNumUsesLimit: number;
+ accessTokenTrustedIps: Array;
+ };
+}
+
+interface UpdateIdentityAwsIamAuthEvent {
+ type: EventType.UPDATE_IDENTITY_AWS_IAM_AUTH;
+ metadata: {
+ identityId: string;
+ stsEndpoint?: string;
+ allowedPrincipalArns?: string;
+ allowedAccountIds?: string;
+ accessTokenTTL?: number;
+ accessTokenMaxTTL?: number;
+ accessTokenNumUsesLimit?: number;
+ accessTokenTrustedIps?: Array;
+ };
+}
+
+interface GetIdentityAwsIamAuthEvent {
+ type: EventType.GET_IDENTITY_AWS_IAM_AUTH;
+ metadata: {
+ identityId: string;
+ };
+}
+
interface CreateEnvironmentEvent {
type: EventType.CREATE_ENVIRONMENT;
metadata: {
@@ -710,6 +758,10 @@ export type Event =
| AddIdentityGcpIamAuthEvent
| UpdateIdentityGcpIamAuthEvent
| GetIdentityGcpIamAuthEvent
+ | LoginIdentityAwsIamAuthEvent
+ | AddIdentityAwsIamAuthEvent
+ | UpdateIdentityAwsIamAuthEvent
+ | GetIdentityAwsIamAuthEvent
| CreateEnvironmentEvent
| UpdateEnvironmentEvent
| DeleteEnvironmentEvent
diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.ts
index e81f6dc12e..47b46d0100 100644
--- a/backend/src/ee/services/license/license-service.ts
+++ b/backend/src/ee/services/license/license-service.ts
@@ -121,8 +121,8 @@ export const licenseServiceFactory = ({
if (isValidOfflineLicense) {
onPremFeatures = contents.license.features;
- instanceType = InstanceType.EnterpriseOnPrem;
- logger.info(`Instance type: ${InstanceType.EnterpriseOnPrem}`);
+ instanceType = InstanceType.EnterpriseOnPremOffline;
+ logger.info(`Instance type: ${InstanceType.EnterpriseOnPremOffline}`);
isValidLicense = true;
return;
}
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index a2379ddaa5..0c8fdc197f 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -3,6 +3,7 @@ import { TOrgPermission } from "@app/lib/types";
export enum InstanceType {
OnPrem = "self-hosted",
EnterpriseOnPrem = "enterprise-self-hosted",
+ EnterpriseOnPremOffline = "enterprise-self-hosted-offline",
Cloud = "cloud"
}
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 10006b9efb..3363854726 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -92,6 +92,18 @@ export const UNIVERSAL_AUTH = {
}
} as const;
+export const AWS_IAM_AUTH = {
+ LOGIN: {
+ identityId: "The ID of the identity to login.",
+ iamHttpRequestMethod: "The HTTP request method used in the signed request.",
+ iamRequestUrl:
+ "The base64-encoded HTTP URL used in the signed request. Most likely, the base64-encoding of https://sts.amazonaws.com/",
+ iamRequestBody:
+ "The base64-encoded body of the signed request. Most likely, the base64-encoding of Action=GetCallerIdentity&Version=2011-06-15.",
+ iamRequestHeaders: "The base64-encoded headers of the sts:GetCallerIdentity signed request."
+ }
+} as const;
+
export const ORGANIZATIONS = {
LIST_USER_MEMBERSHIPS: {
organizationId: "The ID of the organization to get memberships from."
@@ -465,7 +477,7 @@ export const SECRET_TAGS = {
export const IDENTITY_ADDITIONAL_PRIVILEGE = {
CREATE: {
projectSlug: "The slug of the project of the identity in.",
- identityId: "The ID of the identity to delete.",
+ identityId: "The ID of the identity to create.",
slug: "The slug of the privilege to create.",
permissions: `The permission object for the privilege.
- Read secrets
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index 4c06837972..d8814dd40c 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -108,6 +108,7 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
if (req.url.includes("/api/v3/auth/")) {
return;
}
+
if (!authMode) return;
switch (authMode) {
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index c64d221299..e2dc116065 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2,6 +2,12 @@ import { Knex } from "knex";
import { z } from "zod";
import { registerV1EERoutes } from "@app/ee/routes/v1";
+import { accessApprovalPolicyApproverDALFactory } from "@app/ee/services/access-approval-policy/access-approval-policy-approver-dal";
+import { accessApprovalPolicyDALFactory } from "@app/ee/services/access-approval-policy/access-approval-policy-dal";
+import { accessApprovalPolicyServiceFactory } from "@app/ee/services/access-approval-policy/access-approval-policy-service";
+import { accessApprovalRequestDALFactory } from "@app/ee/services/access-approval-request/access-approval-request-dal";
+import { accessApprovalRequestReviewerDALFactory } from "@app/ee/services/access-approval-request/access-approval-request-reviewer-dal";
+import { accessApprovalRequestServiceFactory } from "@app/ee/services/access-approval-request/access-approval-request-service";
import { auditLogDALFactory } from "@app/ee/services/audit-log/audit-log-dal";
import { auditLogQueueServiceFactory } from "@app/ee/services/audit-log/audit-log-queue";
import { auditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-service";
@@ -72,6 +78,8 @@ import { identityOrgDALFactory } from "@app/services/identity/identity-org-dal";
import { identityServiceFactory } from "@app/services/identity/identity-service";
import { identityAccessTokenDALFactory } from "@app/services/identity-access-token/identity-access-token-dal";
import { identityAccessTokenServiceFactory } from "@app/services/identity-access-token/identity-access-token-service";
+import { identityAwsIamAuthDALFactory } from "@app/services/identity-aws-iam-auth/identity-aws-iam-auth-dal";
+import { identityAwsIamAuthServiceFactory } from "@app/services/identity-aws-iam-auth/identity-aws-iam-auth-service";
import { identityGcpIamAuthDALFactory } from "@app/services/identity-gcp-iam-auth/identity-gcp-iam-auth-dal";
import { identityGcpIamAuthServiceFactory } from "@app/services/identity-gcp-iam-auth/identity-gcp-iam-auth-service";
import { identityProjectDALFactory } from "@app/services/identity-project/identity-project-dal";
@@ -197,6 +205,7 @@ export const registerRoutes = async (
const identityUaDAL = identityUaDALFactory(db);
const identityUaClientSecretDAL = identityUaClientSecretDALFactory(db);
+ const identityAwsIamAuthDAL = identityAwsIamAuthDALFactory(db);
const identityGcpIamAuthDAL = identityGcpIamAuthDALFactory(db);
@@ -211,6 +220,12 @@ export const registerRoutes = async (
const scimDAL = scimDALFactory(db);
const ldapConfigDAL = ldapConfigDALFactory(db);
const ldapGroupMapDAL = ldapGroupMapDALFactory(db);
+
+ const accessApprovalPolicyDAL = accessApprovalPolicyDALFactory(db);
+ const accessApprovalRequestDAL = accessApprovalRequestDALFactory(db);
+ const accessApprovalPolicyApproverDAL = accessApprovalPolicyApproverDALFactory(db);
+ const accessApprovalRequestReviewerDAL = accessApprovalRequestReviewerDALFactory(db);
+
const sapApproverDAL = secretApprovalPolicyApproverDALFactory(db);
const secretApprovalPolicyDAL = secretApprovalPolicyDALFactory(db);
const secretApprovalRequestDAL = secretApprovalRequestDALFactory(db);
@@ -269,6 +284,7 @@ export const registerRoutes = async (
secretApprovalPolicyDAL
});
const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL });
+
const samlService = samlConfigServiceFactory({
permissionService,
orgBotDAL,
@@ -600,6 +616,30 @@ export const registerRoutes = async (
secretVersionTagDAL,
secretQueueService
});
+
+ const accessApprovalPolicyService = accessApprovalPolicyServiceFactory({
+ accessApprovalPolicyDAL,
+ accessApprovalPolicyApproverDAL,
+ permissionService,
+ projectEnvDAL,
+ projectMembershipDAL,
+ projectDAL
+ });
+
+ const accessApprovalRequestService = accessApprovalRequestServiceFactory({
+ projectDAL,
+ permissionService,
+ accessApprovalRequestReviewerDAL,
+ additionalPrivilegeDAL: projectUserAdditionalPrivilegeDAL,
+ projectMembershipDAL,
+ accessApprovalPolicyDAL,
+ accessApprovalRequestDAL,
+ projectEnvDAL,
+ userDAL,
+ smtpService,
+ accessApprovalPolicyApproverDAL
+ });
+
const secretRotationQueue = secretRotationQueueFactory({
telemetryService,
secretRotationDAL,
@@ -675,6 +715,15 @@ export const registerRoutes = async (
licenseService
});
+ const identityAWSIAMAuthService = identityAwsIamAuthServiceFactory({
+ identityAccessTokenDAL,
+ identityAwsIamAuthDAL,
+ identityOrgMembershipDAL,
+ identityDAL,
+ licenseService,
+ permissionService
+ });
+
const dynamicSecretProviders = buildDynamicSecretProviders();
const dynamicSecretQueueService = dynamicSecretLeaseQueueServiceFactory({
queueService,
@@ -744,7 +793,10 @@ export const registerRoutes = async (
identityProject: identityProjectService,
identityUa: identityUaService,
identityGcpIamAuth: identityGcpIamAuthService,
+ identityAwsIamAuth: identityAWSIAMAuthService,
secretApprovalPolicy: sapService,
+ accessApprovalPolicy: accessApprovalPolicyService,
+ accessApprovalRequest: accessApprovalRequestService,
secretApprovalRequest: sarService,
secretRotation: secretRotationService,
dynamicSecret: dynamicSecretService,
diff --git a/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts b/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts
new file mode 100644
index 0000000000..12003a1588
--- /dev/null
+++ b/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts
@@ -0,0 +1,269 @@
+import { z } from "zod";
+
+import { IdentityAwsIamAuthsSchema } from "@app/db/schemas";
+import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { AWS_IAM_AUTH } from "@app/lib/api-docs";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
+import {
+ validateAccountIds,
+ validatePrincipalArns
+} from "@app/services/identity-aws-iam-auth/identity-aws-iam-auth-validators";
+
+export const registerIdentityAwsIamAuthRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "POST",
+ url: "/aws-iam-auth/login",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ description: "Login with AWS IAM Auth",
+ body: z.object({
+ identityId: z.string().describe(AWS_IAM_AUTH.LOGIN.identityId),
+ iamHttpRequestMethod: z.string().default("POST").describe(AWS_IAM_AUTH.LOGIN.iamHttpRequestMethod),
+ iamRequestBody: z.string().describe(AWS_IAM_AUTH.LOGIN.iamRequestBody),
+ iamRequestHeaders: z.string().describe(AWS_IAM_AUTH.LOGIN.iamRequestHeaders)
+ }),
+ response: {
+ 200: z.object({
+ accessToken: z.string(),
+ expiresIn: z.coerce.number(),
+ accessTokenMaxTTL: z.coerce.number(),
+ tokenType: z.literal("Bearer")
+ })
+ }
+ },
+ handler: async (req) => {
+ const { identityAwsIamAuth, accessToken, identityAccessToken, identityMembershipOrg } =
+ await server.services.identityAwsIamAuth.login(req.body);
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: identityMembershipOrg?.orgId,
+ event: {
+ type: EventType.LOGIN_IDENTITY_AWS_IAM_AUTH,
+ metadata: {
+ identityId: identityAwsIamAuth.identityId,
+ identityAccessTokenId: identityAccessToken.id,
+ identityAwsIamAuthId: identityAwsIamAuth.id
+ }
+ }
+ });
+
+ return {
+ accessToken,
+ tokenType: "Bearer" as const,
+ expiresIn: identityAwsIamAuth.accessTokenTTL,
+ accessTokenMaxTTL: identityAwsIamAuth.accessTokenMaxTTL
+ };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/aws-iam-auth/identities/:identityId",
+ config: {
+ rateLimit: writeLimit
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ schema: {
+ description: "Attach AWS IAM Auth configuration onto identity",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ identityId: z.string().trim()
+ }),
+ body: z.object({
+ stsEndpoint: z.string().trim().min(1).default("https://sts.amazonaws.com/"),
+ allowedPrincipalArns: validatePrincipalArns,
+ allowedAccountIds: validateAccountIds,
+ accessTokenTrustedIps: z
+ .object({
+ ipAddress: z.string().trim()
+ })
+ .array()
+ .min(1)
+ .default([{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]),
+ accessTokenTTL: z
+ .number()
+ .int()
+ .min(1)
+ .refine((value) => value !== 0, {
+ message: "accessTokenTTL must have a non zero number"
+ })
+ .default(2592000),
+ accessTokenMaxTTL: z
+ .number()
+ .int()
+ .refine((value) => value !== 0, {
+ message: "accessTokenMaxTTL must have a non zero number"
+ })
+ .default(2592000),
+ accessTokenNumUsesLimit: z.number().int().min(0).default(0)
+ }),
+ response: {
+ 200: z.object({
+ identityAwsIamAuth: IdentityAwsIamAuthsSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const identityAwsIamAuth = await server.services.identityAwsIamAuth.attachAwsIamAuth({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ ...req.body,
+ identityId: req.params.identityId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: identityAwsIamAuth.orgId,
+ event: {
+ type: EventType.ADD_IDENTITY_AWS_IAM_AUTH,
+ metadata: {
+ identityId: identityAwsIamAuth.identityId,
+ stsEndpoint: identityAwsIamAuth.stsEndpoint,
+ allowedPrincipalArns: identityAwsIamAuth.allowedPrincipalArns,
+ allowedAccountIds: identityAwsIamAuth.allowedAccountIds,
+ accessTokenTTL: identityAwsIamAuth.accessTokenTTL,
+ accessTokenMaxTTL: identityAwsIamAuth.accessTokenMaxTTL,
+ accessTokenTrustedIps: identityAwsIamAuth.accessTokenTrustedIps as TIdentityTrustedIp[],
+ accessTokenNumUsesLimit: identityAwsIamAuth.accessTokenNumUsesLimit
+ }
+ }
+ });
+
+ return { identityAwsIamAuth };
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/aws-iam-auth/identities/:identityId",
+ config: {
+ rateLimit: writeLimit
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ schema: {
+ description: "Update AWS IAM Auth configuration on identity",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ identityId: z.string()
+ }),
+ body: z.object({
+ stsEndpoint: z.string().trim().min(1).optional(),
+ allowedPrincipalArns: validatePrincipalArns,
+ allowedAccountIds: validateAccountIds,
+ accessTokenTrustedIps: z
+ .object({
+ ipAddress: z.string().trim()
+ })
+ .array()
+ .min(1)
+ .optional(),
+ accessTokenTTL: z.number().int().min(0).optional(),
+ accessTokenNumUsesLimit: z.number().int().min(0).optional(),
+ accessTokenMaxTTL: z
+ .number()
+ .int()
+ .refine((value) => value !== 0, {
+ message: "accessTokenMaxTTL must have a non zero number"
+ })
+ .optional()
+ }),
+ response: {
+ 200: z.object({
+ identityAwsIamAuth: IdentityAwsIamAuthsSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const identityAwsIamAuth = await server.services.identityAwsIamAuth.updateAwsIamAuth({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ ...req.body,
+ identityId: req.params.identityId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: identityAwsIamAuth.orgId,
+ event: {
+ type: EventType.UPDATE_IDENTITY_AWS_IAM_AUTH,
+ metadata: {
+ identityId: identityAwsIamAuth.identityId,
+ stsEndpoint: identityAwsIamAuth.stsEndpoint,
+ allowedPrincipalArns: identityAwsIamAuth.allowedPrincipalArns,
+ allowedAccountIds: identityAwsIamAuth.allowedAccountIds,
+ accessTokenTTL: identityAwsIamAuth.accessTokenTTL,
+ accessTokenMaxTTL: identityAwsIamAuth.accessTokenMaxTTL,
+ accessTokenTrustedIps: identityAwsIamAuth.accessTokenTrustedIps as TIdentityTrustedIp[],
+ accessTokenNumUsesLimit: identityAwsIamAuth.accessTokenNumUsesLimit
+ }
+ }
+ });
+
+ return { identityAwsIamAuth };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/aws-iam-auth/identities/:identityId",
+ config: {
+ rateLimit: readLimit
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ schema: {
+ description: "Retrieve AWS IAM Auth configuration on identity",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ identityId: z.string()
+ }),
+ response: {
+ 200: z.object({
+ identityAwsIamAuth: IdentityAwsIamAuthsSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const identityAwsIamAuth = await server.services.identityAwsIamAuth.getAwsIamAuth({
+ identityId: req.params.identityId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: identityAwsIamAuth.orgId,
+ event: {
+ type: EventType.GET_IDENTITY_AWS_IAM_AUTH,
+ metadata: {
+ identityId: identityAwsIamAuth.identityId
+ }
+ }
+ });
+ return { identityAwsIamAuth };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/index.ts b/backend/src/server/routes/v1/index.ts
index 3d0ac6b1e7..74bad1bdd0 100644
--- a/backend/src/server/routes/v1/index.ts
+++ b/backend/src/server/routes/v1/index.ts
@@ -2,6 +2,7 @@ import { registerAdminRouter } from "./admin-router";
import { registerAuthRoutes } from "./auth-router";
import { registerProjectBotRouter } from "./bot-router";
import { registerIdentityAccessTokenRouter } from "./identity-access-token-router";
+import { registerIdentityAwsIamAuthRouter } from "./identity-aws-iam-auth-router";
import { registerIdentityGcpIamAuthRouter } from "./identity-gcp-iam-auth-router";
import { registerIdentityRouter } from "./identity-router";
import { registerIdentityUaRouter } from "./identity-ua";
@@ -29,6 +30,7 @@ export const registerV1Routes = async (server: FastifyZodProvider) => {
await authRouter.register(registerAuthRoutes);
await authRouter.register(registerIdentityUaRouter);
await authRouter.register(registerIdentityGcpIamAuthRouter);
+ await authRouter.register(registerIdentityAwsIamAuthRouter);
await authRouter.register(registerIdentityAccessTokenRouter);
},
{ prefix: "/auth" }
diff --git a/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-dal.ts b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-dal.ts
new file mode 100644
index 0000000000..584ac775fb
--- /dev/null
+++ b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-dal.ts
@@ -0,0 +1,11 @@
+import { TDbClient } from "@app/db";
+import { TableName } from "@app/db/schemas";
+import { ormify } from "@app/lib/knex";
+
+export type TIdentityAwsIamAuthDALFactory = ReturnType;
+
+export const identityAwsIamAuthDALFactory = (db: TDbClient) => {
+ const awsIamAuthOrm = ormify(db, TableName.IdentityAwsIamAuth);
+
+ return awsIamAuthOrm;
+};
diff --git a/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-fns.ts b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-fns.ts
new file mode 100644
index 0000000000..517e9f6131
--- /dev/null
+++ b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-fns.ts
@@ -0,0 +1,67 @@
+/**
+ * Extracts the identity ARN from the GetCallerIdentity response to one of the following formats:
+ * - arn:aws:iam::123456789012:user/MyUserName
+ * - arn:aws:iam::123456789012:role/MyRoleName
+ */
+export const extractPrincipalArn = (arn: string) => {
+ // split the ARN into parts using ":" as the delimiter
+ const fullParts = arn.split(":");
+ if (fullParts.length !== 6) {
+ throw new Error(`Unrecognized ARN: contains ${fullParts.length} colon-separated parts, expected 6`);
+ }
+ const [prefix, partition, service, , accountNumber, resource] = fullParts;
+ if (prefix !== "arn") {
+ throw new Error('Unrecognized ARN: does not begin with "arn:"');
+ }
+
+ // structure to hold the parsed data
+ const entity = {
+ Partition: partition,
+ Service: service,
+ AccountNumber: accountNumber,
+ Type: "",
+ Path: "",
+ FriendlyName: "",
+ SessionInfo: ""
+ };
+
+ // validate the service is either 'iam' or 'sts'
+ if (entity.Service !== "iam" && entity.Service !== "sts") {
+ throw new Error(`Unrecognized service: ${entity.Service}, not one of iam or sts`);
+ }
+
+ // parse the last part of the ARN which describes the resource
+ const parts = resource.split("/");
+ if (parts.length < 2) {
+ throw new Error(`Unrecognized ARN: "${resource}" contains fewer than 2 slash-separated parts`);
+ }
+
+ const [type, ...rest] = parts;
+ entity.Type = type;
+ entity.FriendlyName = parts[parts.length - 1];
+
+ // handle different types of resources
+ switch (entity.Type) {
+ case "assumed-role": {
+ if (rest.length < 2) {
+ throw new Error(`Unrecognized ARN: "${resource}" contains fewer than 3 slash-separated parts`);
+ }
+ // assumed roles use a special format where the friendly name is the role name
+ const [roleName, sessionId] = rest;
+ entity.Type = "role"; // treat assumed role case as role
+ entity.FriendlyName = roleName;
+ entity.SessionInfo = sessionId;
+ break;
+ }
+ case "user":
+ case "role":
+ case "instance-profile":
+ // standard cases: just join back the path if there's any
+ entity.Path = rest.slice(0, -1).join("/");
+ break;
+ default:
+ throw new Error(`Unrecognized principal type: "${entity.Type}"`);
+ }
+
+ return `arn:aws:iam::${entity.AccountNumber}:${entity.Type}/${entity.FriendlyName}`;
+};
diff --git a/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-service.ts b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-service.ts
new file mode 100644
index 0000000000..95deba2d8c
--- /dev/null
+++ b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-service.ts
@@ -0,0 +1,315 @@
+/* eslint-disable @typescript-eslint/no-unsafe-assignment */
+import { ForbiddenError } from "@casl/ability";
+import axios from "axios";
+import jwt from "jsonwebtoken";
+
+import { IdentityAuthMethod } from "@app/db/schemas";
+import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
+import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
+import { getConfig } from "@app/lib/config/env";
+import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
+import { extractIPDetails, isValidIpOrCidr } from "@app/lib/ip";
+
+import { AuthTokenType } from "../auth/auth-type";
+import { TIdentityDALFactory } from "../identity/identity-dal";
+import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";
+import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";
+import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";
+import { TIdentityAwsIamAuthDALFactory } from "./identity-aws-iam-auth-dal";
+import { extractPrincipalArn } from "./identity-aws-iam-auth-fns";
+import {
+ TAttachAWSIAMAuthDTO,
+ TAWSGetCallerIdentityHeaders,
+ TGetAWSIAMAuthDTO,
+ TGetCallerIdentityResponse,
+ TLoginAWSIAMAuthDTO,
+ TUpdateAWSIAMAuthDTO
+} from "./identity-aws-iam-auth-types";
+
+type TIdentityAwsIamAuthServiceFactoryDep = {
+ identityAccessTokenDAL: Pick;
+ identityAwsIamAuthDAL: Pick;
+ identityOrgMembershipDAL: Pick;
+ identityDAL: Pick;
+ licenseService: Pick;
+ permissionService: Pick;
+};
+
+export type TIdentityAwsIamAuthServiceFactory = ReturnType;
+
+export const identityAwsIamAuthServiceFactory = ({
+ identityAccessTokenDAL,
+ identityAwsIamAuthDAL,
+ identityOrgMembershipDAL,
+ identityDAL,
+ licenseService,
+ permissionService
+}: TIdentityAwsIamAuthServiceFactoryDep) => {
+ const login = async ({
+ identityId,
+ iamHttpRequestMethod,
+ iamRequestBody,
+ iamRequestHeaders
+ }: TLoginAWSIAMAuthDTO) => {
+ const identityAwsIamAuth = await identityAwsIamAuthDAL.findOne({ identityId });
+ if (!identityAwsIamAuth) throw new UnauthorizedError();
+
+ const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId: identityAwsIamAuth.identityId });
+
+ const headers: TAWSGetCallerIdentityHeaders = JSON.parse(Buffer.from(iamRequestHeaders, "base64").toString());
+ const body: string = Buffer.from(iamRequestBody, "base64").toString();
+
+ const {
+ data: {
+ GetCallerIdentityResponse: {
+ GetCallerIdentityResult: { Account, Arn }
+ }
+ }
+ }: { data: TGetCallerIdentityResponse } = await axios({
+ method: iamHttpRequestMethod,
+ url: identityAwsIamAuth.stsEndpoint,
+ headers,
+ data: body
+ });
+
+ if (identityAwsIamAuth.allowedAccountIds) {
+ // validate if Account is in the list of allowed Account IDs
+
+ const isAccountAllowed = identityAwsIamAuth.allowedAccountIds
+ .split(",")
+ .map((accountId) => accountId.trim())
+ .some((accountId) => accountId === Account);
+
+ if (!isAccountAllowed) throw new UnauthorizedError();
+ }
+
+ if (identityAwsIamAuth.allowedPrincipalArns) {
+ // validate if Arn is in the list of allowed Principal ARNs
+
+ const isArnAllowed = identityAwsIamAuth.allowedPrincipalArns
+ .split(",")
+ .map((principalArn) => principalArn.trim())
+ .some((principalArn) => {
+ // convert wildcard ARN to a regular expression: "arn:aws:iam::123456789012:*" -> "^arn:aws:iam::123456789012:.*$"
+ // considers exact matches + wildcard matches
+ const regex = new RegExp(`^${principalArn.replace(/\*/g, ".*")}$`);
+ return regex.test(extractPrincipalArn(Arn));
+ });
+
+ if (!isArnAllowed) throw new UnauthorizedError();
+ }
+
+ const identityAccessToken = await identityAwsIamAuthDAL.transaction(async (tx) => {
+ const newToken = await identityAccessTokenDAL.create(
+ {
+ identityId: identityAwsIamAuth.identityId,
+ isAccessTokenRevoked: false,
+ accessTokenTTL: identityAwsIamAuth.accessTokenTTL,
+ accessTokenMaxTTL: identityAwsIamAuth.accessTokenMaxTTL,
+ accessTokenNumUses: 0,
+ accessTokenNumUsesLimit: identityAwsIamAuth.accessTokenNumUsesLimit
+ },
+ tx
+ );
+ return newToken;
+ });
+
+ const appCfg = getConfig();
+ const accessToken = jwt.sign(
+ {
+ identityId: identityAwsIamAuth.identityId,
+ identityAccessTokenId: identityAccessToken.id,
+ authTokenType: AuthTokenType.IDENTITY_ACCESS_TOKEN
+ } as TIdentityAccessTokenJwtPayload,
+ appCfg.AUTH_SECRET,
+ {
+ expiresIn:
+ Number(identityAccessToken.accessTokenMaxTTL) === 0
+ ? undefined
+ : Number(identityAccessToken.accessTokenMaxTTL)
+ }
+ );
+
+ return { accessToken, identityAwsIamAuth, identityAccessToken, identityMembershipOrg };
+ };
+
+ const attachAwsIamAuth = async ({
+ identityId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps,
+ actorId,
+ actorAuthMethod,
+ actor,
+ actorOrgId
+ }: TAttachAWSIAMAuthDTO) => {
+ const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
+ if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
+ if (identityMembershipOrg.identity.authMethod)
+ throw new BadRequestError({
+ message: "Failed to add AWS IAM Auth to already configured identity"
+ });
+
+ if (accessTokenMaxTTL > 0 && accessTokenTTL > accessTokenMaxTTL) {
+ throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
+ }
+
+ const { permission } = await permissionService.getOrgPermission(
+ actor,
+ actorId,
+ identityMembershipOrg.orgId,
+ actorAuthMethod,
+ actorOrgId
+ );
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
+
+ const plan = await licenseService.getPlan(identityMembershipOrg.orgId);
+ const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {
+ if (
+ !plan.ipAllowlisting &&
+ accessTokenTrustedIp.ipAddress !== "0.0.0.0/0" &&
+ accessTokenTrustedIp.ipAddress !== "::/0"
+ )
+ throw new BadRequestError({
+ message:
+ "Failed to add IP access range to access token due to plan restriction. Upgrade plan to add IP access range."
+ });
+ if (!isValidIpOrCidr(accessTokenTrustedIp.ipAddress))
+ throw new BadRequestError({
+ message: "The IP is not a valid IPv4, IPv6, or CIDR block"
+ });
+ return extractIPDetails(accessTokenTrustedIp.ipAddress);
+ });
+
+ const identityAwsIamAuth = await identityAwsIamAuthDAL.transaction(async (tx) => {
+ const doc = await identityAwsIamAuthDAL.create(
+ {
+ identityId: identityMembershipOrg.identityId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenMaxTTL,
+ accessTokenTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps: JSON.stringify(reformattedAccessTokenTrustedIps)
+ },
+ tx
+ );
+ await identityDAL.updateById(
+ identityMembershipOrg.identityId,
+ {
+ authMethod: IdentityAuthMethod.AWS_IAM_AUTH
+ },
+ tx
+ );
+ return doc;
+ });
+ return { ...identityAwsIamAuth, orgId: identityMembershipOrg.orgId };
+ };
+
+ const updateAwsIamAuth = async ({
+ identityId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps,
+ actorId,
+ actorAuthMethod,
+ actor,
+ actorOrgId
+ }: TUpdateAWSIAMAuthDTO) => {
+ const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
+ if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
+ if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.AWS_IAM_AUTH)
+ throw new BadRequestError({
+ message: "Failed to update AWS IAM Auth"
+ });
+
+ const identityAwsIamAuth = await identityAwsIamAuthDAL.findOne({ identityId });
+
+ if (
+ (accessTokenMaxTTL || identityAwsIamAuth.accessTokenMaxTTL) > 0 &&
+ (accessTokenTTL || identityAwsIamAuth.accessTokenMaxTTL) >
+ (accessTokenMaxTTL || identityAwsIamAuth.accessTokenMaxTTL)
+ ) {
+ throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
+ }
+
+ const { permission } = await permissionService.getOrgPermission(
+ actor,
+ actorId,
+ identityMembershipOrg.orgId,
+ actorAuthMethod,
+ actorOrgId
+ );
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity);
+
+ const plan = await licenseService.getPlan(identityMembershipOrg.orgId);
+ const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
+ if (
+ !plan.ipAllowlisting &&
+ accessTokenTrustedIp.ipAddress !== "0.0.0.0/0" &&
+ accessTokenTrustedIp.ipAddress !== "::/0"
+ )
+ throw new BadRequestError({
+ message:
+ "Failed to add IP access range to access token due to plan restriction. Upgrade plan to add IP access range."
+ });
+ if (!isValidIpOrCidr(accessTokenTrustedIp.ipAddress))
+ throw new BadRequestError({
+ message: "The IP is not a valid IPv4, IPv6, or CIDR block"
+ });
+ return extractIPDetails(accessTokenTrustedIp.ipAddress);
+ });
+
+ const updatedAwsIamAuth = await identityAwsIamAuthDAL.updateById(identityAwsIamAuth.id, {
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenMaxTTL,
+ accessTokenTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps: reformattedAccessTokenTrustedIps
+ ? JSON.stringify(reformattedAccessTokenTrustedIps)
+ : undefined
+ });
+
+ return { ...updatedAwsIamAuth, orgId: identityMembershipOrg.orgId };
+ };
+
+ const getAwsIamAuth = async ({ identityId, actorId, actor, actorAuthMethod, actorOrgId }: TGetAWSIAMAuthDTO) => {
+ const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
+ if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
+ if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.AWS_IAM_AUTH)
+ throw new BadRequestError({
+ message: "The identity does not have AWS IAM Auth attached"
+ });
+
+ const awsIamIdentityAuth = await identityAwsIamAuthDAL.findOne({ identityId });
+
+ const { permission } = await permissionService.getOrgPermission(
+ actor,
+ actorId,
+ identityMembershipOrg.orgId,
+ actorAuthMethod,
+ actorOrgId
+ );
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
+ return { ...awsIamIdentityAuth, orgId: identityMembershipOrg.orgId };
+ };
+
+ return {
+ login,
+ attachAwsIamAuth,
+ updateAwsIamAuth,
+ getAwsIamAuth
+ };
+};
diff --git a/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-types.ts b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-types.ts
new file mode 100644
index 0000000000..19f27f4302
--- /dev/null
+++ b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-types.ts
@@ -0,0 +1,54 @@
+import { TProjectPermission } from "@app/lib/types";
+
+export type TLoginAWSIAMAuthDTO = {
+ identityId: string;
+ iamHttpRequestMethod: string;
+ iamRequestBody: string;
+ iamRequestHeaders: string;
+};
+
+export type TAttachAWSIAMAuthDTO = {
+ identityId: string;
+ stsEndpoint: string;
+ allowedPrincipalArns: string;
+ allowedAccountIds: string;
+ accessTokenTTL: number;
+ accessTokenMaxTTL: number;
+ accessTokenNumUsesLimit: number;
+ accessTokenTrustedIps: { ipAddress: string }[];
+} & Omit;
+
+export type TUpdateAWSIAMAuthDTO = {
+ identityId: string;
+ stsEndpoint?: string;
+ allowedPrincipalArns?: string;
+ allowedAccountIds?: string;
+ accessTokenTTL?: number;
+ accessTokenMaxTTL?: number;
+ accessTokenNumUsesLimit?: number;
+ accessTokenTrustedIps?: { ipAddress: string }[];
+} & Omit;
+
+export type TGetAWSIAMAuthDTO = {
+ identityId: string;
+} & Omit;
+
+export type TAWSGetCallerIdentityHeaders = {
+ "Content-Type": string;
+ Host: string;
+ "X-Amz-Date": string;
+ "Content-Length": number;
+ "x-amz-security-token": string;
+ Authorization: string;
+};
+
+export type TGetCallerIdentityResponse = {
+ GetCallerIdentityResponse: {
+ GetCallerIdentityResult: {
+ Account: string;
+ Arn: string;
+ UserId: string;
+ };
+ ResponseMetadata: { RequestId: string };
+ };
+};
diff --git a/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-validators.ts b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-validators.ts
new file mode 100644
index 0000000000..2cb7b4ea44
--- /dev/null
+++ b/backend/src/services/identity-aws-iam-auth/identity-aws-iam-auth-validators.ts
@@ -0,0 +1,58 @@
+import { z } from "zod";
+
+const twelveDigitRegex = /^\d{12}$/;
+const arnRegex = /^arn:aws:iam::\d{12}:(user\/[\w-]+|role\/[\w-]+|\*)$/;
+
+export const validateAccountIds = z
+ .string()
+ .trim()
+ .default("")
+ // Custom validation to ensure each part is a 12-digit number
+ .refine(
+ (data) => {
+ if (data === "") return true;
+ // Split the string by commas to check each supposed number
+ const accountIds = data.split(",").map((id) => id.trim());
+ // Return true only if every item matches the 12-digit requirement
+ return accountIds.every((id) => twelveDigitRegex.test(id));
+ },
+ {
+ message: "Each account ID must be a 12-digit number."
+ }
+ )
+ // Transform the string to normalize space after commas
+ .transform((data) => {
+ if (data === "") return "";
+ // Trim each ID and join with ', ' to ensure formatting
+ return data
+ .split(",")
+ .map((id) => id.trim())
+ .join(", ");
+ });
+
+export const validatePrincipalArns = z
+ .string()
+ .trim()
+ .default("")
+ // Custom validation for ARN format
+ .refine(
+ (data) => {
+ // Skip validation if the string is empty
+ if (data === "") return true;
+ // Split the string by commas to check each supposed ARN
+ const arns = data.split(",");
+ // Return true only if every item matches one of the allowed ARN formats
+ return arns.every((arn) => arnRegex.test(arn.trim()));
+ },
+ {
+ message:
+ "Each ARN must be in the format of 'arn:aws:iam::123456789012:user/UserName', 'arn:aws:iam::123456789012:role/RoleName', or 'arn:aws:iam::123456789012:*'."
+ }
+ )
+ // Transform to normalize the spaces around commas
+ .transform((data) =>
+ data
+ .split(",")
+ .map((arn) => arn.trim())
+ .join(", ")
+ );
diff --git a/backend/src/services/smtp/smtp-service.ts b/backend/src/services/smtp/smtp-service.ts
index 0b43ffb908..81680537da 100644
--- a/backend/src/services/smtp/smtp-service.ts
+++ b/backend/src/services/smtp/smtp-service.ts
@@ -21,6 +21,7 @@ export enum SmtpTemplates {
EmailVerification = "emailVerification.handlebars",
SecretReminder = "secretReminder.handlebars",
EmailMfa = "emailMfa.handlebars",
+ AccessApprovalRequest = "accessApprovalRequest.handlebars",
HistoricalSecretList = "historicalSecretLeakIncident.handlebars",
NewDeviceJoin = "newDevice.handlebars",
OrgInvite = "organizationInvitation.handlebars",
diff --git a/backend/src/services/smtp/templates/accessApprovalRequest.handlebars b/backend/src/services/smtp/templates/accessApprovalRequest.handlebars
new file mode 100644
index 0000000000..82c66ce5fe
--- /dev/null
+++ b/backend/src/services/smtp/templates/accessApprovalRequest.handlebars
@@ -0,0 +1,50 @@
+
+
+
+
+
+ Access Approval Request
+
+
+
+ Infisical
+ New access approval request pending your review
+ You have a new access approval request pending review in project "{{projectName}}".
+
+
+ {{requesterFullName}}
+ ({{requesterEmail}}) has requested
+ {{#if isTemporary}}
+ temporary
+ {{else}}
+ permanent
+ {{/if}}
+ access to
+ {{secretPath}}
+ in the
+ {{environment}}
+ environment.
+
+ {{#if isTemporary}}
+
+ This access will expire
+ {{expiresIn}}
+ after it has been approved.
+ {{/if}}
+
+
+ The following permissions are requested:
+
+ {{#each permissions}}
+ - {{this}}
+ {{/each}}
+
+
+
+
+ View the request and approve or deny it
+ here.
+
+
+
+
\ No newline at end of file
diff --git a/backend/src/services/user/user-dal.ts b/backend/src/services/user/user-dal.ts
index 530ca3ad1a..f2da0df0e2 100644
--- a/backend/src/services/user/user-dal.ts
+++ b/backend/src/services/user/user-dal.ts
@@ -74,6 +74,17 @@ export const userDALFactory = (db: TDbClient) => {
}
};
+ const findUsersByProjectMembershipIds = async (projectMembershipIds: string[]) => {
+ try {
+ return await db(TableName.ProjectMembership)
+ .whereIn(`${TableName.ProjectMembership}.id`, projectMembershipIds)
+ .join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
+ .select("*");
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Find users by project membership ids" });
+ }
+ };
+
const createUserEncryption = async (data: TUserEncryptionKeysInsert, tx?: Knex) => {
try {
const [userEnc] = await (tx || db)(TableName.UserEncryptionKey).insert(data).returning("*");
@@ -140,6 +151,7 @@ export const userDALFactory = (db: TDbClient) => {
findUserEncKeyByUserId,
updateUserEncryptionByUserId,
findUserByProjectMembershipId,
+ findUsersByProjectMembershipIds,
upsertUserEncryptionKey,
createUserEncryption,
findOneUserAction,
diff --git a/docs/documentation/getting-started/introduction.mdx b/docs/documentation/getting-started/introduction.mdx
index 0f414c62a9..144691ac44 100644
--- a/docs/documentation/getting-started/introduction.mdx
+++ b/docs/documentation/getting-started/introduction.mdx
@@ -4,59 +4,66 @@ sidebarTitle: "What is Infisical?"
description: "An Introduction to the Infisical secret management platform."
---
-Infisical is an [open-source](https://github.com/infisical/infisical) secret management platform for developers.
-It provides capabilities for storing, managing, and syncing application configuration and secrets like API keys, database
-credentials, and certificates across infrastructure. In addition, Infisical prevents secrets leaks to git and enables secure
+Infisical is an [open-source](https://github.com/infisical/infisical) secret management platform for developers.
+It provides capabilities for storing, managing, and syncing application configuration and secrets like API keys, database
+credentials, and certificates across infrastructure. In addition, Infisical prevents secrets leaks to git and enables secure
sharing of secrets among engineers.
Start managing secrets securely with [Infisical Cloud](https://app.infisical.com) or learn how to [host Infisical](/self-hosting/overview) yourself.
-
- Get started with Infisical Cloud in just a few minutes.
-
-
- Self-host Infisical on your own infrastructure.
-
+
+ Get started with Infisical Cloud in just a few minutes.
+
+
+ Self-host Infisical on your own infrastructure.
+
-## Why Infisical?
+## Why Infisical?
+
+Infisical helps developers achieve secure centralized secret management and provides all the tools to easily manage secrets in various environments and infrastructure components. In particular, here are some of the most common points that developers mention after adopting Infisical:
-Infisical helps developers achieve secure centralized secret management and provides all the tools to easily manage secrets in various environments and infrastructure components. In particular, here are some of the most common points that developers mention after adopting Infisical:
- Streamlined **local development** processes (switching .env files to [Infisical CLI](/cli/commands/run) and removing secrets from developer machines).
-- **Best-in-class developer experience** with an easy-to-use [Web Dashboard](/documentation/platform/project).
-- Simple secret management inside **[CI/CD pipelines](/integrations/cicd/githubactions)** and staging environments.
-- Secure and compliant secret management practices in **[production environments](/sdks/overview)**.
+- **Best-in-class developer experience** with an easy-to-use [Web Dashboard](/documentation/platform/project).
+- Simple secret management inside **[CI/CD pipelines](/integrations/cicd/githubactions)** and staging environments.
+- Secure and compliant secret management practices in **[production environments](/sdks/overview)**.
- **Facilitated workflows** around [secret change management](/documentation/platform/pr-workflows), [access requests](/documentation/platform/access-controls/access-requests), [temporary access provisioning](/documentation/platform/access-controls/temporary-access), and more.
- **Improved security posture** thanks to [secret scanning](/cli/scanning-overview), [granular access control policies](/documentation/platform/access-controls/overview), [automated secret rotation](https://infisical.com/docs/documentation/platform/secret-rotation/overview), and [dynamic secrets](/documentation/platform/dynamic-secrets/overview) capabilities.
-## How does Infisical work?
+## How does Infisical work?
-To make secret management effortless and secure, Infisical follows a certain structure for enabling secret management workflows as defined below.
+To make secret management effortless and secure, Infisical follows a certain structure for enabling secret management workflows as defined below.
-**Identities** in Infisical are users or machine which have a certain set of roles and permissions assigned to them. Such identities are able to manage secrets in various **Clients** throughout the entire infrastructure. To do that, identities have to verify themselves through one of the available **Authentication Methods**.
+**Identities** in Infisical are users or machine which have a certain set of roles and permissions assigned to them. Such identities are able to manage secrets in various **Clients** throughout the entire infrastructure. To do that, identities have to verify themselves through one of the available **Authentication Methods**.
-As a result, the 3 main concepts that are important to understand are:
-- **[Identities](/documentation/platform/identities/overview)**: users or machines with a set permissions assigned to them.
+As a result, the 3 main concepts that are important to understand are:
+
+- **[Identities](/documentation/platform/identities/overview)**: users or machines with a set permissions assigned to them.
- **[Clients](/integrations/platforms/kubernetes)**: Infisical-developed tools for managing secrets in various infrastructure components (e.g., [Kubernetes Operator](/integrations/platforms/kubernetes), [Infisical Agent](/integrations/platforms/infisical-agent), [CLI](/cli/usage), [SDKs](/sdks/overview), [API](/api-reference/overview/introduction), [Web Dashboard](/documentation/platform/organization)).
-- **[Authentication Methods](/documentation/platform/identities/universal-auth)**: ways for Identities to authenticate inside different clients (e.g., SAML SSO for Web Dashboard, Universal Auth for Infisical Agent, etc.).
+- **[Authentication Methods](/documentation/platform/identities/universal-auth)**: ways for Identities to authenticate inside different clients (e.g., SAML SSO for Web Dashboard, Universal Auth for Infisical Agent, AWS IAM Auth etc.).
-## How to get started with Infisical?
+## How to get started with Infisical?
Depending on your use case, it might be helpful to look into some of the resources and guides provided below.
-
+
Inject secrets into any application process/environment.
Fetch secrets with any programming language on demand.
-
+
Inject secrets into Docker containers.
+We recommend using one of Infisical's clients like SDKs or the Infisical Agent
+to authenticate with Infisical using AWS IAM Auth as they handle the
+authentication process including the signed `GetCallerIdentity` query
+construction for you.
+
+Also, note that Infisical needs network-level access to send requests to the AWS STS API
+as part of the AWS IAM Auth workflow.
+
+
+
+## Workflow
+
+In the following steps, we explore how to create and use identities for your workloads and applications on AWS to
+access the Infisical API using the AWS IAM authentication method.
+
+
+
+ To create an identity, head to your Organization Settings > Access Control > Machine Identities and press **Create identity**.
+
+ 
+
+ When creating an identity, you specify an organization level [role](/documentation/platform/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
+
+ 
+
+ Now input a few details for your new identity. Here's some guidance for each field:
+
+ - Name (required): A friendly name for the identity.
+ - Role (required): A role from the **Organization Roles** tab for the identity to assume. The organization role assigned will determine what organization level resources this identity can have access to.
+
+ Once you've created an identity, you'll be prompted to configure the authentication method for it. Here, select **AWS IAM Auth**.
+
+ 
+
+ Here's some more guidance on each field:
+
+ - Allowed Principal ARNs: A comma-separated list of trusted IAM principal ARNs that are allowed to authenticate with Infisical. The values should take one of three forms: `arn:aws:iam::123456789012:user/MyUserName`, `arn:aws:iam::123456789012:role/MyRoleName`, or `arn:aws:iam::123456789012:*`. Using a wildcard in this case allows any IAM principal in the account `123456789012` to authenticate with Infisical under the identity.
+ - Allowed Account IDs: A comma-separated list of trusted AWS account IDs that are allowed to authenticate with Infisical.
+ - STS Endpoint (default is `https://sts.amazonaws.com/`): The endpoint URL for the AWS STS API. This is useful for AWS GovCloud or other AWS regions that have different STS endpoints.
+ - Access Token TTL (default is `2592000` equivalent to 30 days): The lifetime for an acccess token in seconds. This value will be referenced at renewal time.
+ - Access Token Max TTL (default is `2592000` equivalent to 30 days): The maximum lifetime for an acccess token in seconds. This value will be referenced at renewal time.
+ - Access Token Max Number of Uses (default is `0`): The maximum number of times that an access token can be used; a value of `0` implies infinite number of uses.
+ - Access Token Trusted IPs: The IPs or CIDR ranges that access tokens can be used from. By default, each token is given the `0.0.0.0/0`, allowing usage from any network address.
+
+
+ To enable the identity to access project-level resources such as secrets within a specific project, you should add it to that project.
+
+ To do this, head over to the project you want to add the identity to and go to Project Settings > Access Control > Machine Identities and press **Add identity**.
+
+ Next, select the identity you want to add to the project and the project level role you want to allow it to assume. The project role assigned will determine what project level resources this identity can have access to.
+
+ 
+
+ 
+
+
+ To access the Infisical API as the identity, you need to construct a signed `GetCallerIdentity` query using the [AWS Signature v4 algorithm](https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html) and make a request to the `/api/v1/auth/aws-iam-auth/login` endpoint containing the query data
+ in exchange for an access token.
+
+ We provide a few code examples below of how you can authenticate with Infisical from inside a Lambda function, EC2 instance, etc. and obtain an access token to access the [Infisical API](/api-reference/overview/introduction).
+
+
+
+ The following query construction is an example of how you can authenticate with Infisical from inside a Lambda function.
+
+ The shown example uses Node.js but you can use other languages supported by AWS Lambda.
+
+ ```javascript
+ import AWS from "aws-sdk";
+ import axios from "axios";
+
+ export const handler = async (event, context) => {
+ try {
+ const region = process.env.AWS_REGION;
+ AWS.config.update({ region });
+
+ const iamRequestURL = `https://sts.${region}.amazonaws.com/`;
+ const iamRequestBody = "Action=GetCallerIdentity&Version=2011-06-15";
+ const iamRequestHeaders = {
+ "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
+ Host: `sts.${region}.amazonaws.com`,
+ };
+
+ // Create the request
+ const request = new AWS.HttpRequest(iamRequestURL, region);
+ request.method = "POST";
+ request.headers = iamRequestHeaders;
+ request.headers["X-Amz-Date"] = AWS.util.date
+ .iso8601(new Date())
+ .replace(/[:-]|\.\d{3}/g, "");
+ request.body = iamRequestBody;
+ request.headers["Content-Length"] =
+ Buffer.byteLength(iamRequestBody).toString();
+
+ // Sign the request
+ const signer = new AWS.Signers.V4(request, "sts");
+ signer.addAuthorization(AWS.config.credentials, new Date());
+
+ const infisicalUrl = "https://app.infisical.com"; // or your self-hosted Infisical URL
+ const identityId = "";
+
+ const { data } = await axios.post(
+ `${infisicalUrl}/api/v1/auth/aws-iam-auth/login`,
+ {
+ identityId,
+ iamHttpRequestMethod: "POST",
+ iamRequestUrl: Buffer.from(iamRequestURL).toString("base64"),
+ iamRequestBody: Buffer.from(iamRequestBody).toString("base64"),
+ iamRequestHeaders: Buffer.from(
+ JSON.stringify(iamRequestHeaders)
+ ).toString("base64"),
+ }
+ );
+
+ console.log("result data: ", data); // access token here
+ } catch (err) {
+ console.error(err);
+ }
+ };
+ ````
+
+
+ The following query construction is an example of how you can authenticate with Infisical from inside a EC2 instance.
+
+ The shown example uses Node.js but you can use other language you wish.
+
+ ```javascript
+ import AWS from "aws-sdk";
+ import axios from "axios";
+
+ const main = async () => {
+ try {
+ // obtain region from EC2 instance metadata
+ const tokenResponse = await axios.put("http://169.254.169.254/latest/api/token", null, {
+ headers: {
+ "X-aws-ec2-metadata-token-ttl-seconds": "21600"
+ }
+ });
+
+ const url = "http://169.254.169.254/latest/dynamic/instance-identity/document";
+ const response = await axios.get(url, {
+ headers: {
+ "X-aws-ec2-metadata-token": tokenResponse.data
+ }
+ });
+
+ const region = response.data.region;
+
+ AWS.config.update({
+ region
+ });
+
+ const iamRequestURL = `https://sts.${region}.amazonaws.com/`;
+ const iamRequestBody = "Action=GetCallerIdentity&Version=2011-06-15";
+ const iamRequestHeaders = {
+ "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
+ Host: `sts.${region}.amazonaws.com`
+ };
+
+ const request = new AWS.HttpRequest(new AWS.Endpoint(iamRequestURL), AWS.config.region);
+ request.method = "POST";
+ request.headers = iamRequestHeaders;
+ request.headers["X-Amz-Date"] = AWS.util.date.iso8601(new Date()).replace(/[:-]|\.\d{3}/g, "");
+ request.body = iamRequestBody;
+ request.headers["Content-Length"] = Buffer.byteLength(iamRequestBody);
+
+ const signer = new AWS.Signers.V4(request, "sts");
+ signer.addAuthorization(AWS.config.credentials, new Date());
+
+ const infisicalUrl = "https://app.infisical.com"; // or your self-hosted Infisical URL
+ const identityId = "";
+
+ const { data } = await axios.post(`${infisicalUrl}/api/v1/auth/aws-iam-auth/login`, {
+ identityId,
+ iamHttpRequestMethod: "POST",
+ iamRequestUrl: Buffer.from(iamRequestURL).toString("base64"),
+ iamRequestBody: Buffer.from(iamRequestBody).toString("base64"),
+ iamRequestHeaders: Buffer.from(JSON.stringify(iamRequestHeaders)).toString("base64")
+ });
+
+ console.log("result data: ", data); // access token here
+ } catch (err) {
+ console.error(err);
+ }
+ }
+
+ main();
+ ````
+
+
+ The following query construction provides a generic example of how you can construct a signed `GetCallerIdentity` query and obtain the required payload components.
+
+ The shown example uses Node.js but you can use any language you wish.
+
+ ```javascript
+ const AWS = require("aws-sdk");
+
+ const region = "";
+ const infisicalUrl = "https://app.infisical.com"; // or your self-hosted Infisical URL
+
+ const iamRequestURL = `https://sts.${region}.amazonaws.com/`;
+ const iamRequestBody = "Action=GetCallerIdentity&Version=2011-06-15";
+ const iamRequestHeaders = {
+ "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
+ Host: `sts.${region}.amazonaws.com`
+ };
+
+ const request = new AWS.HttpRequest(new AWS.Endpoint(iamRequestURL), region);
+ request.method = "POST";
+ request.headers = iamRequestHeaders;
+ request.headers["X-Amz-Date"] = AWS.util.date.iso8601(new Date()).replace(/[:-]|\.\d{3}/g, "");
+ request.body = iamRequestBody;
+ request.headers["Content-Length"] = Buffer.byteLength(iamRequestBody);
+ ````
+
+ #### Sample request
+
+ ```bash Request
+ curl --location --request POST 'https://app.infisical.com/api/v1/auth/aws-iam-auth/login' \
+ --header 'Content-Type: application/x-www-form-urlencoded' \
+ --data-urlencode 'identityId=...' \
+ --data-urlencode 'iamHttpRequestMethod=...' \
+ --data-urlencode 'iamRequestBody=...' \
+ --data-urlencode 'iamRequestHeaders=...'
+ ```
+
+ #### Sample response
+
+ ```bash Response
+ {
+ "accessToken": "...",
+ "expiresIn": 7200,
+ "accessTokenMaxTTL": 43244
+ "tokenType": "Bearer"
+ }
+ ```
+
+ Next, you can use the access token to access the [Infisical API](/api-reference/overview/introduction)
+
+
+
+
+ We recommend using one of Infisical's clients like SDKs or the Infisical Agent to authenticate with Infisical using AWS IAM Auth as they handle the authentication process including the signed `GetCallerIdentity` query construction for you.
+
+
+
+ Each identity access token has a time-to-live (TLL) which you can infer from the response of the login operation;
+ the default TTL is `7200` seconds which can be adjusted.
+
+ If an identity access token expires, it can no longer authenticate with the Infisical API. In this case,
+ a new access token should be obtained by performing another login operation.
+
+
+
+
diff --git a/docs/documentation/platform/identities/machine-identities.mdx b/docs/documentation/platform/identities/machine-identities.mdx
index daa5db7ede..9168cb230d 100644
--- a/docs/documentation/platform/identities/machine-identities.mdx
+++ b/docs/documentation/platform/identities/machine-identities.mdx
@@ -7,7 +7,7 @@ description: "Learn how to use Machine Identities to programmatically interact w
An Infisical machine identity is an entity that represents a workload or application that require access to various resources in Infisical. This is conceptually similar to an IAM user in AWS or service account in Google Cloud Platform (GCP).
-Each identity must authenticate with the API using a supported authentication method like [Universal Auth](/documentation/platform/identities/universal-auth) to get back a short-lived access token to be used in subsequent requests.
+Each identity must authenticate using a supported authentication method like [Universal Auth](/documentation/platform/identities/universal-auth) or [AWS IAM Auth](/documentation/platform/identities/aws-iam-auth) to get back a short-lived access token to be used in subsequent requests.

@@ -21,7 +21,7 @@ Key Features:
A typical workflow for using identities consists of four steps:
1. Creating the identity with a name and [role](/documentation/platform/role-based-access-controls) in Organization Access Control > Machine Identities.
- This step also involves configuring an authentication method for it such as [Universal Auth](/documentation/platform/identities/universal-auth).
+ This step also involves configuring an authentication method for it such as [Universal Auth](/documentation/platform/identities/universal-auth) or [AWS IAM Auth](/documentation/platform/identities/aws-iam-auth).
2. Adding the identity to the project(s) you want it to have access to.
3. Authenticating the identity with the Infisical API based on the configured authentication method on it and receiving a short-lived access token back.
4. Authenticating subsequent requests with the Infisical API using the short-lived access token.
@@ -37,7 +37,8 @@ Machine Identity support for the rest of the clients is planned to be released i
To interact with various resources in Infisical, Machine Identities are able to authenticate using:
-- [Universal Auth](/documentation/platform/identities/universal-auth): the most versatile authentication method that can be configured on an identity from any platform/environment to access Infisical.
+- [Universal Auth](/documentation/platform/identities/universal-auth): A platform-agnostic authentication method that can be configured on an identity suitable to authenticate from any platform/environment.
+- [AWS IAM Auth](/documentation/platform/identities/aws-iam-auth): An AWS-native authentication method for IAM principals like EC2 instances or Lambda functions to authenticate with Infisical.
## FAQ
diff --git a/docs/documentation/platform/identities/universal-auth.mdx b/docs/documentation/platform/identities/universal-auth.mdx
index a9f4dffae3..cd40a9e641 100644
--- a/docs/documentation/platform/identities/universal-auth.mdx
+++ b/docs/documentation/platform/identities/universal-auth.mdx
@@ -3,17 +3,14 @@ title: Universal Auth
description: "Learn how to authenticate to Infisical from any platform or environment."
---
-**Universal Auth** is the most versatile authentication method that can be configured for a [machine identity](/documentation/platform/identities/machine-identities) to access Infisical from any platform or environment.
+**Universal Auth** is a platform-agnostic authentication method that can be configured for a [machine identity](/documentation/platform/identities/machine-identities) suitable to authenticate from any platform/environment.
-In this method, each identity is given a **Client ID** for which you can generate one or more **Client Secret(s)**. Together, a **Client ID** and **Client Secret** can be exchanged for an access token to authenticate with the Infisical API.
+## Concept
-## Properties
+In this method, Infisical authenticates an identity by verifying the credentials issued for it at the `/api/v1/auth/universal-auth/login` endpoint. If successful,
+then Infisical returns a short-lived access token that can be used to make authenticated requests to the Infisical API.
-Universal Auth supports many settings that can be beneficial for tightening your workflow security configuration:
-
-- Support for restrictions on the number of times that the **Client Secret(s)** and access token(s) can be used.
-- Support for expiration, so, if specified, the **Client Secret** of the identity will automatically be defunct after a period of time.
-- Support for IP allowlisting; this means you can restrict the usage of **Client Secret(s)** and access token to a specific IP or CIDR range.
+In Universal Auth, an identity is given a **Client ID** and one or more **Client Secret(s)**. Together, a **Client ID** and **Client Secret** can be exchanged for a short-lived access token to authenticate with the Infisical API.
## Workflow
@@ -27,18 +24,18 @@ using the Universal Auth authentication method.

When creating an identity, you specify an organization level [role](/documentation/platform/role-based-access-controls) for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
-
+

Now input a few details for your new identity. Here's some guidance for each field:
- Name (required): A friendly name for the identity.
- Role (required): A role from the **Organization Roles** tab for the identity to assume. The organization role assigned will determine what organization level resources this identity can have access to.
-
+
Once you've created an identity, you'll be prompted to configure the **Universal Auth** authentication method for it.
-
+

-
+
Here's some more guidance on each field:
- Access Token TTL (default is `2592000` equivalent to 30 days): The lifetime for an acccess token in seconds. This value will be referenced at renewal time.
@@ -78,8 +75,9 @@ using the Universal Auth authentication method.
Next, select the identity you want to add to the project and the project level role you want to allow it to assume. The project role assigned will determine what project level resources this identity can have access to.

-
+

+
To access the Infisical API as the identity, you should first perform a login operation
@@ -88,16 +86,16 @@ using the Universal Auth authentication method.
#### Sample request
- ```
+ ```bash Request
curl --location --request POST 'https://app.infisical.com/api/v1/auth/universal-auth/login' \
--header 'Content-Type: application/x-www-form-urlencoded' \
- --data-urlencode 'clientSecret=...' \
- --data-urlencode 'clientId=...'
+ --data-urlencode 'clientId=...' \
+ --data-urlencode 'clientSecret=...'
```
-
+
#### Sample response
-
- ```
+
+ ```bash Response
{
"accessToken": "...",
"expiresIn": 7200,
@@ -107,7 +105,7 @@ using the Universal Auth authentication method.
```
Next, you can use the access token to authenticate with the [Infisical API](/api-reference/overview/introduction)
-
+
Each identity access token has a time-to-live (TLL) which you can infer from the response of the login operation;
the default TTL is `7200` seconds which can be adjusted.
@@ -115,6 +113,7 @@ using the Universal Auth authentication method.
If an identity access token expires, it can no longer authenticate with the Infisical API. In this case,
a new access token should be obtained by performing another login operation.
+
@@ -134,7 +133,8 @@ using the Universal Auth authentication method.
In certain cases, you may want to extend the lifespan of an access token; to do so, you must set a max TTL parameter.
- A token can be renewed any number of time and each call to renew it will extend the toke life by increments of access token TTL.
- Regardless of how frequently an access token is renewed, its lifespan remains bound to the maximum TTL determined at its creation
+A token can be renewed any number of time and each call to renew it will extend the toke life by increments of access token TTL.
+Regardless of how frequently an access token is renewed, its lifespan remains bound to the maximum TTL determined at its creation
+
-
\ No newline at end of file
+
diff --git a/docs/images/platform/identities/identities-org-create-aws-iam-auth-method.png b/docs/images/platform/identities/identities-org-create-aws-iam-auth-method.png
new file mode 100644
index 0000000000..4b902c048a
Binary files /dev/null and b/docs/images/platform/identities/identities-org-create-aws-iam-auth-method.png differ
diff --git a/docs/mint.json b/docs/mint.json
index 1708f49f38..976d5df37d 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -153,6 +153,7 @@
"documentation/platform/auth-methods/email-password",
"documentation/platform/token",
"documentation/platform/identities/universal-auth",
+ "documentation/platform/identities/aws-iam-auth",
"documentation/platform/identities/gcp-iam-auth",
"documentation/platform/mfa",
{
diff --git a/frontend/src/components/permissions/PermissionDeniedBanner.tsx b/frontend/src/components/permissions/PermissionDeniedBanner.tsx
index 067ee9c4a9..b3c7a4f538 100644
--- a/frontend/src/components/permissions/PermissionDeniedBanner.tsx
+++ b/frontend/src/components/permissions/PermissionDeniedBanner.tsx
@@ -17,23 +17,20 @@ export const PermissionDeniedBanner = ({ containerClassName, className, children
containerClassName
)}
>
-
-
-
-
-
-
Access Restricted
- {children || (
-
- Your role has limited permissions, please
contact your administrator to gain
- access
-
- )}
+
+
+
+
+
+
+
Access Restricted
+ {children || (
+
+ Your role has limited permissions, please
contact your administrator to gain
+ access
+
+ )}
+
diff --git a/frontend/src/components/v2/Badge/Badge.tsx b/frontend/src/components/v2/Badge/Badge.tsx
new file mode 100644
index 0000000000..321c032966
--- /dev/null
+++ b/frontend/src/components/v2/Badge/Badge.tsx
@@ -0,0 +1,32 @@
+import { cva, VariantProps } from "cva";
+import { twMerge } from "tailwind-merge";
+
+interface IProps {
+ children: React.ReactNode;
+ className?: string;
+}
+
+const badgeVariants = cva(
+ [
+ "inline-block cursor-default rounded-md bg-yellow/20 px-1.5 pb-[0.03rem] pt-[0.04rem] text-xs text-yellow opacity-80 hover:opacity-100"
+ ],
+ {
+ variants: {
+ variant: {
+ primary: "bg-yellow/20 text-yellow",
+ danger: "bg-red/20 text-red",
+ success: "bg-green/20 text-green"
+ }
+ }
+ }
+);
+
+export type BadgeProps = VariantProps
& IProps;
+
+export const Badge = ({ children, className, variant }: BadgeProps) => {
+ return (
+
+ {children}
+
+ );
+};
diff --git a/frontend/src/components/v2/Badge/index.tsx b/frontend/src/components/v2/Badge/index.tsx
new file mode 100644
index 0000000000..5c7042709a
--- /dev/null
+++ b/frontend/src/components/v2/Badge/index.tsx
@@ -0,0 +1 @@
+export { Badge } from "./Badge";
diff --git a/frontend/src/components/v2/Button/Button.tsx b/frontend/src/components/v2/Button/Button.tsx
index 5536d699aa..7707805e98 100644
--- a/frontend/src/components/v2/Button/Button.tsx
+++ b/frontend/src/components/v2/Button/Button.tsx
@@ -29,7 +29,7 @@ const buttonVariants = cva(
colorSchema: {
primary: ["bg-primary", "text-black", "border-primary bg-opacity-90 hover:bg-opacity-100"],
secondary: ["bg-mineshaft", "text-gray-300", "border-mineshaft hover:bg-opacity-80"],
- danger: ["bg-red", "text-white", "border-red hover:bg-opacity-90"],
+ danger: ["!bg-red", "!text-white", "!border-red hover:!bg-opacity-90"],
gray: ["bg-bunker-500", "text-bunker-200"]
},
variant: {
diff --git a/frontend/src/components/v2/Divider/Divider.tsx b/frontend/src/components/v2/Divider/Divider.tsx
new file mode 100644
index 0000000000..39b0f84c57
--- /dev/null
+++ b/frontend/src/components/v2/Divider/Divider.tsx
@@ -0,0 +1,13 @@
+import { twMerge } from "tailwind-merge";
+
+interface IProps {
+ className?: string;
+}
+
+export const Divider = ({ className }: IProps): JSX.Element => {
+ return (
+
+ );
+};
diff --git a/frontend/src/components/v2/Divider/index.tsx b/frontend/src/components/v2/Divider/index.tsx
new file mode 100644
index 0000000000..ac407aa37d
--- /dev/null
+++ b/frontend/src/components/v2/Divider/index.tsx
@@ -0,0 +1 @@
+export { Divider } from "./Divider";
diff --git a/frontend/src/components/v2/Select/Select.tsx b/frontend/src/components/v2/Select/Select.tsx
index 2a76be2abf..12a9094e03 100644
--- a/frontend/src/components/v2/Select/Select.tsx
+++ b/frontend/src/components/v2/Select/Select.tsx
@@ -41,18 +41,22 @@ export const Select = forwardRef(
ref={ref}
className={twMerge(
`inline-flex items-center justify-between rounded-md
- bg-mineshaft-900 px-3 py-2 font-inter text-sm font-normal text-bunker-200 outline-none data-[placeholder]:text-mineshaft-200 focus:bg-mineshaft-700/80`,
- className
+ bg-mineshaft-900 px-3 py-2 font-inter text-sm font-normal text-bunker-200 outline-none focus:bg-mineshaft-700/80 data-[placeholder]:text-mineshaft-200`,
+ className,
+ isDisabled && "cursor-not-allowed opacity-50"
)}
>
{props.icon ? : placeholder}
- {!isDisabled && (
-
-
-
- )}
+
+
+
+
{
+ const queryClient = useQueryClient();
+
+ return useMutation<{}, {}, TCreateAccessPolicyDTO>({
+ mutationFn: async ({ environment, projectSlug, approvals, approvers, name, secretPath }) => {
+ const { data } = await apiRequest.post("/api/v1/access-approvals/policies", {
+ environment,
+ projectSlug,
+ approvals,
+ approvers,
+ secretPath,
+ name
+ });
+ return data;
+ },
+ onSuccess: (_, { projectSlug }) => {
+ queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
+ }
+ });
+};
+
+export const useUpdateAccessApprovalPolicy = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<{}, {}, TUpdateAccessPolicyDTO>({
+ mutationFn: async ({ id, approvers, approvals, name, secretPath }) => {
+ const { data } = await apiRequest.patch(`/api/v1/access-approvals/policies/${id}`, {
+ approvals,
+ approvers,
+ secretPath,
+ name
+ });
+ return data;
+ },
+ onSuccess: (_, { projectSlug }) => {
+ queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
+ }
+ });
+};
+
+export const useDeleteAccessApprovalPolicy = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<{}, {}, TDeleteSecretPolicyDTO>({
+ mutationFn: async ({ id }) => {
+ const { data } = await apiRequest.delete(`/api/v1/access-approvals/policies/${id}`);
+ return data;
+ },
+ onSuccess: (_, { projectSlug }) => {
+ queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
+ }
+ });
+};
+
+export const useCreateAccessRequest = () => {
+ const queryClient = useQueryClient();
+ return useMutation<{}, {}, TCreateAccessRequestDTO>({
+ mutationFn: async ({ projectSlug, ...request }) => {
+ const { data } = await apiRequest.post(
+ "/api/v1/access-approvals/requests",
+ {
+ ...request,
+ permissions: request.permissions ? packRules(request.permissions) : undefined
+ },
+ {
+ params: {
+ projectSlug
+ }
+ }
+ );
+
+ return data;
+ },
+ onSuccess: (_, { projectSlug }) => {
+ queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalRequestCount(projectSlug));
+ }
+ });
+};
+
+export const useReviewAccessRequest = () => {
+ const queryClient = useQueryClient();
+ return useMutation<
+ {},
+ {},
+ {
+ requestId: string;
+ status: "approved" | "rejected";
+ projectSlug: string;
+ envSlug?: string;
+ requestedBy?: string;
+ }
+ >({
+ mutationFn: async ({ requestId, status }) => {
+ const { data } = await apiRequest.post(
+ `/api/v1/access-approvals/requests/${requestId}/review`,
+ {
+ status
+ }
+ );
+ return data;
+ },
+ onSuccess: (_, { projectSlug, envSlug, requestedBy }) => {
+ queryClient.invalidateQueries(
+ accessApprovalKeys.getAccessApprovalRequests(projectSlug, envSlug, requestedBy)
+ );
+ queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalRequestCount(projectSlug));
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/accessApproval/queries.tsx b/frontend/src/hooks/api/accessApproval/queries.tsx
new file mode 100644
index 0000000000..599962e433
--- /dev/null
+++ b/frontend/src/hooks/api/accessApproval/queries.tsx
@@ -0,0 +1,159 @@
+import { PackRule, unpackRules } from "@casl/ability/extra";
+import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { TProjectPermission } from "../roles/types";
+import {
+ TAccessApprovalPolicy,
+ TAccessApprovalRequest,
+ TAccessRequestCount,
+ TGetAccessApprovalRequestsDTO,
+ TGetAccessPolicyApprovalCountDTO
+} from "./types";
+
+export const accessApprovalKeys = {
+ getAccessApprovalPolicies: (projectSlug: string) =>
+ [{ projectSlug }, "access-approval-policies"] as const,
+ getAccessApprovalPolicyOfABoard: (workspaceId: string, environment: string) =>
+ [{ workspaceId, environment }, "access-approval-policy"] as const,
+
+ getAccessApprovalRequests: (projectSlug: string, envSlug?: string, requestedBy?: string) =>
+ [{ projectSlug, envSlug, requestedBy }, "access-approvals-requests"] as const,
+ getAccessApprovalRequestCount: (projectSlug: string) =>
+ [{ projectSlug }, "access-approval-request-count"] as const
+};
+
+export const fetchPolicyApprovalCount = async ({
+ projectSlug,
+ envSlug
+}: TGetAccessPolicyApprovalCountDTO) => {
+ const { data } = await apiRequest.get<{ count: number }>(
+ "/api/v1/access-approvals/policies/count",
+ {
+ params: { projectSlug, envSlug }
+ }
+ );
+ return data.count;
+};
+
+export const useGetAccessPolicyApprovalCount = ({
+ projectSlug,
+ envSlug,
+ options = {}
+}: TGetAccessPolicyApprovalCountDTO & {
+ options?: UseQueryOptions<
+ number,
+ unknown,
+ number,
+ ReturnType
+ >;
+}) =>
+ useQuery({
+ queryFn: () => fetchPolicyApprovalCount({ projectSlug, envSlug }),
+ ...options,
+ enabled: Boolean(projectSlug) && (options?.enabled ?? true)
+ });
+
+const fetchApprovalPolicies = async ({ projectSlug }: TGetAccessApprovalRequestsDTO) => {
+ const { data } = await apiRequest.get<{ approvals: TAccessApprovalPolicy[] }>(
+ "/api/v1/access-approvals/policies",
+ { params: { projectSlug } }
+ );
+ return data.approvals;
+};
+
+const fetchApprovalRequests = async ({
+ projectSlug,
+ envSlug,
+ authorProjectMembershipId
+}: TGetAccessApprovalRequestsDTO) => {
+ const { data } = await apiRequest.get<{ requests: TAccessApprovalRequest[] }>(
+ "/api/v1/access-approvals/requests",
+ { params: { projectSlug, envSlug, authorProjectMembershipId } }
+ );
+
+ return data.requests.map((request) => ({
+ ...request,
+
+ privilege: request.privilege
+ ? {
+ ...request.privilege,
+ permissions: unpackRules(
+ request.privilege.permissions as unknown as PackRule[]
+ )
+ }
+ : null,
+ permissions: unpackRules(request.permissions as unknown as PackRule[])
+ }));
+};
+
+const fetchAccessRequestsCount = async (projectSlug: string) => {
+ const { data } = await apiRequest.get(
+ "/api/v1/access-approvals/requests/count",
+ { params: { projectSlug } }
+ );
+ return data;
+};
+
+export const useGetAccessRequestsCount = ({
+ projectSlug,
+ options = {}
+}: TGetAccessApprovalRequestsDTO & {
+ options?: UseQueryOptions<
+ TAccessRequestCount,
+ unknown,
+ { pendingCount: number; finalizedCount: number },
+ ReturnType
+ >;
+}) =>
+ useQuery({
+ queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug),
+ queryFn: () => fetchAccessRequestsCount(projectSlug),
+ ...options,
+ enabled: Boolean(projectSlug) && (options?.enabled ?? true)
+ });
+
+export const useGetAccessApprovalPolicies = ({
+ projectSlug,
+ envSlug,
+ authorProjectMembershipId,
+ options = {}
+}: TGetAccessApprovalRequestsDTO & {
+ options?: UseQueryOptions<
+ TAccessApprovalPolicy[],
+ unknown,
+ TAccessApprovalPolicy[],
+ ReturnType
+ >;
+}) =>
+ useQuery({
+ queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug),
+ queryFn: () => fetchApprovalPolicies({ projectSlug, envSlug, authorProjectMembershipId }),
+ ...options,
+ enabled: Boolean(projectSlug) && (options?.enabled ?? true)
+ });
+
+export const useGetAccessApprovalRequests = ({
+ projectSlug,
+ envSlug,
+ authorProjectMembershipId,
+ options = {}
+}: TGetAccessApprovalRequestsDTO & {
+ options?: UseQueryOptions<
+ TAccessApprovalRequest[],
+ unknown,
+ TAccessApprovalRequest[],
+ ReturnType
+ >;
+}) =>
+ useQuery({
+ queryKey: accessApprovalKeys.getAccessApprovalRequests(
+ projectSlug,
+ envSlug,
+ authorProjectMembershipId
+ ),
+ queryFn: () => fetchApprovalRequests({ projectSlug, envSlug, authorProjectMembershipId }),
+ ...options,
+ enabled: Boolean(projectSlug) && (options?.enabled ?? true)
+ });
diff --git a/frontend/src/hooks/api/accessApproval/types.ts b/frontend/src/hooks/api/accessApproval/types.ts
new file mode 100644
index 0000000000..2176b8bc1b
--- /dev/null
+++ b/frontend/src/hooks/api/accessApproval/types.ts
@@ -0,0 +1,139 @@
+import { TProjectPermission } from "../roles/types";
+import { WorkspaceEnv } from "../workspace/types";
+
+export type TAccessApprovalPolicy = {
+ id: string;
+ name: string;
+ approvals: number;
+ secretPath: string;
+ envId: string;
+ workspace: string;
+ environment: WorkspaceEnv;
+ projectId: string;
+ approvers: string[];
+};
+
+export type TAccessApprovalRequest = {
+ id: string;
+ policyId: string;
+ privilegeId: string | null;
+ requestedBy: string;
+ createdAt: Date;
+ updatedAt: Date;
+ isTemporary: boolean;
+ temporaryRange: string | null | undefined;
+
+ permissions: TProjectPermission[] | null;
+
+ // Computed
+ environmentName: string;
+ isApproved: boolean;
+
+ privilege: {
+ membershipId: string;
+ isTemporary: boolean;
+ temporaryMode?: string | null;
+ temporaryRange?: string | null;
+ temporaryAccessStartTime?: Date | null;
+ temporaryAccessEndTime?: Date | null;
+ permissions: TProjectPermission[];
+ isApproved: boolean;
+ } | null;
+
+ policy: {
+ id: string;
+ name: string;
+ approvals: number;
+ approvers: string[];
+ secretPath?: string | null;
+ envId: string;
+ };
+
+ reviewers: {
+ member: string;
+ status: string;
+ }[];
+};
+
+export type TAccessApproval = {
+ id: string;
+ policyId: string;
+ privilegeId: string;
+ requestedBy: string;
+};
+
+export type TAccessRequestCount = {
+ pendingCount: number;
+ finalizedCount: number;
+};
+
+export type TProjectUserPrivilege = {
+ projectMembershipId: string;
+ slug: string;
+ id: string;
+ createdAt: Date;
+ updatedAt: Date;
+ permissions?: TProjectPermission[];
+} & (
+ | {
+ isTemporary: true;
+ temporaryMode: string;
+ temporaryRange: string;
+ temporaryAccessStartTime: string;
+ temporaryAccessEndTime?: string;
+ }
+ | {
+ isTemporary: false;
+ temporaryMode?: null;
+ temporaryRange?: null;
+ temporaryAccessStartTime?: null;
+ temporaryAccessEndTime?: null;
+ }
+);
+
+export type TCreateAccessRequestDTO = {
+ projectSlug: string;
+} & Omit;
+
+export type TGetAccessApprovalRequestsDTO = {
+ projectSlug: string;
+ envSlug?: string;
+ authorProjectMembershipId?: string;
+};
+
+export type TGetAccessPolicyApprovalCountDTO = {
+ projectSlug: string;
+ envSlug: string;
+};
+
+export type TGetSecretApprovalPolicyOfBoardDTO = {
+ workspaceId: string;
+ environment: string;
+ secretPath: string;
+};
+
+export type TCreateAccessPolicyDTO = {
+ projectSlug: string;
+ name?: string;
+ environment: string;
+ approvers?: string[];
+ approvals?: number;
+ secretPath?: string;
+};
+
+export type TUpdateAccessPolicyDTO = {
+ id: string;
+ name?: string;
+ approvers?: string[];
+ secretPath?: string;
+ environment?: string;
+ approvals?: number;
+ // for invalidating list
+ projectSlug: string;
+};
+
+export type TDeleteSecretPolicyDTO = {
+ id: string;
+ // for invalidating list
+ projectSlug: string;
+};
diff --git a/frontend/src/hooks/api/identities/constants.tsx b/frontend/src/hooks/api/identities/constants.tsx
index ff29df376d..a97b83861a 100644
--- a/frontend/src/hooks/api/identities/constants.tsx
+++ b/frontend/src/hooks/api/identities/constants.tsx
@@ -2,5 +2,6 @@ import { IdentityAuthMethod } from "./enums";
export const identityAuthToNameMap: { [I in IdentityAuthMethod]: string } = {
[IdentityAuthMethod.UNIVERSAL_AUTH]: "Universal Auth",
- [IdentityAuthMethod.GCP_IAM_AUTH]: "GCP IAM Auth"
+ [IdentityAuthMethod.GCP_IAM_AUTH]: "GCP IAM Auth",
+ [IdentityAuthMethod.AWS_IAM_AUTH]: "AWS IAM Auth"
};
diff --git a/frontend/src/hooks/api/identities/enums.tsx b/frontend/src/hooks/api/identities/enums.tsx
index 7991ed7db0..ecc8f12150 100644
--- a/frontend/src/hooks/api/identities/enums.tsx
+++ b/frontend/src/hooks/api/identities/enums.tsx
@@ -1,4 +1,5 @@
export enum IdentityAuthMethod {
UNIVERSAL_AUTH = "universal-auth",
- GCP_IAM_AUTH = "gcp-iam-auth"
+ GCP_IAM_AUTH = "gcp-iam-auth",
+ AWS_IAM_AUTH = "aws-iam-auth"
}
diff --git a/frontend/src/hooks/api/identities/index.tsx b/frontend/src/hooks/api/identities/index.tsx
index dba67af404..21166816ff 100644
--- a/frontend/src/hooks/api/identities/index.tsx
+++ b/frontend/src/hooks/api/identities/index.tsx
@@ -1,6 +1,7 @@
export { identityAuthToNameMap } from "./constants";
export { IdentityAuthMethod } from "./enums";
export {
+ useAddIdentityAwsIamAuth,
useAddIdentityGcpIamAuth,
useAddIdentityUniversalAuth,
useCreateIdentity,
@@ -8,9 +9,13 @@ export {
useDeleteIdentity,
useRevokeIdentityUniversalAuthClientSecret,
useUpdateIdentity,
+ useUpdateIdentityAwsIamAuth,
useUpdateIdentityGcpIamAuth,
- useUpdateIdentityUniversalAuth} from "./mutations";
+ useUpdateIdentityUniversalAuth
+} from "./mutations";
export {
+ useGetIdentityAwsIamAuth,
useGetIdentityGcpIamAuth,
useGetIdentityUniversalAuth,
- useGetIdentityUniversalAuthClientSecrets} from "./queries";
+ useGetIdentityUniversalAuthClientSecrets
+} from "./queries";
diff --git a/frontend/src/hooks/api/identities/mutations.tsx b/frontend/src/hooks/api/identities/mutations.tsx
index 2f573f8d7e..914264b870 100644
--- a/frontend/src/hooks/api/identities/mutations.tsx
+++ b/frontend/src/hooks/api/identities/mutations.tsx
@@ -5,6 +5,7 @@ import { apiRequest } from "@app/config/request";
import { organizationKeys } from "../organization/queries";
import { identitiesKeys } from "./queries";
import {
+ AddIdentityAwsIamAuthDTO,
AddIdentityGcpIamAuthDTO,
AddIdentityUniversalAuthDTO,
ClientSecretData,
@@ -14,11 +15,14 @@ import {
DeleteIdentityDTO,
DeleteIdentityUniversalAuthClientSecretDTO,
Identity,
+ IdentityAwsIamAuth,
IdentityGcpIamAuth,
IdentityUniversalAuth,
+ UpdateIdentityAwsIamAuthDTO,
UpdateIdentityDTO,
UpdateIdentityGcpIamAuthDTO,
- UpdateIdentityUniversalAuthDTO} from "./types";
+ UpdateIdentityUniversalAuthDTO
+} from "./types";
export const useCreateIdentity = () => {
const queryClient = useQueryClient();
@@ -206,6 +210,42 @@ export const useAddIdentityGcpIamAuth = () => {
});
};
+export const useAddIdentityAwsIamAuth = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({
+ identityId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }) => {
+ const {
+ data: { identityAwsIamAuth }
+ } = await apiRequest.post<{ identityAwsIamAuth: IdentityAwsIamAuth }>(
+ `/api/v1/auth/aws-iam-auth/identities/${identityId}`,
+ {
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }
+ );
+
+ return identityAwsIamAuth;
+ },
+ onSuccess: (_, { organizationId }) => {
+ queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
+ }
+ });
+};
+
export const useUpdateIdentityGcpIamAuth = () => {
const queryClient = useQueryClient();
return useMutation({
@@ -231,6 +271,7 @@ export const useUpdateIdentityGcpIamAuth = () => {
accessTokenTrustedIps
}
);
+
return identityGcpIamAuth;
},
onSuccess: (_, { organizationId }) => {
@@ -238,3 +279,39 @@ export const useUpdateIdentityGcpIamAuth = () => {
}
});
};
+
+export const useUpdateIdentityAwsIamAuth = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({
+ identityId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }) => {
+ const {
+ data: { identityAwsIamAuth }
+ } = await apiRequest.patch<{ identityAwsIamAuth: IdentityAwsIamAuth }>(
+ `/api/v1/auth/aws-iam-auth/identities/${identityId}`,
+ {
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }
+ );
+
+ return identityAwsIamAuth;
+ },
+ onSuccess: (_, { organizationId }) => {
+ queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/identities/queries.tsx b/frontend/src/hooks/api/identities/queries.tsx
index fee3b7f0e5..623f1b310b 100644
--- a/frontend/src/hooks/api/identities/queries.tsx
+++ b/frontend/src/hooks/api/identities/queries.tsx
@@ -2,28 +2,32 @@ import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
-import { ClientSecretData, IdentityGcpIamAuth,IdentityUniversalAuth } from "./types";
+import {
+ ClientSecretData,
+ IdentityAwsIamAuth,
+ IdentityGcpIamAuth,
+ IdentityUniversalAuth
+} from "./types";
export const identitiesKeys = {
getIdentityUniversalAuth: (identityId: string) =>
[{ identityId }, "identity-universal-auth"] as const,
getIdentityUniversalAuthClientSecrets: (identityId: string) =>
[{ identityId }, "identity-universal-auth-client-secrets"] as const,
- getIdentityGcpIamAuth: (identityId: string) => [{ identityId }, "identity-gcp-iam-auth"] as const
+ getIdentityGcpIamAuth: (identityId: string) => [{ identityId }, "identity-gcp-iam-auth"] as const,
+ getIdentityAwsIamAuth: (identityId: string) => [{ identityId }, "identity-aws-iam-auth"] as const
};
export const useGetIdentityUniversalAuth = (identityId: string) => {
return useQuery({
+ enabled: Boolean(identityId),
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
queryFn: async () => {
- if (identityId === "") throw new Error("Identity ID is required");
-
const {
data: { identityUniversalAuth }
} = await apiRequest.get<{ identityUniversalAuth: IdentityUniversalAuth }>(
`/api/v1/auth/universal-auth/identities/${identityId}`
);
-
return identityUniversalAuth;
}
});
@@ -31,16 +35,14 @@ export const useGetIdentityUniversalAuth = (identityId: string) => {
export const useGetIdentityUniversalAuthClientSecrets = (identityId: string) => {
return useQuery({
+ enabled: Boolean(identityId),
queryKey: identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId),
queryFn: async () => {
- if (identityId === "") return [];
-
const {
data: { clientSecretData }
} = await apiRequest.get<{ clientSecretData: ClientSecretData[] }>(
`/api/v1/auth/universal-auth/identities/${identityId}/client-secrets`
);
-
return clientSecretData;
}
});
@@ -60,3 +62,18 @@ export const useGetIdentityGcpIamAuth = (identityId: string) => {
}
});
};
+
+export const useGetIdentityAwsIamAuth = (identityId: string) => {
+ return useQuery({
+ enabled: Boolean(identityId),
+ queryKey: identitiesKeys.getIdentityAwsIamAuth(identityId),
+ queryFn: async () => {
+ const {
+ data: { identityAwsIamAuth }
+ } = await apiRequest.get<{ identityAwsIamAuth: IdentityAwsIamAuth }>(
+ `/api/v1/auth/aws-iam-auth/identities/${identityId}`
+ );
+ return identityAwsIamAuth;
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.ts
index 2222fdf564..bb904f462c 100644
--- a/frontend/src/hooks/api/identities/types.ts
+++ b/frontend/src/hooks/api/identities/types.ts
@@ -149,6 +149,45 @@ export type UpdateIdentityGcpIamAuthDTO = {
}[];
};
+export type IdentityAwsIamAuth = {
+ identityId: string;
+ stsEndpoint: string;
+ allowedPrincipalArns: string;
+ allowedAccountIds: string;
+ accessTokenTTL: number;
+ accessTokenMaxTTL: number;
+ accessTokenNumUsesLimit: number;
+ accessTokenTrustedIps: IdentityTrustedIp[];
+};
+
+export type AddIdentityAwsIamAuthDTO = {
+ organizationId: string;
+ identityId: string;
+ stsEndpoint: string;
+ allowedPrincipalArns: string;
+ allowedAccountIds: string;
+ accessTokenTTL: number;
+ accessTokenMaxTTL: number;
+ accessTokenNumUsesLimit: number;
+ accessTokenTrustedIps: {
+ ipAddress: string;
+ }[];
+};
+
+export type UpdateIdentityAwsIamAuthDTO = {
+ organizationId: string;
+ identityId: string;
+ stsEndpoint?: string;
+ allowedPrincipalArns?: string;
+ allowedAccountIds?: string;
+ accessTokenTTL?: number;
+ accessTokenMaxTTL?: number;
+ accessTokenNumUsesLimit?: number;
+ accessTokenTrustedIps?: {
+ ipAddress: string;
+ }[];
+};
+
export type CreateIdentityUniversalAuthClientSecretDTO = {
identityId: string;
description?: string;
diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsx
index 574da5a319..61e8cb6665 100644
--- a/frontend/src/hooks/api/index.tsx
+++ b/frontend/src/hooks/api/index.tsx
@@ -1,3 +1,4 @@
+export * from "./accessApproval";
export * from "./admin";
export * from "./apiKeys";
export * from "./auditLogs";
diff --git a/frontend/src/hooks/api/secretFolders/queries.tsx b/frontend/src/hooks/api/secretFolders/queries.tsx
index bcda2b0a49..71c63f3eb3 100644
--- a/frontend/src/hooks/api/secretFolders/queries.tsx
+++ b/frontend/src/hooks/api/secretFolders/queries.tsx
@@ -94,7 +94,21 @@ export const useGetFoldersByEnv = ({
[(folders || []).map((folder) => folder.data)]
);
- return { folders, folderNames, isFolderPresentInEnv };
+ const getFolderByNameAndEnv = useCallback(
+ (name: string, env: string) => {
+ const selectedEnvIndex = environments.indexOf(env);
+ if (selectedEnvIndex !== -1) {
+ return folders?.[selectedEnvIndex]?.data?.find(
+ ({ name: folderName }) => folderName === name
+ );
+ }
+
+ return undefined;
+ },
+ [(folders || []).map((folder) => folder.data)]
+ );
+
+ return { folders, folderNames, isFolderPresentInEnv, getFolderByNameAndEnv };
};
export const useCreateFolder = () => {
diff --git a/frontend/src/hooks/api/types.ts b/frontend/src/hooks/api/types.ts
index 49949d88e1..516a5d7cf3 100644
--- a/frontend/src/hooks/api/types.ts
+++ b/frontend/src/hooks/api/types.ts
@@ -1,5 +1,6 @@
import { ZodIssue } from "zod";
+export type { TAccessApprovalPolicy } from "./accessApproval/types";
export type { TAuditLogStream } from "./auditLogStreams/types";
export type { GetAuthTokenAPI } from "./auth/types";
export type { IncidentContact } from "./incidentContacts/types";
@@ -49,13 +50,13 @@ export enum ApiErrorTypes {
export type TApiErrors =
| {
- error: ApiErrorTypes.ValidationError;
- message: ZodIssue[];
- statusCode: 403;
- }
+ error: ApiErrorTypes.ValidationError;
+ message: ZodIssue[];
+ statusCode: 403;
+ }
| { error: ApiErrorTypes.ForbiddenError; message: string; statusCode: 401 }
| {
- statusCode: 400;
- message: string;
- error: ApiErrorTypes.BadRequestError;
- };
+ statusCode: 400;
+ message: string;
+ error: ApiErrorTypes.BadRequestError;
+ };
diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx
index 2550150f3a..2fcdc93397 100644
--- a/frontend/src/layouts/AppLayout/AppLayout.tsx
+++ b/frontend/src/layouts/AppLayout/AppLayout.tsx
@@ -5,7 +5,7 @@
/* eslint-disable no-var */
/* eslint-disable func-names */
-import { useEffect } from "react";
+import { useEffect, useMemo } from "react";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import Image from "next/image";
@@ -64,6 +64,7 @@ import {
fetchOrgUsers,
useAddUserToWsNonE2EE,
useCreateWorkspace,
+ useGetAccessRequestsCount,
useGetOrgTrialUrl,
useGetSecretApprovalRequestCount,
useGetUserAction,
@@ -115,7 +116,7 @@ type TAddProjectFormData = yup.InferType;
export const AppLayout = ({ children }: LayoutProps) => {
const router = useRouter();
-
+
const { mutateAsync } = useGetOrgTrialUrl();
const { workspaces, currentWorkspace } = useWorkspace();
@@ -124,9 +125,15 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { user } = useUser();
const { subscription } = useSubscription();
const workspaceId = currentWorkspace?.id || "";
+ const projectSlug = currentWorkspace?.slug || "";
const { data: updateClosed } = useGetUserAction("december_update_closed");
const { data: secretApprovalReqCount } = useGetSecretApprovalRequestCount({ workspaceId });
+ const { data: accessApprovalRequestCount } = useGetAccessRequestsCount({ projectSlug });
+
+ const pendingRequestsCount = useMemo(() => {
+ return (secretApprovalReqCount?.open || 0) + (accessApprovalRequestCount?.pendingCount || 0);
+ }, [secretApprovalReqCount, accessApprovalRequestCount]);
const isAddingProjectsAllowed = subscription?.workspaceLimit
? subscription.workspacesUsed < subscription.workspaceLimit
@@ -554,10 +561,13 @@ export const AppLayout = ({ children }: LayoutProps) => {
}
icon="system-outline-189-domain-verification"
>
- Secret Approvals
- {Boolean(secretApprovalReqCount?.open) && (
+ Approvals
+ {Boolean(
+ secretApprovalReqCount?.open ||
+ accessApprovalRequestCount?.pendingCount
+ ) && (
- {secretApprovalReqCount?.open}
+ {pendingRequestsCount}
)}
diff --git a/frontend/src/pages/login/select-organization.tsx b/frontend/src/pages/login/select-organization.tsx
index 586ed62f90..de866a3235 100644
--- a/frontend/src/pages/login/select-organization.tsx
+++ b/frontend/src/pages/login/select-organization.tsx
@@ -35,8 +35,6 @@ export default function LoginPage() {
const selectOrg = useSelectOrganization();
const { user, isLoading: userLoading } = useUser();
-
-
const queryParams = new URLSearchParams(window.location.search);
const logout = useLogoutUser(true);
@@ -153,7 +151,7 @@ export default function LoginPage() {
- You‘re currently logged in as {user.email}
+ You‘re currently logged in as {user.username}
Not you?{" "}
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx
index 7ec17dd312..2cd4cc3342 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx
@@ -1,3 +1,4 @@
+import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
@@ -13,6 +14,7 @@ import {
import { IdentityAuthMethod } from "@app/hooks/api/identities";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { IdentityAwsIamAuthForm } from "./IdentityAwsIamAuthForm";
import { IdentityUniversalAuthForm } from "./IdentityUniversalAuthForm";
type Props = {
@@ -24,22 +26,25 @@ type Props = {
) => void;
};
-const identityAuthMethods = [{ label: "Universal Auth", value: IdentityAuthMethod.UNIVERSAL_AUTH }];
+const identityAuthMethods = [
+ { label: "Universal Auth", value: IdentityAuthMethod.UNIVERSAL_AUTH },
+ { label: "AWS IAM Auth", value: IdentityAuthMethod.AWS_IAM_AUTH }
+];
const schema = yup
.object({
- authMethod: yup.string().required("Auth method is required") // TODO: better enforcement here
+ authMethod: yup.string().required("Auth method is required")
})
.required();
export type FormData = yup.InferType;
export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
- const {
- control
- // watch,
- } = useForm({
- resolver: yupResolver(schema)
+ const { control, watch, setValue } = useForm({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ authMethod: IdentityAuthMethod.UNIVERSAL_AUTH
+ }
});
const identityAuthMethodData = popUp?.identityAuthMethod?.data as {
@@ -48,16 +53,41 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
authMethod?: IdentityAuthMethod;
};
- // const authMethod = watch("authMethod");
+ useEffect(() => {
+ if (identityAuthMethodData?.authMethod) {
+ setValue("authMethod", identityAuthMethodData.authMethod);
+ return;
+ }
+
+ setValue("authMethod", IdentityAuthMethod.UNIVERSAL_AUTH);
+ }, [identityAuthMethodData?.authMethod]);
+
+ const authMethod = watch("authMethod");
const renderIdentityAuthForm = () => {
- return (
-
- );
+ switch (identityAuthMethodData?.authMethod ?? authMethod) {
+ case IdentityAuthMethod.AWS_IAM_AUTH: {
+ return (
+
+ );
+ }
+ case IdentityAuthMethod.UNIVERSAL_AUTH: {
+ return (
+
+ );
+ }
+ default: {
+ return ;
+ }
+ }
};
return (
@@ -83,6 +113,7 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
{...field}
onValueChange={(e) => onChange(e)}
className="w-full"
+ isDisabled={!!identityAuthMethodData?.authMethod}
>
{identityAuthMethods.map(({ label, value }) => (
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsIamAuthForm.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsIamAuthForm.tsx
new file mode 100644
index 0000000000..8528a5c30d
--- /dev/null
+++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsIamAuthForm.tsx
@@ -0,0 +1,352 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { yupResolver } from "@hookform/resolvers/yup";
+import * as yup from "yup";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityAwsIamAuth,
+ useGetIdentityAwsIamAuth,
+ useUpdateIdentityAwsIamAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = yup
+ .object({
+ stsEndpoint: yup.string(),
+ allowedPrincipalArns: yup.string(),
+ allowedAccountIds: yup.string(),
+ accessTokenTTL: yup.string().required("Access Token TTL is required"),
+ accessTokenMaxTTL: yup.string().required("Access Max Token TTL is required"),
+ accessTokenNumUsesLimit: yup.string().required("Access Token Max Number of Uses is required"),
+ accessTokenTrustedIps: yup
+ .array(
+ yup.object({
+ ipAddress: yup.string().max(50).required().label("IP Address")
+ })
+ )
+ .min(1)
+ .required()
+ .label("Access Token Trusted IP")
+ })
+ .required();
+
+export type FormData = yup.InferType;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityAwsIamAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityAwsIamAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityAwsIamAuth();
+
+ const { data } = useGetIdentityAwsIamAuth(identityAuthMethodData?.identityId ?? "");
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ stsEndpoint: "https://sts.amazonaws.com/",
+ allowedPrincipalArns: "",
+ allowedAccountIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ stsEndpoint: data.stsEndpoint,
+ allowedPrincipalArns: data.allowedPrincipalArns,
+ allowedAccountIds: data.allowedAccountIds,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ stsEndpoint: "https://sts.amazonaws.com/",
+ allowedPrincipalArns: "",
+ allowedAccountIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ allowedPrincipalArns,
+ allowedAccountIds,
+ stsEndpoint,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ identityId: identityAuthMethodData.identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ stsEndpoint: stsEndpoint || "",
+ allowedPrincipalArns: allowedPrincipalArns || "",
+ allowedAccountIds: allowedAccountIds || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${
+ identityAuthMethodData?.authMethod ? "updated" : "configured"
+ } auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ createNotification({
+ text: `Failed to ${identityAuthMethodData?.authMethod ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+
+ );
+};
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
index 4ab44e947f..e8b16cb5db 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
@@ -15,7 +15,10 @@ import {
} from "@app/components/v2";
import { useOrganization } from "@app/context";
import { useCreateIdentity, useGetOrgRoles, useUpdateIdentity } from "@app/hooks/api";
-import { IdentityAuthMethod, useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
+import {
+ IdentityAuthMethod
+ // useAddIdentityUniversalAuth
+} from "@app/hooks/api/identities";
import { UsePopUpState } from "@app/hooks/usePopUp";
const schema = yup
@@ -40,9 +43,7 @@ type Props = {
handlePopUpToggle: (popUpName: keyof UsePopUpState<["identity"]>, state?: boolean) => void;
};
-export const IdentityModal = ({ popUp, /* handlePopUpOpen, */ handlePopUpToggle }: Props) => {
-
-
+export const IdentityModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
@@ -50,7 +51,7 @@ export const IdentityModal = ({ popUp, /* handlePopUpOpen, */ handlePopUpToggle
const { mutateAsync: createMutateAsync } = useCreateIdentity();
const { mutateAsync: updateMutateAsync } = useUpdateIdentity();
- const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
+ // const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
const {
control,
@@ -113,31 +114,31 @@ export const IdentityModal = ({ popUp, /* handlePopUpOpen, */ handlePopUpToggle
// create
const {
- id: createdId
- // name: createdName,
- // authMethod
+ id: createdId,
+ name: createdName,
+ authMethod
} = await createMutateAsync({
name,
role: role || undefined,
organizationId: orgId
});
- await addMutateAsync({
- organizationId: orgId,
- identityId: createdId,
- clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTTL: 2592000,
- accessTokenMaxTTL: 2592000,
- accessTokenNumUsesLimit: 0
- });
+ // await addMutateAsync({
+ // organizationId: orgId,
+ // identityId: createdId,
+ // clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ // accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ // accessTokenTTL: 2592000,
+ // accessTokenMaxTTL: 2592000,
+ // accessTokenNumUsesLimit: 0
+ // });
handlePopUpToggle("identity", false);
- // handlePopUpOpen("identityAuthMethod", {
- // identityId: createdId,
- // name: createdName,
- // authMethod
- // });
+ handlePopUpOpen("identityAuthMethod", {
+ identityId: createdId,
+ name: createdName,
+ authMethod
+ });
}
createNotification({
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
index 804c2d0542..0ed9cd9a45 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -23,8 +23,6 @@ import { useGetIdentityMembershipOrgs, useGetOrgRoles, useUpdateIdentity } from
import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api/identities";
import { UsePopUpState } from "@app/hooks/usePopUp";
-// TODO: some kind of map
-
type Props = {
handlePopUpOpen: (
popUpName: keyof UsePopUpState<
@@ -44,7 +42,6 @@ type Props = {
};
export const IdentityTable = ({ handlePopUpOpen }: Props) => {
-
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
index d8b4ac0429..af82082a51 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
@@ -63,7 +63,6 @@ export const IdentityUniversalAuthForm = ({
handlePopUpToggle,
identityAuthMethodData
}: Props) => {
-
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
const { subscription } = useSubscription();
@@ -384,7 +383,7 @@ export const IdentityUniversalAuthForm = ({
variant="plain"
onClick={() => handlePopUpToggle("identityAuthMethod", false)}
>
- Cancel
+ {identityAuthMethodData?.authMethod ? "Cancel" : "Skip"}
diff --git a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx
index 2286837267..6fb97063b6 100644
--- a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx
+++ b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx
@@ -1,9 +1,11 @@
+import { useMemo } from "react";
import { Controller, useForm } from "react-hook-form";
import {
faArrowRotateLeft,
faCaretDown,
faCheck,
faClock,
+ faLockOpen,
faPlus,
faTrash
} from "@fortawesome/free-solid-svg-icons";
@@ -44,11 +46,13 @@ import {
import { usePopUp } from "@app/hooks";
import {
TProjectUserPrivilege,
+ useCreateAccessRequest,
useCreateProjectUserAdditionalPrivilege,
useDeleteProjectUserAdditionalPrivilege,
useListProjectUserPrivileges,
useUpdateProjectUserAdditionalPrivilege
} from "@app/hooks/api";
+import { TAccessApprovalPolicy } from "@app/hooks/api/types";
const secretPermissionSchema = z.object({
secretPath: z.string().optional(),
@@ -70,51 +74,105 @@ const secretPermissionSchema = z.object({
])
});
type TSecretPermissionForm = z.infer;
-const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPrivilege }) => {
+export const SpecificPrivilegeSecretForm = ({
+ privilege,
+ policies,
+ onClose
+}: {
+ privilege?: TProjectUserPrivilege;
+ policies?: TAccessApprovalPolicy[];
+ onClose?: () => void;
+}) => {
const { currentWorkspace } = useWorkspace();
+
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
- "deletePrivilege"
+ "deletePrivilege",
+ "requestAccess"
] as const);
const { permission } = useProjectPermission();
- const isMemberEditDisabled = permission.cannot(
- ProjectPermissionActions.Edit,
- ProjectPermissionSub.Member
- );
+ const isMemberEditDisabled =
+ permission.cannot(ProjectPermissionActions.Edit, ProjectPermissionSub.Member) && !!privilege;
const updateUserPrivilege = useUpdateProjectUserAdditionalPrivilege();
const deleteUserPrivilege = useDeleteProjectUserAdditionalPrivilege();
+ const requestAccess = useCreateAccessRequest();
const privilegeForm = useForm({
resolver: zodResolver(secretPermissionSchema),
values: {
- environmentSlug: privilege.permissions?.[0]?.conditions?.environment,
- // secret path will be inside $glob operator
- secretPath: privilege.permissions?.[0]?.conditions?.secretPath?.$glob || "",
- read: privilege.permissions?.some(({ action }) =>
- action.includes(ProjectPermissionActions.Read)
- ),
- edit: privilege.permissions?.some(({ action }) =>
- action.includes(ProjectPermissionActions.Edit)
- ),
- create: privilege.permissions?.some(({ action }) =>
- action.includes(ProjectPermissionActions.Create)
- ),
- delete: privilege.permissions?.some(({ action }) =>
- action.includes(ProjectPermissionActions.Delete)
- ),
- // zod will pick it
- temporaryAccess: privilege
+ ...(privilege
+ ? {
+ environmentSlug: privilege.permissions?.[0]?.conditions?.environment,
+ // secret path will be inside $glob operator
+ secretPath: privilege.permissions?.[0]?.conditions?.secretPath?.$glob || "",
+ read: privilege.permissions?.some(({ action }) =>
+ action.includes(ProjectPermissionActions.Read)
+ ),
+ edit: privilege.permissions?.some(({ action }) =>
+ action.includes(ProjectPermissionActions.Edit)
+ ),
+ create: privilege.permissions?.some(({ action }) =>
+ action.includes(ProjectPermissionActions.Create)
+ ),
+ delete: privilege.permissions?.some(({ action }) =>
+ action.includes(ProjectPermissionActions.Delete)
+ ),
+ // zod will pick it
+ temporaryAccess: privilege
+ }
+ : {
+ environmentSlug: currentWorkspace?.environments?.[0].slug!,
+ read: false,
+ edit: false,
+ create: false,
+ delete: false,
+ temporaryAccess: {
+ isTemporary: false
+ }
+ })
}
});
const temporaryAccessField = privilegeForm.watch("temporaryAccess");
- const selectedEnvironmentSlug = privilegeForm.watch("environmentSlug");
+ const selectedEnvironment = privilegeForm.watch("environmentSlug");
+ const secretPath = privilegeForm.watch("secretPath");
+
+ const readAccess = privilegeForm.watch("read");
+ const createAccess = privilegeForm.watch("create");
+ const editAccess = privilegeForm.watch("edit");
+ const deleteAccess = privilegeForm.watch("delete");
+
+ const accessSelected = readAccess || createAccess || editAccess || deleteAccess;
+
+ const selectablePaths = useMemo(() => {
+ if (!policies) return [];
+ const environmentPolicies = policies.filter(
+ (policy) => policy.environment.slug === selectedEnvironment
+ );
+
+ privilegeForm.setValue("secretPath", "", {
+ shouldValidate: true
+ });
+
+ return [...environmentPolicies.map((policy) => policy.secretPath)];
+ }, [policies, selectedEnvironment]);
+
const isTemporary = temporaryAccessField?.isTemporary;
const isExpired =
temporaryAccessField.isTemporary &&
new Date() > new Date(temporaryAccessField.temporaryAccessEndTime || "");
const handleUpdatePrivilege = async (data: TSecretPermissionForm) => {
+ if (!privilege) {
+ createNotification({
+ type: "error",
+ text: "No privilege to update found.",
+ title: "Error"
+ });
+
+ return;
+ }
+
if (updateUserPrivilege.isLoading) return;
try {
const actions = [
@@ -152,6 +210,15 @@ const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPri
};
const handleDeletePrivilege = async () => {
+ if (!privilege) {
+ createNotification({
+ type: "error",
+ text: "No privilege to delete found.",
+ title: "Error"
+ });
+ return;
+ }
+
if (deleteUserPrivilege.isLoading) return;
try {
await deleteUserPrivilege.mutateAsync({
@@ -170,35 +237,100 @@ const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPri
}
};
+ // This is used for requesting access additional privileges, not directly creating a privilege!
+ const handleRequestAccess = async (data: TSecretPermissionForm) => {
+ if (!policies) return;
+ if (!currentWorkspace) {
+ createNotification({
+ type: "error",
+ text: "No workspace found.",
+ title: "Error"
+ });
+ return;
+ }
+
+ if (!data.secretPath) {
+ createNotification({
+ type: "error",
+ text: "Please select a secret path",
+ title: "Error"
+ });
+ return;
+ }
+
+ const actions = [
+ { action: ProjectPermissionActions.Read, allowed: data.read },
+ { action: ProjectPermissionActions.Create, allowed: data.create },
+ { action: ProjectPermissionActions.Delete, allowed: data.delete },
+ { action: ProjectPermissionActions.Edit, allowed: data.edit }
+ ];
+ const conditions: Record = { environment: data.environmentSlug };
+ if (data.secretPath) {
+ conditions.secretPath = { $glob: data.secretPath };
+ }
+ await requestAccess.mutateAsync({
+ ...data,
+ ...(data.temporaryAccess.isTemporary && {
+ temporaryRange: data.temporaryAccess.temporaryRange
+ }),
+ projectSlug: currentWorkspace.slug,
+ isTemporary: data.temporaryAccess.isTemporary,
+ permissions: actions
+ .filter(({ allowed }) => allowed)
+ .map(({ action }) => ({
+ action,
+ subject: [ProjectPermissionSub.Secrets],
+ conditions
+ }))
+ });
+
+ createNotification({
+ type: "success",
+ text: "Successfully requested access"
+ });
+ privilegeForm.reset();
+ if (onClose) onClose();
+ };
+
+ const handleSubmit = async (data: TSecretPermissionForm) => {
+ if (privilege) {
+ handleUpdatePrivilege(data);
+ } else {
+ handleRequestAccess(data);
+ }
+ };
+
const getAccessLabel = (exactTime = false) => {
if (isExpired) return "Access expired";
if (!temporaryAccessField?.isTemporary) return "Permanent";
- if (exactTime)
+
+ if (exactTime && !policies) {
return `Until ${format(
new Date(temporaryAccessField.temporaryAccessEndTime || ""),
"yyyy-MM-dd HH:mm:ss"
)}`;
+ }
return formatDistance(new Date(temporaryAccessField.temporaryAccessEndTime || ""), new Date());
};
return (
-