mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Add 'RedirectState' table (used by oauth2 login flow); change userSession table from memory to rdbms backend
This commit is contained in:
@ -28,6 +28,8 @@ import com.kingsrook.qqq.backend.core.model.metadata.MetaDataProducerInterface;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.authentication.OAuth2AuthenticationMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.authentication.OAuth2AuthenticationMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.modules.authentication.implementations.metadata.RedirectStateMetaDataProducer;
|
||||||
|
import com.kingsrook.qqq.backend.core.modules.authentication.implementations.model.UserSession;
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -49,15 +51,15 @@ public class OAuth2MetaDataProvider implements MetaDataProducerInterface<QAuthen
|
|||||||
QMetaDataVariableInterpreter qMetaDataVariableInterpreter = new QMetaDataVariableInterpreter();
|
QMetaDataVariableInterpreter qMetaDataVariableInterpreter = new QMetaDataVariableInterpreter();
|
||||||
|
|
||||||
String oauth2BaseUrl = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_BASE_URL}");
|
String oauth2BaseUrl = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_BASE_URL}");
|
||||||
String oauth2TokenUrl = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_TOKEN_URL}");
|
|
||||||
String oauth2ClientId = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_CLIENT_ID}");
|
String oauth2ClientId = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_CLIENT_ID}");
|
||||||
String oauth2ClientSecret = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_CLIENT_SECRET}");
|
String oauth2ClientSecret = qMetaDataVariableInterpreter.interpret("${env.OAUTH2_CLIENT_SECRET}");
|
||||||
|
|
||||||
return (new OAuth2AuthenticationMetaData()
|
return (new OAuth2AuthenticationMetaData()
|
||||||
.withBaseUrl(oauth2BaseUrl)
|
.withBaseUrl(oauth2BaseUrl)
|
||||||
.withTokenUrl(oauth2TokenUrl)
|
|
||||||
.withClientId(oauth2ClientId)
|
.withClientId(oauth2ClientId)
|
||||||
.withClientSecret(oauth2ClientSecret)
|
.withClientSecret(oauth2ClientSecret)
|
||||||
|
.withUserSessionTableName(UserSession.TABLE_NAME)
|
||||||
|
.withRedirectStateTableName(RedirectStateMetaDataProducer.TABLE_NAME)
|
||||||
.withName(NAME));
|
.withName(NAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.Association;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
|
||||||
|
import com.kingsrook.qqq.backend.core.modules.authentication.implementations.metadata.RedirectStateMetaDataProducer;
|
||||||
import com.kingsrook.qqq.backend.core.modules.authentication.implementations.metadata.UserSessionMetaDataProducer;
|
import com.kingsrook.qqq.backend.core.modules.authentication.implementations.metadata.UserSessionMetaDataProducer;
|
||||||
import com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryBackendModule;
|
import com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryBackendModule;
|
||||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep;
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep;
|
||||||
@ -86,6 +87,7 @@ import com.kingsrook.qqq.backend.module.filesystem.local.model.metadata.Filesyst
|
|||||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
|
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
|
||||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
||||||
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
|
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSTableBackendDetails;
|
||||||
import com.kingsrook.sampleapp.dashboard.widgets.PersonsByCreateDateBarChart;
|
import com.kingsrook.sampleapp.dashboard.widgets.PersonsByCreateDateBarChart;
|
||||||
import com.kingsrook.sampleapp.processes.clonepeople.ClonePeopleTransformStep;
|
import com.kingsrook.sampleapp.processes.clonepeople.ClonePeopleTransformStep;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@ -161,7 +163,8 @@ public class SampleMetaDataProvider extends AbstractQQQApplication
|
|||||||
qInstance.addProcess(defineProcessScreenThenSleep());
|
qInstance.addProcess(defineProcessScreenThenSleep());
|
||||||
qInstance.addProcess(defineProcessSimpleThrow());
|
qInstance.addProcess(defineProcessSimpleThrow());
|
||||||
|
|
||||||
qInstance.addTable(new UserSessionMetaDataProducer(MEMORY_BACKEND_NAME).produce(qInstance));
|
qInstance.addTable(setTableBackendNamesForRdbms(new UserSessionMetaDataProducer(RDBMS_BACKEND_NAME).produce(qInstance)));
|
||||||
|
qInstance.addTable(setTableBackendNamesForRdbms(new RedirectStateMetaDataProducer(RDBMS_BACKEND_NAME).produce(qInstance)));
|
||||||
|
|
||||||
MetaDataProducerHelper.processAllMetaDataProducersInPackage(qInstance, SampleMetaDataProvider.class.getPackageName());
|
MetaDataProducerHelper.processAllMetaDataProducersInPackage(qInstance, SampleMetaDataProvider.class.getPackageName());
|
||||||
|
|
||||||
@ -174,6 +177,21 @@ public class SampleMetaDataProvider extends AbstractQQQApplication
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** if rdbms backend uses snake_case table & column names, instead of camelCase
|
||||||
|
** style used for qqq meta-data tableNames and fieldNames, then set those via
|
||||||
|
** this method.
|
||||||
|
*******************************************************************************/
|
||||||
|
private static QTableMetaData setTableBackendNamesForRdbms(QTableMetaData table)
|
||||||
|
{
|
||||||
|
table.setBackendDetails(new RDBMSTableBackendDetails()
|
||||||
|
.withTableName(QInstanceEnricher.inferBackendName(table.getName())));
|
||||||
|
QInstanceEnricher.setInferredFieldBackendNames(table);
|
||||||
|
return (table);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
** for tests, define the same instance as above, but use mock authentication.
|
** for tests, define the same instance as above, but use mock authentication.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
@ -19,6 +19,31 @@
|
|||||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS user_session;
|
||||||
|
CREATE TABLE user_session
|
||||||
|
(
|
||||||
|
id INTEGER AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
create_date TIMESTAMP DEFAULT now(),
|
||||||
|
modify_date TIMESTAMP DEFAULT now(),
|
||||||
|
uuid VARCHAR(40) NOT NULL,
|
||||||
|
access_token MEDIUMTEXT,
|
||||||
|
user_id VARCHAR(100)
|
||||||
|
);
|
||||||
|
ALTER TABLE user_session ADD UNIQUE u_uuid (uuid);
|
||||||
|
ALTER TABLE user_session ADD INDEX i_user_id (user_id);
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS redirect_state;
|
||||||
|
CREATE TABLE redirect_state
|
||||||
|
(
|
||||||
|
id INTEGER AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
create_date TIMESTAMP DEFAULT now(),
|
||||||
|
state VARCHAR(45) NOT NULL,
|
||||||
|
redirect_uri TEXT
|
||||||
|
);
|
||||||
|
ALTER TABLE redirect_state ADD UNIQUE u_state (state);
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS person;
|
DROP TABLE IF EXISTS person;
|
||||||
CREATE TABLE person
|
CREATE TABLE person
|
||||||
(
|
(
|
||||||
|
Reference in New Issue
Block a user