Skip to content

Commit

Permalink
Merge branch 'main' into topics/admin-clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelax authored Sep 6, 2023
2 parents 4c6e36a + eef6376 commit 07fb319
Show file tree
Hide file tree
Showing 22 changed files with 858 additions and 2,745 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
storage
.github
2 changes: 1 addition & 1 deletion .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: 18
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
scope: '@DMGT-TECH'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: 18
cache: 'npm'
cache-dependency-path: |
database/package-lock.json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ This list of links is written for developers that would like to contribute to Th

## What is in progress

* [ ] Implement Groups functionality (see https://github.com/DMGT-TECH/the-usher-server/issues/2)
* [ ] Implement Groups functionality (see <https://github.com/DMGT-TECH/the-usher-server/issues/2>)

## What could be added

Expand Down
18 changes: 15 additions & 3 deletions database/layer/admin-personarole.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,21 @@ async function insertPersonaRole (tenantName, issClaim, subClaim, userContext, c
}

async function deletePersonaRole (tenantName, issClaim, subClaim, userContext, clientId, rolename) {
const sql = `DELETE FROM usher.personaroles pr
WHERE EXISTS (SELECT t.key FROM usher.tenants t JOIN usher.personas p ON (t.key = p.tenantkey) WHERE t.key = pr.tenantkey AND t.name = $1 AND t.iss_claim = $2 AND p.sub_claim = $3 AND p.user_context = $4)
AND EXISTS (SELECT c.key FROM usher.clients c JOIN usher.roles r ON r.clientkey = c.key WHERE r.key = pr.rolekey AND c.client_id = $5 AND r.name = $6 AND r.key = rp.rolekey)`
const sql = `DELETE FROM usher.personaroles
WHERE (personakey, rolekey) IN (
SELECT p.KEY, r.KEY
FROM usher.roles r
JOIN usher.clients c ON (c.key = r.clientkey)
JOIN usher.tenantclients tc ON (c.key = tc.clientkey)
JOIN usher.tenants t ON (t.key = tc.tenantkey)
JOIN usher.personas p ON (p.tenantkey = t.key)
WHERE t.name = $1
AND t.iss_claim = $2
AND p.sub_claim = $3
AND p.user_context = $4
AND c.client_id = $5
AND r.name = $6
);`
const sqlParams = [tenantName, issClaim, subClaim, userContext, clientId, rolename]
try {
const results = await pool.query(sql, sqlParams)
Expand Down
147 changes: 89 additions & 58 deletions database/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dmgt-tech/the-usher-server-database",
"version": "1.6.0",
"version": "1.6.1",
"description": "Database layer for TheUsher",
"scripts": {
"test": "mocha",
Expand All @@ -16,15 +16,15 @@
},
"repository": {
"type": "git",
"url": "git@github.com:DMGT-TECH/the-usher-server.git",
"url": "https://github.com/DMGT-TECH/the-usher-server.git",
"directory": "database"
},
"author": "",
"license": "MIT",
"dependencies": {
"dotenv": "16.0.3",
"knex": "2.3.0",
"pg": "8.8.0",
"dotenv": "16.3.1",
"knex": "2.5.1",
"pg": "8.11.3",
"uuid": "9.0.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion database/test/db-insert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ describe('Insert Update and Delete tests', function () {
it('Should insert a single relationship', async function () {
const insertResult = await postPersonaRoles.insertPersonaRole('dummy_tenant', 'https://dummytenant', 'dummy_subclaim', '', 'dummy_client', 'dummy_role:dummyA')
assert.strictEqual(insertResult, 'Insert successful')
await postPersonaRoles.deletePersonaRole('dummy_tenant', 'https://dummytenant', 'dummy_subclaim', '', 'dummy_client', 'dummy_role:dummyA')
const deleteResult = await postPersonaRoles.deletePersonaRole('dummy_tenant', 'https://dummytenant', 'dummy_subclaim', '', 'dummy_client', 'dummy_role:dummyA')
assert.strictEqual(deleteResult, 'Delete successful')
})
it('Should fail to insert where persona tenant is different than role and client tenant', async function () {
const insertResult = await postPersonaRoles.insertPersonaRole('dummy_tenant', 'https://dummytenant', 'dummy_subclaim', '', 'the-usher', 'the-usher:usher-admin')
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
aliases:
- usher-db
mockidentityprovider-server:
image: node:14.21.1-alpine
image: node:18-alpine
expose: [3002]
entrypoint: ["sh", "/app/scripts/run_for_development_mockidentityprovider.sh"]
ports:
Expand Down
Loading

0 comments on commit 07fb319

Please sign in to comment.