From be094127550a7e8ce7c554d3742abe72e1ec57d5 Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Thu, 27 Apr 2023 10:31:13 -0500 Subject: [PATCH] CTLE-421: checkpoint commit of api key story so that CTL test coverage can be worked on instead --- qqq-backend-core/pom.xml | 18 ++++- .../AbstractPreInsertCustomizer.java | 65 +++++++++++++++++++ .../actions/customizers/TableCustomizers.java | 8 +-- .../core/actions/tables/InsertAction.java | 8 +++ .../Auth0AuthenticationModule.java | 5 +- 5 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/AbstractPreInsertCustomizer.java diff --git a/qqq-backend-core/pom.xml b/qqq-backend-core/pom.xml index 04d00d1a..d6fc2da1 100644 --- a/qqq-backend-core/pom.xml +++ b/qqq-backend-core/pom.xml @@ -56,6 +56,10 @@ software.amazon.awssdk quicksight + + software.amazon.awssdk + apigateway + com.amazonaws aws-java-sdk-secretsmanager @@ -100,8 +104,18 @@ com.auth0 - mvc-auth-commons - 1.9.2 + auth0 + 2.1.0 + + + com.auth0 + java-jwt + 4.4.0 + + + com.auth0 + jwks-rsa + 0.22.0 io.github.cdimascio diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/AbstractPreInsertCustomizer.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/AbstractPreInsertCustomizer.java new file mode 100644 index 00000000..1b3ab771 --- /dev/null +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/AbstractPreInsertCustomizer.java @@ -0,0 +1,65 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.kingsrook.qqq.backend.core.actions.customizers; + + +import java.util.List; +import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput; +import com.kingsrook.qqq.backend.core.model.data.QRecord; + + +/******************************************************************************* + ** + *******************************************************************************/ +public abstract class AbstractPreInsertCustomizer +{ + protected InsertInput insertInput; + + + + /******************************************************************************* + ** + *******************************************************************************/ + public abstract List apply(List records); + + + + /******************************************************************************* + ** Getter for insertInput + ** + *******************************************************************************/ + public InsertInput getInsertInput() + { + return insertInput; + } + + + + /******************************************************************************* + ** Setter for insertInput + ** + *******************************************************************************/ + public void setInsertInput(InsertInput insertInput) + { + this.insertInput = insertInput; + } +} diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/TableCustomizers.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/TableCustomizers.java index 2d2d6621..548b18bf 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/TableCustomizers.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/customizers/TableCustomizers.java @@ -29,16 +29,10 @@ package com.kingsrook.qqq.backend.core.actions.customizers; ** Works with TableCustomizer (singular version of this name) objects, during ** instance validation, to provide validation of the referenced code (and to ** make such validation from sub-backend-modules possible in the future). - ** - ** The idea of the 3rd argument here is to provide a way that we can enforce - ** the type-parameters for the custom code. E.g., if it's a Function - how - ** can we check at run-time that the type-params are correct? We couldn't find - ** how to do this "reflectively", so we can instead try to run the custom code, - ** passing it objects of the type that this customizer expects, and a validation - ** error will raise upon ClassCastException... This maybe could improve! *******************************************************************************/ public enum TableCustomizers { + PRE_INSERT_RECORD(new TableCustomizer("preInsertRecord", AbstractPreInsertCustomizer.class)), POST_QUERY_RECORD(new TableCustomizer("postQueryRecord", AbstractPostQueryCustomizer.class)), POST_INSERT_RECORD(new TableCustomizer("postInsertRecord", AbstractPostInsertCustomizer.class)); diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/tables/InsertAction.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/tables/InsertAction.java index 5cbbb2ad..8a532325 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/tables/InsertAction.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/tables/InsertAction.java @@ -38,6 +38,7 @@ import com.kingsrook.qqq.backend.core.actions.audits.DMLAuditAction; import com.kingsrook.qqq.backend.core.actions.automation.AutomationStatus; import com.kingsrook.qqq.backend.core.actions.automation.RecordAutomationStatusUpdater; import com.kingsrook.qqq.backend.core.actions.customizers.AbstractPostInsertCustomizer; +import com.kingsrook.qqq.backend.core.actions.customizers.AbstractPreInsertCustomizer; import com.kingsrook.qqq.backend.core.actions.customizers.QCodeLoader; import com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizers; import com.kingsrook.qqq.backend.core.actions.tables.helpers.UniqueKeyHelper; @@ -86,6 +87,7 @@ public class InsertAction extends AbstractQActionFunction preInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPreInsertCustomizer.class, table, TableCustomizers.PRE_INSERT_RECORD.getRole()); Optional postInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPostInsertCustomizer.class, table, TableCustomizers.POST_INSERT_RECORD.getRole()); setAutomationStatusField(insertInput); @@ -97,6 +99,12 @@ public class InsertAction extends AbstractQActionFunction errors = insertOutput.getRecords().stream().flatMap(r -> r.getErrors().stream()).toList(); if(CollectionUtils.nullSafeHasContents(errors)) diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/modules/authentication/implementations/Auth0AuthenticationModule.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/modules/authentication/implementations/Auth0AuthenticationModule.java index 0f6550a8..a0279503 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/modules/authentication/implementations/Auth0AuthenticationModule.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/modules/authentication/implementations/Auth0AuthenticationModule.java @@ -47,6 +47,7 @@ import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.exceptions.JWTVerificationException; import com.auth0.jwt.exceptions.TokenExpiredException; import com.auth0.jwt.interfaces.DecodedJWT; +import com.auth0.net.Response; import com.kingsrook.qqq.backend.core.actions.tables.InsertAction; import com.kingsrook.qqq.backend.core.actions.tables.QueryAction; import com.kingsrook.qqq.backend.core.context.QContext; @@ -297,12 +298,12 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface ///////////////////////////////////// // call auth0 with a login request // ///////////////////////////////////// - TokenHolder result = auth.login(credentials.split(":")[0], credentials.split(":")[1].toCharArray()) + Response result = auth.login(credentials.split(":")[0], credentials.split(":")[1].toCharArray()) .setScope("openid email nickname") .setAudience(metaData.getAudience()) .execute(); - return (result.getAccessToken()); + return (result.getBody().getAccessToken()); }