diff --git a/compendium_v2/config.py b/compendium_v2/config.py index 5cf1a69b3527529672a25ed6af7130fd4a14cb0e..490f399a55af8bff0a2d0b82e45ef6ae2fbbd6fa 100644 --- a/compendium_v2/config.py +++ b/compendium_v2/config.py @@ -1,15 +1,25 @@ import json import jsonschema - CONFIG_SCHEMA = { '$schema': 'http://json-schema.org/draft-07/schema#', 'type': 'object', 'properties': { 'SQLALCHEMY_DATABASE_URI': {'type': 'string', 'format': 'database-uri'}, - 'SURVEY_DATABASE_URI': {'type': 'string', 'format': 'database-uri'} + 'SURVEY_DATABASE_URI': {'type': 'string', 'format': 'database-uri'}, + 'oidc': { + 'type': 'object', + 'properties': { + 'client_id': {'type': 'string'}, + 'client_secret': {'type': 'string'}, + 'server_metadata_url': {'type': 'string', 'format': 'uri', 'pattern': '^https?://'}, + }, + 'required': ['client_id', 'client_secret', 'server_metadata_url'], + 'additionalProperties': False + }, + 'SECRET_KEY': {'type': 'string'}, }, - 'required': ['SQLALCHEMY_DATABASE_URI', 'SURVEY_DATABASE_URI'], + 'required': ['SQLALCHEMY_DATABASE_URI', 'SURVEY_DATABASE_URI', 'SECRET_KEY'], 'additionalProperties': False } diff --git a/config-example.json b/config-example.json index f480ed9299e96959a65f543c5dda1514ceef3b4e..a04ee059f8b528a5821205dc507765c0e6751aa8 100644 --- a/config-example.json +++ b/config-example.json @@ -1,4 +1,10 @@ { "SQLALCHEMY_DATABASE_URI": "postgresql://compendium:compendium321@localhost:65000/compendium", - "SURVEY_DATABASE_URI": "" + "SURVEY_DATABASE_URI": "", + "oidc": { + "client_id": "<id>", + "client_secret": "<secret>", + "server_metadata_url": "https://accounts.google.com/.well-known/openid-configuration" + }, + "SECRET_KEY": "changeme" } diff --git a/requirements.txt b/requirements.txt index 2487e32e3c9d72740dc2e346166467f3f2c64bde..fe4111a1bdb186ad37a0fc0feaa05aff6b5ec931 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,8 @@ flask-sqlalchemy~=3.0 openpyxl~=3.1 psycopg2-binary~=2.9 SQLAlchemy~=2.0 +authlib~=1.2 +flask-login~=0.6 pytest~=7.2 pytest-mock~=3.10 diff --git a/setup.py b/setup.py index 87daee04949c447be24b534016e656490c090171..af25355ec89d80135cb677fd89c23291dc71cc61 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,9 @@ setup( 'openpyxl~=3.1', 'psycopg2-binary~=2.9', 'SQLAlchemy~=2.0', - 'sentry-sdk[flask]~=1.23' + 'sentry-sdk[flask]~=1.23', + 'authlib~=1.2', + 'flask-login~=0.6' ], include_package_data=True, diff --git a/test/conftest.py b/test/conftest.py index 1374fe29bac869138c83fdbdc2a3cff95a66636d..8fdd0c86cec496325f0f7e6b8bb5a0b3420ba215 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -17,7 +17,8 @@ def _test_data_csv(filename): def dummy_config(): yield { 'SQLALCHEMY_DATABASE_URI': 'sqlite://', - 'SURVEY_DATABASE_URI': 'sqlite:///' + 'SURVEY_DATABASE_URI': 'sqlite:///', + 'SECRET_KEY': 'testsecret123' }