From 1e2896d750deea7d177e611a27cd1761c9eb39b3 Mon Sep 17 00:00:00 2001 From: Andreas Hubel <40266+saerdnaer@users.noreply.github.com> Date: Sat, 17 Aug 2024 03:38:31 +0200 Subject: [PATCH 1/4] fix "Invalid array length" --- api/src/services/authorization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/services/authorization.ts b/api/src/services/authorization.ts index 9c623584b..2caa6c567 100644 --- a/api/src/services/authorization.ts +++ b/api/src/services/authorization.ts @@ -623,7 +623,7 @@ export class AuthorizationService { for (let i = 0; i < originalItems.length; i++) { const originalItem: Item = originalItems[i]!; - const emptyItemsToAdd = originalItem[fieldKey].length - field.update?.length - field.delete?.length; + const emptyItemsToAdd = field.update?.length - originalItem[fieldKey].length - field.delete?.length; const finalArrayToValidate = arrayToValidate.concat(Array(emptyItemsToAdd).fill({})); // validate partial items until the last key From 1080d94f3c347d361eb7ab649d861dfb07e606b9 Mon Sep 17 00:00:00 2001 From: Andreas Hubel <40266+saerdnaer@users.noreply.github.com> Date: Sat, 17 Aug 2024 03:55:56 +0200 Subject: [PATCH 2/4] chore: add example for Authentik SSP https://goauthentik.io --- docs/self-hosted/sso-examples.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/self-hosted/sso-examples.md b/docs/self-hosted/sso-examples.md index a97656505..9fcc70009 100644 --- a/docs/self-hosted/sso-examples.md +++ b/docs/self-hosted/sso-examples.md @@ -91,6 +91,18 @@ AUTH_KEYCLOAK_ISSUER_URL="http:///realms/ Date: Sat, 17 Aug 2024 03:58:56 +0200 Subject: [PATCH 3/4] chore: add auth_data null fallback --- api/src/auth/drivers/oauth2.ts | 2 +- api/src/auth/drivers/openid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/auth/drivers/oauth2.ts b/api/src/auth/drivers/oauth2.ts index 27d7b91c6..f1951cf40 100644 --- a/api/src/auth/drivers/oauth2.ts +++ b/api/src/auth/drivers/oauth2.ts @@ -148,7 +148,7 @@ export class OAuth2AuthDriver extends BaseOAuthDriver { email: email, external_identifier: identifier, role: this.config['defaultRoleId'], - auth_data: tokenSet.refresh_token && JSON.stringify({ refreshToken: tokenSet.refresh_token }), + auth_data: tokenSet.refresh_token ? JSON.stringify({ refreshToken: tokenSet.refresh_token }) : null, }; return [tokenSet, userInfo, userPayload]; diff --git a/api/src/auth/drivers/openid.ts b/api/src/auth/drivers/openid.ts index af1f594aa..d15fdead1 100644 --- a/api/src/auth/drivers/openid.ts +++ b/api/src/auth/drivers/openid.ts @@ -179,7 +179,7 @@ export class OpenIDAuthDriver extends BaseOAuthDriver { email: email, external_identifier: identifier, role: this.config['defaultRoleId'], - auth_data: tokenSet.refresh_token && JSON.stringify({ refreshToken: tokenSet.refresh_token }), + auth_data: tokenSet.refresh_token ? JSON.stringify({ refreshToken: tokenSet.refresh_token }) : null, }; return [tokenSet, userInfo, userPayload]; From 644180524458978b8709fbf45eeb496274c090dc Mon Sep 17 00:00:00 2001 From: Andreas Hubel <40266+saerdnaer@users.noreply.github.com> Date: Sat, 17 Aug 2024 04:01:09 +0200 Subject: [PATCH 4/4] chore: add fallback value for ip to fix `Cannot read properties of undefined (reading 'startsWith')` --- api/src/utils/get-ip-from-req.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/utils/get-ip-from-req.ts b/api/src/utils/get-ip-from-req.ts index 75d725546..18c12f695 100644 --- a/api/src/utils/get-ip-from-req.ts +++ b/api/src/utils/get-ip-from-req.ts @@ -4,7 +4,7 @@ import env from '../env.js'; import logger from '../logger.js'; export function getIPFromReq(req: Request): string { - let ip = req.ip; + let ip = req.ip || ''; if (env['IP_CUSTOM_HEADER']) { const customIPHeaderValue = req.get(env['IP_CUSTOM_HEADER']) as unknown;