diff --git a/.env.example b/.env.example index 32c346ea500244cc49ba843b813d70020f2cef86..b8994459cdcc9e5772b28b349bb735d6ceb441dd 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ BROKER_PASSWORD=fda WEBSITE=http://example.com MAIL_FROM=Database Repository <noreply@example.com> MAIL_REPLY_TO=Admin <somebody@example.com> +MAIL_VERIFY=true JWT_ISSUER=dbrepo JWT_SECRET=secret JWT_EXPIRATION=86400000 diff --git a/.jupyter/tuple_publish.ipynb b/.jupyter/tuple_publish.ipynb index ab6f31b99c1fc38064a6090a1355a8027fb60e19..837dfb2c844c4f88e28ce828adcb3350d4fd5dd2 100644 --- a/.jupyter/tuple_publish.ipynb +++ b/.jupyter/tuple_publish.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" @@ -25,6 +25,7 @@ "source": [ "import time\n", "import csv\n", + "import pika\n", "from api_broker.BrokerServiceClient import BrokerServiceClient\n", "from api_authentication.api.authentication_endpoint_api import AuthenticationEndpointApi\n", "from api_authentication.api.user_endpoint_api import UserEndpointApi\n", @@ -46,13 +47,13 @@ "identifier = IdentifierEndpointApi()\n", "persistence = PersistenceEndpointApi()\n", "\n", - "username = \"user\"\n", - "password = \"user\"" + "username = \"test\"\n", + "password = \"test\"" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "metadata": { "pycharm": { "name": "#%%\n" @@ -79,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "metadata": { "pycharm": { "name": "#%%\n" @@ -101,9 +102,10 @@ " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'}\n" + " 'username': 'test'}\n" ] } ], @@ -117,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 10, "metadata": { "pycharm": { "name": "#%%\n" @@ -128,22 +130,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'created': datetime.datetime(2022, 7, 22, 2, 3, 19, 16000, tzinfo=tzutc()),\n", + "{'created': datetime.datetime(2022, 8, 12, 18, 13, 23, 859000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", - " 'hash': '34a7cecef222acb34c917ddc01450c14feaa0d5e49ecf15c1bf8b33efc218e79',\n", + " 'username': 'test'},\n", + " 'hash': '1785640e50886bbb9769827a63c564270b1d682214e12c3fee5a4678ff95860b',\n", " 'id': 1,\n", " 'internal_name': 'fda-userdb-airquality',\n", " 'is_public': None,\n", @@ -163,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 11, "metadata": { "pycharm": { "name": "#%%\n" @@ -174,22 +171,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'created': datetime.datetime(2022, 7, 22, 2, 3, 19, 16000, tzinfo=tzutc()),\n", + "{'created': datetime.datetime(2022, 8, 12, 18, 13, 23, 859000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", - " 'hash': '34a7cecef222acb34c917ddc01450c14feaa0d5e49ecf15c1bf8b33efc218e79',\n", + " 'username': 'test'},\n", + " 'hash': '1785640e50886bbb9769827a63c564270b1d682214e12c3fee5a4678ff95860b',\n", " 'id': 1,\n", " 'internal_name': 'fda-userdb-airquality',\n", " 'is_public': None,\n", @@ -207,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 12, "metadata": { "pycharm": { "name": "#%%\n" @@ -218,41 +210,31 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'container': {'created': datetime.datetime(2022, 7, 22, 2, 3, 19, 16000, tzinfo=tzutc()),\n", + "{'container': {'created': datetime.datetime(2022, 8, 12, 18, 13, 23, 859000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", - " 'hash': '34a7cecef222acb34c917ddc01450c14feaa0d5e49ecf15c1bf8b33efc218e79',\n", + " 'username': 'test'},\n", + " 'hash': '1785640e50886bbb9769827a63c564270b1d682214e12c3fee5a4678ff95860b',\n", " 'id': 1,\n", " 'internal_name': 'fda-userdb-airquality',\n", " 'is_public': None,\n", " 'name': 'Airquality'},\n", - " 'created': datetime.datetime(2022, 7, 22, 2, 3, 25, 678000, tzinfo=tzutc()),\n", + " 'created': datetime.datetime(2022, 8, 12, 18, 13, 30, 103000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", + " 'username': 'test'},\n", " 'description': 'Airquality',\n", " 'engine': 'mariadb:10.5',\n", " 'id': 1,\n", @@ -273,166 +255,82 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 13, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'contact': None,\n", - " 'container': {'created': datetime.datetime(2022, 7, 22, 2, 3, 19, 16000, tzinfo=tzutc()),\n", + " 'container': {'created': datetime.datetime(2022, 8, 12, 18, 13, 23, 859000, tzinfo=tzutc()),\n", " 'databases': None,\n", - " 'hash': '34a7cecef222acb34c917ddc01450c14feaa0d5e49ecf15c1bf8b33efc218e79',\n", + " 'hash': '1785640e50886bbb9769827a63c564270b1d682214e12c3fee5a4678ff95860b',\n", " 'id': 1,\n", - " 'image': {'compiled': None,\n", - " 'date_formats': [{'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 956000, tzinfo=tzutc()),\n", - " 'database_format': '%Y-%c-%d',\n", - " 'example': '2022-01-30',\n", - " 'has_time': False,\n", - " 'id': 1,\n", - " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 963000, tzinfo=tzutc()),\n", - " 'database_format': '%d.%c.%Y',\n", - " 'example': '30.01.2022',\n", - " 'has_time': False,\n", - " 'id': 2,\n", - " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 966000, tzinfo=tzutc()),\n", - " 'database_format': '%d.%c.%y',\n", - " 'example': '30.01.22',\n", - " 'has_time': False,\n", - " 'id': 3,\n", - " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 970000, tzinfo=tzutc()),\n", - " 'database_format': '%c/%d/%Y',\n", - " 'example': '01/30/2022',\n", - " 'has_time': False,\n", - " 'id': 4,\n", - " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 974000, tzinfo=tzutc()),\n", - " 'database_format': '%c/%d/%y',\n", - " 'example': '01/30/22',\n", - " 'has_time': False,\n", - " 'id': 5,\n", - " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 977000, tzinfo=tzutc()),\n", - " 'database_format': '%Y-%c-%d '\n", - " '%H:%i:%S.%f',\n", - " 'example': '2022-01-30 13:44:25.0',\n", - " 'has_time': True,\n", - " 'id': 6,\n", - " 'unix_format': 'yyyy-MM-dd '\n", - " 'HH:mm:ss.SSSSSS'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 980000, tzinfo=tzutc()),\n", - " 'database_format': '%Y-%c-%d '\n", - " '%H:%i:%S',\n", - " 'example': '2022-01-30 13:44:25',\n", - " 'has_time': True,\n", - " 'id': 7,\n", - " 'unix_format': 'yyyy-MM-dd '\n", - " 'HH:mm:ss'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 984000, tzinfo=tzutc()),\n", - " 'database_format': '%d.%c.%Y '\n", - " '%H:%i:%S',\n", - " 'example': '30.01.2022 13:44:25',\n", - " 'has_time': True,\n", - " 'id': 8,\n", - " 'unix_format': 'dd.MM.yyyy '\n", - " 'HH:mm:ss'}],\n", - " 'default_port': 3306,\n", - " 'dialect': 'org.hibernate.dialect.MariaDBDialect',\n", - " 'driver_class': 'org.mariadb.jdbc.Driver',\n", - " 'environment': [{'iid': 1,\n", - " 'key': 'ROOT',\n", - " 'type': 'PRIVILEGED_USERNAME',\n", - " 'value': 'root'},\n", - " {'iid': 1,\n", - " 'key': 'MARIADB_ROOT_PASSWORD',\n", - " 'type': 'PRIVILEGED_PASSWORD',\n", - " 'value': 'mariadb'},\n", - " {'iid': 1,\n", - " 'key': 'MARIADB_USER',\n", - " 'type': 'USERNAME',\n", - " 'value': 'mariadb'},\n", - " {'iid': 1,\n", - " 'key': 'MARIADB_PASSWORD',\n", - " 'type': 'PASSWORD',\n", - " 'value': 'mariadb'}],\n", - " 'hash': None,\n", - " 'id': 1,\n", - " 'jdbc_method': 'mariadb',\n", - " 'repository': 'mariadb',\n", - " 'size': None,\n", - " 'tag': '10.5'},\n", + " 'image': {'id': 1, 'repository': 'mariadb', 'tag': '10.5'},\n", " 'internal_name': 'fda-userdb-airquality',\n", " 'ip_address': None,\n", " 'is_public': None,\n", " 'name': 'Airquality',\n", - " 'port': 12888,\n", + " 'port': 30511,\n", " 'state': None},\n", - " 'created': datetime.datetime(2022, 7, 22, 2, 3, 25, 678000, tzinfo=tzutc()),\n", + " 'created': datetime.datetime(2022, 8, 12, 18, 13, 30, 103000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", + " 'username': 'test'},\n", " 'deleted': None,\n", " 'description': 'Airquality',\n", " 'exchange': 'airquality',\n", " 'id': 1,\n", " 'image': {'compiled': None,\n", - " 'date_formats': [{'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 956000, tzinfo=tzutc()),\n", + " 'date_formats': [{'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 279000, tzinfo=tzutc()),\n", " 'database_format': '%Y-%c-%d',\n", " 'example': '2022-01-30',\n", " 'has_time': False,\n", " 'id': 1,\n", " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 963000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 287000, tzinfo=tzutc()),\n", " 'database_format': '%d.%c.%Y',\n", " 'example': '30.01.2022',\n", " 'has_time': False,\n", " 'id': 2,\n", " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 966000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 290000, tzinfo=tzutc()),\n", " 'database_format': '%d.%c.%y',\n", " 'example': '30.01.22',\n", " 'has_time': False,\n", " 'id': 3,\n", " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 970000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 293000, tzinfo=tzutc()),\n", " 'database_format': '%c/%d/%Y',\n", " 'example': '01/30/2022',\n", " 'has_time': False,\n", " 'id': 4,\n", " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 974000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 296000, tzinfo=tzutc()),\n", " 'database_format': '%c/%d/%y',\n", " 'example': '01/30/22',\n", " 'has_time': False,\n", " 'id': 5,\n", " 'unix_format': 'yyyy-MM-dd'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 977000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 299000, tzinfo=tzutc()),\n", " 'database_format': '%Y-%c-%d %H:%i:%S.%f',\n", " 'example': '2022-01-30 13:44:25.0',\n", " 'has_time': True,\n", " 'id': 6,\n", " 'unix_format': 'yyyy-MM-dd HH:mm:ss.SSSSSS'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 980000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 301000, tzinfo=tzutc()),\n", " 'database_format': '%Y-%c-%d %H:%i:%S',\n", " 'example': '2022-01-30 13:44:25',\n", " 'has_time': True,\n", " 'id': 7,\n", " 'unix_format': 'yyyy-MM-dd HH:mm:ss'},\n", - " {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 984000, tzinfo=tzutc()),\n", + " {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 303000, tzinfo=tzutc()),\n", " 'database_format': '%d.%c.%Y %H:%i:%S',\n", " 'example': '30.01.2022 13:44:25',\n", " 'has_time': True,\n", @@ -468,7 +366,7 @@ " 'language': None,\n", " 'license': None,\n", " 'name': 'Airquality',\n", - " 'publication': None,\n", + " 'publication_year': 2022,\n", " 'publisher': None,\n", " 'subjects': [],\n", " 'tables': []}\n" @@ -489,7 +387,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 15, "metadata": { "pycharm": { "name": "#%%\n" @@ -500,41 +398,31 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'container': {'created': datetime.datetime(2022, 7, 22, 2, 3, 19, 16000, tzinfo=tzutc()),\n", + "{'container': {'created': datetime.datetime(2022, 8, 12, 18, 13, 23, 859000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", - " 'hash': '34a7cecef222acb34c917ddc01450c14feaa0d5e49ecf15c1bf8b33efc218e79',\n", + " 'username': 'test'},\n", + " 'hash': '1785640e50886bbb9769827a63c564270b1d682214e12c3fee5a4678ff95860b',\n", " 'id': 1,\n", " 'internal_name': 'fda-userdb-airquality',\n", " 'is_public': None,\n", " 'name': 'Airquality'},\n", - " 'created': datetime.datetime(2022, 7, 22, 2, 3, 25, 678000, tzinfo=tzutc()),\n", + " 'created': datetime.datetime(2022, 8, 12, 18, 13, 30, 103000, tzinfo=tzutc()),\n", " 'creator': {'affiliation': None,\n", - " 'authorities': None,\n", - " 'containers': None,\n", - " 'databases': None,\n", - " 'email': 'martin.weise@tuwien.ac.at',\n", - " 'email_verified': False,\n", " 'firstname': 'Martin',\n", " 'id': 2,\n", - " 'identifiers': None,\n", " 'lastname': 'Weise',\n", " 'orcid': None,\n", + " 'theme_dark': False,\n", " 'titles_after': None,\n", " 'titles_before': None,\n", - " 'username': 'user'},\n", + " 'username': 'test'},\n", " 'description': 'This dataset includes daily values from 1983 to the current '\n", " 'day, divided into annual files. This includes the maximum '\n", " 'hourly average and the number of times the hourly average '\n", @@ -562,14 +450,14 @@ " },\n", " \"language\": \"en\",\n", " \"is_public\": False,\n", - " \"publication\": \"2022-07-19\"\n", + " \"publication_year\": \"2022\"\n", "}, container_id, database_id)\n", "print(response)" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 16, "metadata": { "pycharm": { "name": "#%%\n" @@ -580,7 +468,18 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'id': 1, 'internal_name': 'airquality', 'name': 'Airquality'}\n" + "{'creator': {'affiliation': None,\n", + " 'firstname': 'Martin',\n", + " 'id': 2,\n", + " 'lastname': 'Weise',\n", + " 'orcid': None,\n", + " 'theme_dark': False,\n", + " 'titles_after': None,\n", + " 'titles_before': None,\n", + " 'username': 'test'},\n", + " 'id': 1,\n", + " 'internal_name': 'airquality',\n", + " 'name': 'Airquality'}\n" ] } ], @@ -640,7 +539,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 17, "metadata": { "pycharm": { "name": "#%%\n" @@ -671,7 +570,7 @@ " 'check_expression': None,\n", " 'column_concept': None,\n", " 'column_type': 'date',\n", - " 'date_format': {'created_at': datetime.datetime(2022, 7, 22, 1, 52, 58, 956000, tzinfo=tzutc()),\n", + " 'date_format': {'created_at': datetime.datetime(2022, 8, 12, 18, 4, 42, 279000, tzinfo=tzutc()),\n", " 'database_format': '%Y-%c-%d',\n", " 'example': '2022-01-30',\n", " 'has_time': False,\n", @@ -784,7 +683,16 @@ " 'name': 'Status',\n", " 'references': None,\n", " 'unique': False}],\n", - " 'created': datetime.datetime(2022, 7, 22, 2, 3, 27, 332000, tzinfo=tzutc()),\n", + " 'created': datetime.datetime(2022, 8, 12, 18, 14, 31, 839000, tzinfo=tzutc()),\n", + " 'creator': {'affiliation': None,\n", + " 'firstname': 'Martin',\n", + " 'id': 2,\n", + " 'lastname': 'Weise',\n", + " 'orcid': None,\n", + " 'theme_dark': False,\n", + " 'titles_after': None,\n", + " 'titles_before': None,\n", + " 'username': 'test'},\n", " 'description': 'Airquality in Zürich, Switzerland',\n", " 'id': 1,\n", " 'internal_name': 'airquality',\n", @@ -801,7 +709,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 18, "metadata": { "pycharm": { "name": "#%%\n" @@ -834,35 +742,18 @@ "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'NOx', 'interval': 'h1', 'unit': 'ppb', 'value': '36.55', 'status': 'tentative'}\n", "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'NO', 'interval': 'h1', 'unit': 'µg/m3', 'value': '17.2', 'status': 'tentative'}\n", "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'NO2', 'interval': 'h1', 'unit': 'µg/m3', 'value': '43.51', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'O3', 'interval': 'h1', 'unit': 'µg/m3', 'value': '4.38', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'PM10', 'interval': 'h1', 'unit': 'µg/m3', 'value': '74.05', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'PM2.5', 'interval': 'h1', 'unit': 'µg/m3', 'value': '74.11', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'CO', 'interval': 'h1', 'unit': 'mg/m3', 'value': '0.4', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'SO2', 'interval': 'h1', 'unit': 'µg/m3', 'value': '5.02', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'NOx', 'interval': 'h1', 'unit': 'ppb', 'value': '35.47', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'NO', 'interval': 'h1', 'unit': 'µg/m3', 'value': '16.28', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'NO2', 'interval': 'h1', 'unit': 'µg/m3', 'value': '42.88', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'O3', 'interval': 'h1', 'unit': 'µg/m3', 'value': '5.34', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'PM10', 'interval': 'h1', 'unit': 'µg/m3', 'value': '140.15', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Stampfenbachstrasse', 'parameter': 'PM2.5', 'interval': 'h1', 'unit': 'µg/m3', 'value': '118.87', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'NOx', 'interval': 'h1', 'unit': 'ppb', 'value': '39.43', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'NO', 'interval': 'h1', 'unit': 'µg/m3', 'value': '20.8', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'NO2', 'interval': 'h1', 'unit': 'µg/m3', 'value': '43.51', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'O3', 'interval': 'h1', 'unit': 'µg/m3', 'value': '6.93', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'PM10', 'interval': 'h1', 'unit': 'µg/m3', 'value': '118.95', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Schimmelstrasse', 'parameter': 'PM2.5', 'interval': 'h1', 'unit': 'µg/m3', 'value': '102.54', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Heubeeribüel', 'parameter': 'NOx', 'interval': 'h1', 'unit': 'ppb', 'value': '5.31', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Heubeeribüel', 'parameter': 'NO', 'interval': 'h1', 'unit': 'µg/m3', 'value': '0.52', 'status': 'tentative'}\n", - "{'date': '2021-01-01', 'location': 'Heubeeribüel', 'parameter': 'NO2', 'interval': 'h1', 'unit': 'µg/m3', 'value': '9.36', 'status': 'tentative'}\n" + "{'date': '2021-01-01', 'location': 'Rosengartenstrasse', 'parameter': 'O3', 'interval': 'h1', 'unit': 'µg/m3', 'value': '4.38', 'status': 'tentative'}\n" ] }, { - "name": "stderr", - "output_type": "stream", - "text": [ - "\n", - "KeyboardInterrupt\n", - "\n" + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mKeyboardInterrupt\u001B[0m Traceback (most recent call last)", + "Input \u001B[0;32mIn [18]\u001B[0m, in \u001B[0;36m<cell line: 3>\u001B[0;34m()\u001B[0m\n\u001B[1;32m 6\u001B[0m payload \u001B[38;5;241m=\u001B[39m {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mdate\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m0\u001B[39m], \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mlocation\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m1\u001B[39m], \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mparameter\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m2\u001B[39m], \u001B[38;5;124m'\u001B[39m\u001B[38;5;124minterval\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m3\u001B[39m], \u001B[38;5;124m'\u001B[39m\u001B[38;5;124munit\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m4\u001B[39m],\n\u001B[1;32m 7\u001B[0m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mvalue\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m5\u001B[39m], \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstatus\u001B[39m\u001B[38;5;124m'\u001B[39m: row[\u001B[38;5;241m6\u001B[39m]}\n\u001B[1;32m 8\u001B[0m response \u001B[38;5;241m=\u001B[39m broker\u001B[38;5;241m.\u001B[39msend(payload)\n\u001B[0;32m----> 9\u001B[0m \u001B[43mtime\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43msleep\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 10\u001B[0m \u001B[38;5;28mprint\u001B[39m(payload)\n", + "\u001B[0;31mKeyboardInterrupt\u001B[0m: " ] } ], diff --git a/docker-compose.demo.yml b/docker-compose.demo.yml index 70afbae18727f6dc88363c7d39807ecf8c10ba09..9e9818489f53c23064ffa25c27269d224e2f655c 100644 --- a/docker-compose.demo.yml +++ b/docker-compose.demo.yml @@ -148,6 +148,7 @@ services: SMTP_PORT: ${SMTP_PORT} SMTP_USERNAME: ${SMTP_USERNAME} SMTP_PASSWORD: ${SMTP_PASSWORD} + MAIL_VERIFY: ${MAIL_VERIFY} depends_on: discovery-service: condition: service_healthy diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 807443937641f44657838ffb1510105b70a72a62..23c64f2130cd6829f374492fe1281067bc22cf92 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -148,6 +148,7 @@ services: SMTP_PORT: ${SMTP_PORT} SMTP_USERNAME: ${SMTP_USERNAME} SMTP_PASSWORD: ${SMTP_PASSWORD} + MAIL_VERIFY: ${MAIL_VERIFY} depends_on: discovery-service: condition: service_healthy diff --git a/docker-compose.yml b/docker-compose.yml index 28deeabc8aa42ce911344e8287ebd952e3967b7b..c0e4d6cead087134c2354afbe66f0cff26ae3859 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -138,10 +138,6 @@ services: JWT_SECRET: fda-secret JWT_EXPIRATION: 86400000 SPRING_PROFILES_ACTIVE: docker - SMTP_HOST: "" - SMTP_PORT: "" - SMTP_USERNAME: "" - SMTP_PASSWORD: "" ports: - "9097:9097" depends_on: diff --git a/fda-authentication-service/Dockerfile b/fda-authentication-service/Dockerfile index 9af0be43a9f09c2cc3c6e78e96e104c23864e1af..05f20e76c14e51dddc585497649f96fe4326b4f0 100644 --- a/fda-authentication-service/Dockerfile +++ b/fda-authentication-service/Dockerfile @@ -28,6 +28,7 @@ ENV WEBSITE=http://example.com ENV GATEWAY_ENDPOINT=http://gateway-service:9095 ENV MAIL_FROM="Database Repository <noreply@example.com>" ENV MAIL_REPLY_TO="Somebody <somebody@example.com>" +ENV MAIL_VERIFY=false ENV JWT_ISSUER=dbrepo ENV JWT_SECRET=secret ENV JWT_EXPIRATION=86400000 diff --git a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java b/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java index 0ea6bd53e646275bfa3e38c1cde19f7c9bfb3532..49385acc585e175fa4d2cd53eef1f0f4e8e08e11 100644 --- a/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java +++ b/fda-authentication-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java @@ -77,7 +77,9 @@ public class UserEndpoint { @Operation(summary = "Create user") public ResponseEntity<UserDto> register(@NotNull @Valid @RequestBody SignupRequestDto data) throws UserEmailExistsException, - UserNameExistsException, RoleNotFoundException, UserEmailFailedException, BrokerUserCreationException, OrcidMalformedException { + UserNameExistsException, RoleNotFoundException, UserEmailFailedException, BrokerUserCreationException, + OrcidMalformedException, AuthenticationInvalidException, UserNotFoundException, + UserEmailNotVerifiedException { final User user = userService.create(data); queueService.createUser(data); final Token token = tokenService.create(user); @@ -109,7 +111,8 @@ public class UserEndpoint { @Operation(summary = "Reset user information") public void reset(@NotNull @Valid @RequestBody UserResetDto data, @NotNull HttpServletResponse httpServletResponse) - throws UserEmailFailedException, TokenInvalidException, UserNotFoundException, BrokerUserCreationException { + throws UserEmailFailedException, TokenInvalidException, UserNotFoundException, BrokerUserCreationException, + UserEmailNotVerifiedException { final User user = tokenService.invalidate(data.getToken()); final UserPasswordDto userPasswordDto = userMapper.userResetDtoToUserPasswordDto(data); userService.updatePassword(user.getId(), userPasswordDto); @@ -125,7 +128,8 @@ public class UserEndpoint { @Transactional(readOnly = true) @PreAuthorize("hasRole('ROLE_DEVELOPER') or hasPermission(#id, 'READ_USER')") @Operation(summary = "Find some user", security = @SecurityRequirement(name = "bearerAuth")) - public ResponseEntity<UserDto> find(@NotNull @PathVariable("id") Long id) throws UserNotFoundException, OrcidMalformedException { + public ResponseEntity<UserDto> find(@NotNull @PathVariable("id") Long id) throws UserNotFoundException, + OrcidMalformedException { final User entity = userService.find(id); return ResponseEntity.status(HttpStatus.OK) .body(userMapper.userToUserDto(entity)); @@ -172,7 +176,8 @@ public class UserEndpoint { @Operation(summary = "Update user password", security = @SecurityRequirement(name = "bearerAuth")) public ResponseEntity<UserDto> updatePassword(@NotNull @PathVariable("id") Long id, @NotNull @Valid @RequestBody UserPasswordDto data) - throws UserNotFoundException, BrokerUserCreationException, OrcidMalformedException { + throws UserNotFoundException, BrokerUserCreationException, OrcidMalformedException, + UserEmailNotVerifiedException { final User entity = userService.updatePassword(id, data); queueService.modifyUserPassword(entity, data); return ResponseEntity.status(HttpStatus.ACCEPTED) diff --git a/fda-authentication-service/rest-service/src/main/resources/application-docker.yml b/fda-authentication-service/rest-service/src/main/resources/application-docker.yml index 471a1f64f74a45dae58a475116c13614f1f674df..680823819b1eff4633d2250bd293e2a702f4c6e8 100644 --- a/fda-authentication-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-authentication-service/rest-service/src/main/resources/application-docker.yml @@ -2,7 +2,7 @@ app.version: '@project.version@' spring: main.banner-mode: off datasource: - url: jdbc:postgresql://fda-metadata-db:5432/fda + url: jdbc:postgresql://metadata-db:5432/fda driver-class-name: org.postgresql.Driver username: postgres password: postgres @@ -17,7 +17,7 @@ spring: jdbc: time_zone: UTC application: - name: fda-authentication-service + name: authentication-service cloud: loadbalancer.ribbon.enabled: false mail: @@ -40,8 +40,8 @@ logging: org.springframework.mail.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-authentication-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: authentication-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready website: "${WEBSITE}" @@ -50,6 +50,7 @@ fda: prefix: / from: "${MAIL_FROM}" replyto: "${MAIL_REPLY_TO}" + verify: false jwt: issuer: "${JWT_ISSUER}" secret: "${JWT_SECRET}" diff --git a/fda-authentication-service/rest-service/src/main/resources/application-local.yml b/fda-authentication-service/rest-service/src/main/resources/application-local.yml new file mode 100644 index 0000000000000000000000000000000000000000..7ca3bb37bef612a6332f66bfccd2bfcbdd42445a --- /dev/null +++ b/fda-authentication-service/rest-service/src/main/resources/application-local.yml @@ -0,0 +1,57 @@ +app.version: '@project.version@' +spring: + main.banner-mode: off + datasource: + url: jdbc:postgresql://localhost:5432/fda + driver-class-name: org.postgresql.Driver + username: postgres + password: postgres + jpa: + show-sql: false + database-platform: org.hibernate.dialect.PostgreSQLDialect + hibernate: + ddl-auto: validate + open-in-view: false + properties: + hibernate: + jdbc: + time_zone: UTC + application: + name: authentication-service + cloud: + loadbalancer.ribbon.enabled: false + mail: + default-encoding: UTF-8 + host: "" + port: 0 + username: "" + password: "" + properties.mail.smtp: + timeout: 5000 + auth: true + starttls.enable: true +server: + port: 9097 +logging: + pattern.console: "%d %highlight(%-5level) %msg%n" + level: + root: warn + at.tuwien.: debug + org.springframework.mail.: debug + org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug +eureka: + instance.hostname: authentication-service + client.serviceUrl.defaultZone: http://localhost:9090/eureka/ +fda: + ready.path: ./ready + website: localhost:3000 + gateway.endpoint: http://localhost:9095 + mail: + prefix: / + from: Nobody + replyto: Nobody + verify: false +jwt: + issuer: dbrepo + secret: dbrepo + expiration.ms: 100000000 \ No newline at end of file diff --git a/fda-authentication-service/rest-service/src/main/resources/application.yml b/fda-authentication-service/rest-service/src/main/resources/application.yml index b257e3c261459779e71ea9f9e7791682268602a8..2206e7af368b7b8d8adf86be7746ee0fcb35e799 100644 --- a/fda-authentication-service/rest-service/src/main/resources/application.yml +++ b/fda-authentication-service/rest-service/src/main/resources/application.yml @@ -4,8 +4,8 @@ spring: datasource: url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect @@ -50,6 +50,7 @@ fda: prefix: / from: "${MAIL_FROM}" replyto: "${MAIL_REPLY_TO}" + verify: "${MAIL_VERIFY}" jwt: issuer: "${JWT_ISSUER}" secret: "${JWT_SECRET}" diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/config/MailConfig.java b/fda-authentication-service/services/src/main/java/at/tuwien/config/MailConfig.java index 222e947ca4d2e850037a450ddd5fe104c81bbc76..c80afc2e4d6890ae8fd93770f44ee3976e111d9c 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/config/MailConfig.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/config/MailConfig.java @@ -28,6 +28,9 @@ public class MailConfig { @Value("${spring.mail.username}") private String mailUsername; + @Value("${fda.mail.verify}") + private Boolean mailVerify; + @Bean public SpringTemplateEngine springTemplateEngine() { final SpringTemplateEngine springTemplateEngine = new SpringTemplateEngine(); diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java b/fda-authentication-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java index 3d45d6ea8fd9fe80674df3f61a4f0abb3d3d526a..1e4aeac29b7080f642526497fb95546efa60ec81 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java @@ -3,7 +3,10 @@ package at.tuwien.gateway; import at.tuwien.api.amqp.CreateUserDto; import at.tuwien.api.user.UserModifyPasswordDto; +import at.tuwien.exception.AuthenticationInvalidException; import at.tuwien.exception.BrokerUserCreationException; +import at.tuwien.exception.UserEmailNotVerifiedException; +import at.tuwien.exception.UserNotFoundException; public interface BrokerServiceGateway { @@ -19,9 +22,9 @@ public interface BrokerServiceGateway { /** * Modify a user password for a user at the Queue Service * - * @param username The username. - * @param data The user modification data. + * @param data The user modification data. * @throws BrokerUserCreationException The broker did not modify a user. */ - void modifyUserPassword(String username, UserModifyPasswordDto data) throws BrokerUserCreationException; + void modifyUserPassword(UserModifyPasswordDto data) + throws BrokerUserCreationException, UserNotFoundException, UserEmailNotVerifiedException; } diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java b/fda-authentication-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java index 14576187e75e0fa5a23f9a260fff74eef9a5602b..72771998cb00ca677fe88b07779015b9c9f7781d 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java @@ -2,16 +2,19 @@ package at.tuwien.gateway.impl; import at.tuwien.api.amqp.CreateUserDto; import at.tuwien.api.amqp.GrantVirtualHostPermissionsDto; +import at.tuwien.api.auth.JwtResponseDto; +import at.tuwien.api.auth.LoginRequestDto; import at.tuwien.api.user.UserModifyPasswordDto; +import at.tuwien.exception.AuthenticationInvalidException; import at.tuwien.exception.BrokerUserCreationException; +import at.tuwien.exception.UserEmailNotVerifiedException; +import at.tuwien.exception.UserNotFoundException; import at.tuwien.gateway.BrokerServiceGateway; import at.tuwien.mapper.UserMapper; +import at.tuwien.service.AuthenticationService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -19,18 +22,21 @@ import org.springframework.web.client.RestTemplate; @Service public class BrokerServiceGatewayImpl implements BrokerServiceGateway { - private final RestTemplate restTemplate; private final UserMapper userMapper; + private final RestTemplate restTemplate; + private final AuthenticationService authenticationService; @Autowired - public BrokerServiceGatewayImpl(RestTemplate restTemplate, UserMapper userMapper) { - this.restTemplate = restTemplate; + public BrokerServiceGatewayImpl(UserMapper userMapper, RestTemplate restTemplate, + AuthenticationService authenticationService) { this.userMapper = userMapper; + this.restTemplate = restTemplate; + this.authenticationService = authenticationService; } @Override public void createUser(CreateUserDto data) throws BrokerUserCreationException { - final GrantVirtualHostPermissionsDto grantDto = userMapper.signupRequestDtoToGrantComponentDto(); + /* create user */ final ResponseEntity<Void> createResponse = restTemplate.exchange("/api/broker/user", HttpMethod.POST, new HttpEntity<>(data), Void.class); if (!createResponse.getStatusCode().equals(HttpStatus.CREATED)) { @@ -38,9 +44,10 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { throw new BrokerUserCreationException("Failed to create user at queue service"); } log.info("Created user at queue service with username {}", data.getUsername()); - final ResponseEntity<Void> grantResponse = restTemplate.exchange( - "/api/broker/user/" + data.getUsername() + "/permission", HttpMethod.PUT, new HttpEntity<>(grantDto), - Void.class); + final GrantVirtualHostPermissionsDto grantDto = userMapper.signupRequestDtoToGrantComponentDto(); + final String url = "/api/broker/user/" + data.getUsername() + "/permission"; + final ResponseEntity<Void> grantResponse = restTemplate.exchange(url, HttpMethod.PUT, + new HttpEntity<>(grantDto), Void.class); if (!grantResponse.getStatusCode().equals(HttpStatus.ACCEPTED)) { log.error("Failed to grant permissions at queue service: {}", createResponse.getStatusCode()); throw new BrokerUserCreationException("Failed to grant permissions at queue service"); @@ -50,15 +57,22 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { } @Override - public void modifyUserPassword(String username, UserModifyPasswordDto data) throws BrokerUserCreationException { + public void modifyUserPassword(UserModifyPasswordDto data) throws BrokerUserCreationException, + UserNotFoundException, UserEmailNotVerifiedException { + /* obtain token */ + final JwtResponseDto obtainResponse = authenticationService.authenticate(data); + /* modify at broker service */ + final HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", "Bearer " + obtainResponse.getToken()); log.debug("modify user at broker service {}", data); - final ResponseEntity<Void> response = restTemplate.exchange("/api/broker/user/" + username + "/password", - HttpMethod.PUT, new HttpEntity<>(data), Void.class); + final String url = "/api/broker/user/" + data.getUsername() + "/password"; + final ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.PUT, + new HttpEntity<>(data, headers), Void.class); if (!response.getStatusCode().equals(HttpStatus.ACCEPTED)) { log.error("Failed to update user password at queue service: {}", response.getStatusCode()); throw new BrokerUserCreationException("Failed to update user password at queue service"); } - log.info("Updated user password at queue service for username {}", username); + log.info("Updated user password at queue service for username {}", data.getUsername()); log.debug("updated user password at queue service {}", data); } diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/mapper/UserMapper.java b/fda-authentication-service/services/src/main/java/at/tuwien/mapper/UserMapper.java index 97180b2d3011144b2e8c8cd9835acd69b809cb56..c483d0200f3b9fff73c5301e64977f8a79464336 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/mapper/UserMapper.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/mapper/UserMapper.java @@ -3,6 +3,7 @@ package at.tuwien.mapper; import at.tuwien.api.amqp.CreateUserDto; import at.tuwien.api.amqp.GrantVirtualHostPermissionsDto; import at.tuwien.api.auth.JwtResponseDto; +import at.tuwien.api.auth.LoginRequestDto; import at.tuwien.api.auth.SignupRequestDto; import at.tuwien.api.user.*; import at.tuwien.entities.user.RoleType; @@ -30,6 +31,8 @@ public interface UserMapper { CreateUserDto signupRequestDtoToCreateUserDto(SignupRequestDto data); + LoginRequestDto createUserDtoToLoginRequestDto(CreateUserDto data); + UserPasswordDto userResetDtoToUserPasswordDto(UserResetDto data); @Transactional(readOnly = true) diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java index 3532d1eaf176fa441edcdfdf72a5dd9502731609..be0a0e9f0a4cf1701b29eccdcc92ec91c8b2053a 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/service/AuthenticationService.java @@ -2,8 +2,10 @@ package at.tuwien.service; import at.tuwien.api.auth.JwtResponseDto; import at.tuwien.api.auth.LoginRequestDto; +import at.tuwien.api.user.UserModifyPasswordDto; import at.tuwien.exception.UserEmailNotVerifiedException; import at.tuwien.exception.UserNotFoundException; +import org.springframework.transaction.annotation.Transactional; import java.security.Principal; @@ -14,9 +16,22 @@ public interface AuthenticationService { * * @param data The credentials. * @return The token, if successful + * @throws UserEmailNotVerifiedException The user email is not verified. + * @throws UserNotFoundException The user was not found by username. */ JwtResponseDto authenticate(LoginRequestDto data) throws UserEmailNotVerifiedException, UserNotFoundException; + /** + * Authenticate a user with username and a reset token as credentials. + * + * @param data The credentials. + * @return The token if successful. + * @throws UserEmailNotVerifiedException The user email is not verified. + * @throws UserNotFoundException The user was not found by username. + */ + JwtResponseDto authenticate(UserModifyPasswordDto data) throws UserEmailNotVerifiedException, + UserNotFoundException; + /** * Renews a token for a given principal * TODO limit rate of renewal to 1/hour diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/QueueService.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/QueueService.java index 96007ca3f1e462161302183ca58820c1ca06fccb..3ce4f4bf1edb2b5b06df0f17bf581e229b10215b 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/QueueService.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/service/QueueService.java @@ -3,7 +3,10 @@ package at.tuwien.service; import at.tuwien.api.auth.SignupRequestDto; import at.tuwien.api.user.UserPasswordDto; import at.tuwien.entities.user.User; +import at.tuwien.exception.AuthenticationInvalidException; import at.tuwien.exception.BrokerUserCreationException; +import at.tuwien.exception.UserEmailNotVerifiedException; +import at.tuwien.exception.UserNotFoundException; import org.springframework.stereotype.Service; @@ -13,17 +16,16 @@ public interface QueueService { /** * Creates a user at the Broker Service * - * @param data The user data. - * @throws BrokerUserCreationException The broker did not create the user. + * @param data The user data@throws BrokerUserCreationException The broker did not create the user. */ - void createUser(SignupRequestDto data) throws BrokerUserCreationException; + void createUser(SignupRequestDto data) throws BrokerUserCreationException, AuthenticationInvalidException, UserNotFoundException, UserEmailNotVerifiedException; /** * Modify a user password at the Broker Service * - * @param user The user data. - * @param data The user password. + * @param user The user data. + * @param data The user password.. * @throws BrokerUserCreationException The broker did not modify the user. */ - void modifyUserPassword(User user, UserPasswordDto data) throws BrokerUserCreationException; + void modifyUserPassword(User user, UserPasswordDto data) throws BrokerUserCreationException, UserNotFoundException, UserEmailNotVerifiedException; } diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/AuthenticationServiceImpl.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/AuthenticationServiceImpl.java index 42fcc659cc89e824dd2e0b4fb126f544eeaa0526..3ce64d3ccd224cdc83e3814f8d0d32f636857822 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/AuthenticationServiceImpl.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/AuthenticationServiceImpl.java @@ -2,7 +2,9 @@ package at.tuwien.service.impl; import at.tuwien.api.auth.JwtResponseDto; import at.tuwien.api.auth.LoginRequestDto; +import at.tuwien.api.user.UserModifyPasswordDto; import at.tuwien.auth.JwtUtils; +import at.tuwien.config.MailConfig; import at.tuwien.entities.user.User; import at.tuwien.exception.UserEmailNotVerifiedException; import at.tuwien.exception.UserNotFoundException; @@ -11,7 +13,6 @@ import at.tuwien.service.AuthenticationService; import at.tuwien.service.UserService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -20,7 +21,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.security.Principal; -import java.util.Arrays; @Slf4j @@ -29,18 +29,17 @@ public class AuthenticationServiceImpl implements AuthenticationService { private final JwtUtils jwtUtils; private final UserMapper userMapper; + private final MailConfig mailConfig; private final UserService userService; - private final Environment environment; private final AuthenticationManager authenticationManager; @Autowired - public AuthenticationServiceImpl(JwtUtils jwtUtils, UserMapper userMapper, - UserService userService, Environment environment, - AuthenticationManager authenticationManager) { + public AuthenticationServiceImpl(JwtUtils jwtUtils, UserMapper userMapper, MailConfig mailConfig, + UserService userService, AuthenticationManager authenticationManager) { this.jwtUtils = jwtUtils; this.userMapper = userMapper; + this.mailConfig = mailConfig; this.userService = userService; - this.environment = environment; this.authenticationManager = authenticationManager; } @@ -49,7 +48,25 @@ public class AuthenticationServiceImpl implements AuthenticationService { public JwtResponseDto authenticate(LoginRequestDto data) throws UserEmailNotVerifiedException, UserNotFoundException { final User user = userService.findByUsername(data.getUsername()); - if (isProduction() && !user.getEmailVerified()) { + if (mailConfig.getMailVerify() && !user.getEmailVerified()) { + log.error("E-Mail not verified for username {}", data.getUsername()); + throw new UserEmailNotVerifiedException("E-Mail not verified"); + } + final UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(data.getUsername(), + data.getPassword()); + final Authentication authentication = authenticationManager.authenticate(token); + SecurityContextHolder.getContext().setAuthentication(authentication); + final JwtResponseDto response = userMapper.principalToJwtResponseDto(authentication.getPrincipal()); + response.setToken(jwtUtils.generateJwtToken(authentication.getPrincipal())); + return response; + } + + @Override + @Transactional(readOnly = true) + public JwtResponseDto authenticate(UserModifyPasswordDto data) throws UserEmailNotVerifiedException, + UserNotFoundException { + final User user = userService.findByUsername(data.getUsername()); + if (mailConfig.getMailVerify() && !user.getEmailVerified()) { log.error("E-Mail not verified for username {}", data.getUsername()); throw new UserEmailNotVerifiedException("E-Mail not verified"); } @@ -70,8 +87,4 @@ public class AuthenticationServiceImpl implements AuthenticationService { response.setToken(jwtUtils.generateJwtToken(token.getPrincipal())); return response; } - - private Boolean isProduction() { - return Arrays.asList(this.environment.getActiveProfiles()).contains("prod"); - } } diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/QueueServiceImpl.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/QueueServiceImpl.java index fb9e0d018ae49466e7cf3165d7c60d9194ed0d6f..7dd16330bcf63467311ab3dc45e8d9a01d5d3857 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/QueueServiceImpl.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/QueueServiceImpl.java @@ -5,7 +5,10 @@ import at.tuwien.api.auth.SignupRequestDto; import at.tuwien.api.user.UserModifyPasswordDto; import at.tuwien.api.user.UserPasswordDto; import at.tuwien.entities.user.User; +import at.tuwien.exception.AuthenticationInvalidException; import at.tuwien.exception.BrokerUserCreationException; +import at.tuwien.exception.UserEmailNotVerifiedException; +import at.tuwien.exception.UserNotFoundException; import at.tuwien.gateway.BrokerServiceGateway; import at.tuwien.mapper.UserMapper; import at.tuwien.service.QueueService; @@ -33,12 +36,13 @@ public class QueueServiceImpl implements QueueService { } @Override - public void modifyUserPassword(User user, UserPasswordDto data) throws BrokerUserCreationException { + public void modifyUserPassword(User user, UserPasswordDto data) throws BrokerUserCreationException, + UserNotFoundException, UserEmailNotVerifiedException { final UserModifyPasswordDto passwordDto = UserModifyPasswordDto.builder() .username(user.getUsername()) .password(data.getPassword()) .build(); - brokerServiceGateway.modifyUserPassword(user.getUsername(), passwordDto); + brokerServiceGateway.modifyUserPassword(passwordDto); } } diff --git a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/UserServiceImpl.java b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/UserServiceImpl.java index 4ab0e32aa20abd20574fa5d752336041d9aa02a1..99d943f2b278967cfe98d74c41eea66b8af09b1f 100644 --- a/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/UserServiceImpl.java +++ b/fda-authentication-service/services/src/main/java/at/tuwien/service/impl/UserServiceImpl.java @@ -85,7 +85,7 @@ public class UserServiceImpl implements UserService { @Override @Transactional public User create(SignupRequestDto data) throws UserEmailExistsException, UserNameExistsException { - /* check */ + /* duplicate */ final Optional<User> email = userRepository.findByEmail(data.getEmail()); if (email.isPresent()) { log.error("Email address is already present in the database"); diff --git a/fda-broker-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java b/fda-broker-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java index a13585f48a9502af727409167db5a04de16c9723..75a4ffac90d07f5ddf4d3b349c6ce4cefaf2ae2c 100644 --- a/fda-broker-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java +++ b/fda-broker-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java @@ -11,6 +11,7 @@ import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -32,7 +33,7 @@ public class UserEndpoint { } @PostMapping - @Operation(summary = "Create user", security = @SecurityRequirement(name = "bearerAuth")) + @Operation(summary = "Create user") public ResponseEntity<?> create(@NotNull @Valid @RequestBody CreateUserDto data) throws ProcessCompletionException { queueService.createUser(data); return ResponseEntity.status(HttpStatus.CREATED) @@ -40,6 +41,7 @@ public class UserEndpoint { } @PutMapping("/{username}/password") + @PreAuthorize("hasRole('ROLE_RESEARCHER')") @Operation(summary = "Modifies user password", security = @SecurityRequirement(name = "bearerAuth")) public ResponseEntity<?> modify(@NotNull @PathVariable("username") String username, @NotNull @Valid @RequestBody UserModifyPasswordDto data, @@ -51,12 +53,11 @@ public class UserEndpoint { } @PutMapping("/{username}/permission") - @Operation(summary = "Grants user permission", security = @SecurityRequirement(name = "bearerAuth")) + @Operation(summary = "Grants user permission") public ResponseEntity<?> grant(@NotNull @PathVariable("username") String username, - @NotNull @Valid @RequestBody GrantVirtualHostPermissionsDto data, - @NotNull Principal principal) + @NotNull @Valid @RequestBody GrantVirtualHostPermissionsDto data) throws ProcessCompletionException { - queueService.grantVirtualHost(username, data, principal); + queueService.grantVirtualHost(username, data); return ResponseEntity.accepted() .build(); } diff --git a/fda-broker-service/rest-service/src/main/resources/application-docker.yml b/fda-broker-service/rest-service/src/main/resources/application-docker.yml index 85684b583251344744efe2e8c8c0ffd591abfe05..8c8e17d1145c4d16ef2d8eccf076529c1521922a 100644 --- a/fda-broker-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-broker-service/rest-service/src/main/resources/application-docker.yml @@ -13,11 +13,11 @@ spring: jdbc: time_zone: UTC application: - name: "${BROKER_HOSTNAME}" + name: broker-service rabbitmq: - host: "${BROKER_HOSTNAME}" - username: "${BROKER_USERNAME}" - password: "${BROKER_PASSWORD}" + host: broker-service + username: fda + password: fda cloud: loadbalancer.ribbon.enabled: false server: @@ -29,8 +29,8 @@ logging: at.tuwien.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: "${BROKER_HOSTNAME}" - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: broker-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready gateway.endpoint: "${GATEWAY_ENDPOINT}" \ No newline at end of file diff --git a/fda-broker-service/rest-service/src/main/resources/application.yml b/fda-broker-service/rest-service/src/main/resources/application.yml index a8041d2101a80aa07dc9fbfaf3038c902407e71f..ae83cb217b9e7ccf408303644e6954c3ec2d1d99 100644 --- a/fda-broker-service/rest-service/src/main/resources/application.yml +++ b/fda-broker-service/rest-service/src/main/resources/application.yml @@ -29,7 +29,7 @@ logging: at.tuwien.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: broker-service + instance.hostname: ${BROKER_HOSTNAME}" client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: ./ready diff --git a/fda-broker-service/services/src/main/java/at/tuwien/auth/AuthTokenFilter.java b/fda-broker-service/services/src/main/java/at/tuwien/auth/AuthTokenFilter.java index e33f0dba4dddf90216af08dbb5ec98b184fbf6f6..4d819a17867603ab7f017a9f678f387cce38ef87 100644 --- a/fda-broker-service/services/src/main/java/at/tuwien/auth/AuthTokenFilter.java +++ b/fda-broker-service/services/src/main/java/at/tuwien/auth/AuthTokenFilter.java @@ -55,4 +55,4 @@ public class AuthTokenFilter extends OncePerRequestFilter { } return null; } -} \ No newline at end of file +} diff --git a/fda-broker-service/services/src/main/java/at/tuwien/config/WebSecurityConfig.java b/fda-broker-service/services/src/main/java/at/tuwien/config/WebSecurityConfig.java index 4e7e5da8cfdbcf3bcd72b969e6f3454c9ccb0d0f..f853935327df9d03d0aef439a8c61c1f97517a8d 100644 --- a/fda-broker-service/services/src/main/java/at/tuwien/config/WebSecurityConfig.java +++ b/fda-broker-service/services/src/main/java/at/tuwien/config/WebSecurityConfig.java @@ -4,6 +4,7 @@ import at.tuwien.auth.AuthTokenFilter; import at.tuwien.gateway.AuthenticationServiceGateway; import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.security.SecuritySchemes; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -65,8 +66,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { /* set permissions on endpoints */ http.authorizeRequests() /* our public endpoints */ - .antMatchers("/api/broker/user/**").hasIpAddress("172.29.0.0/16") - .antMatchers("/api/broker/vhost/**").hasIpAddress("172.29.0.0/16") + .antMatchers(HttpMethod.POST, "/api/broker/user").hasIpAddress("172.29.0.0/16") + .antMatchers(HttpMethod.PUT, "/api/broker/user/**/permission").hasIpAddress("172.29.0.0/16") .antMatchers("/v3/api-docs.yaml", "/v3/api-docs/**", "/swagger-ui/**", diff --git a/fda-broker-service/services/src/main/java/at/tuwien/service/QueueService.java b/fda-broker-service/services/src/main/java/at/tuwien/service/QueueService.java index 5184853d8f7d769a21a5ebf113ffe9749bb57dc1..9387305743e80cfd2e315638e2070dec3ca637f9 100644 --- a/fda-broker-service/services/src/main/java/at/tuwien/service/QueueService.java +++ b/fda-broker-service/services/src/main/java/at/tuwien/service/QueueService.java @@ -44,9 +44,8 @@ public interface QueueService { * * @param username The username of the user. * @param data The password. - * @param principal The current user. * @throws ProcessCompletionException The process did not complete within the 3s timeout. */ - void grantVirtualHost(String username, GrantVirtualHostPermissionsDto data, Principal principal) + void grantVirtualHost(String username, GrantVirtualHostPermissionsDto data) throws ProcessCompletionException; } diff --git a/fda-broker-service/services/src/main/java/at/tuwien/service/impl/AmqpServiceImpl.java b/fda-broker-service/services/src/main/java/at/tuwien/service/impl/AmqpServiceImpl.java index a5ff4953165821654371bec13eeed19c34d50131..96737a074a857f98975f8c56b23295afe9cf09be 100644 --- a/fda-broker-service/services/src/main/java/at/tuwien/service/impl/AmqpServiceImpl.java +++ b/fda-broker-service/services/src/main/java/at/tuwien/service/impl/AmqpServiceImpl.java @@ -57,7 +57,7 @@ public class AmqpServiceImpl implements QueueService { } @Override - public void grantVirtualHost(String username, GrantVirtualHostPermissionsDto data, Principal principal) + public void grantVirtualHost(String username, GrantVirtualHostPermissionsDto data) throws ProcessCompletionException { final StringBuilder setPermissionsCmd = new StringBuilder("rabbitmqctl set_permissions -p ") .append(data.getVirtualHost()) diff --git a/fda-container-service/rest-service/src/main/resources/application-docker.yml b/fda-container-service/rest-service/src/main/resources/application-docker.yml index c9acde992f56ddcd735387f647d8c12915f49a06..8cadde6a05233e148e0bb2d7bffa65482b3e3a61 100644 --- a/fda-container-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-container-service/rest-service/src/main/resources/application-docker.yml @@ -17,7 +17,7 @@ spring: jdbc: time_zone: UTC application: - name: fda-container-service + name: container-service cloud: loadbalancer.ribbon.enabled: false springdoc.swagger-ui.enabled: true @@ -29,8 +29,8 @@ logging: at.tuwien.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-container-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: container-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: mount.path: /tmp ready.path: /ready diff --git a/fda-container-service/rest-service/src/main/resources/application.yml b/fda-container-service/rest-service/src/main/resources/application.yml index e9627301ec9c9594db021b71833a0939dfdfad26..d38936b08a03d0932f0a8a15e2fead0abf5ad7a9 100644 --- a/fda-container-service/rest-service/src/main/resources/application.yml +++ b/fda-container-service/rest-service/src/main/resources/application.yml @@ -4,8 +4,8 @@ spring: datasource: url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/fda-database-service/rest-service/src/main/resources/application-docker.yml b/fda-database-service/rest-service/src/main/resources/application-docker.yml index c8311330acf3613ff78936180ae88f6d1bd5e118..2f1e5dbd8d4407e06e373a819efff5899cc1cee3 100644 --- a/fda-database-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-database-service/rest-service/src/main/resources/application-docker.yml @@ -17,13 +17,13 @@ spring: jdbc: time_zone: UTC application: - name: fda-database-service + name: database-service cloud: loadbalancer.ribbon.enabled: false rabbitmq: - host: fda-broker-service - username: "${BROKER_USERNAME}" - password: "${BROKER_PASSWORD}" + host: broker-service + username: fda + password: fda server.port: 9092 logging: pattern.console: "%d %highlight(%-5level) %msg%n" @@ -33,8 +33,8 @@ logging: at.tuwien.mapper.: trace org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-database-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: database-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: elastic.endpoint: "${SEARCH_ENDPOINT}" ready.path: /ready diff --git a/fda-discovery-service/discovery/src/main/resources/application-docker.yml b/fda-discovery-service/discovery/src/main/resources/application-docker.yml index 6a28ba573fc366ea4842fbc5c92181de5fbbe4d9..63852fa846b21cf6b860582de498b321b9ad55b9 100644 --- a/fda-discovery-service/discovery/src/main/resources/application-docker.yml +++ b/fda-discovery-service/discovery/src/main/resources/application-docker.yml @@ -1,7 +1,7 @@ spring: main.banner-mode: off datasource: - url: jdbc:postgresql://fda-metadata-db:5432/fda + url: jdbc:postgresql://metadata-db:5432/fda driver-class-name: org.postgresql.Driver username: postgres password: postgres @@ -16,17 +16,19 @@ spring: jdbc: time_zone: UTC application: - name: fda-discovery-service + name: discovery-service server.port: 9090 logging: pattern.console: "%d %highlight(%-5level) %msg%n" level: root: warn at.tuwien.: debug + com.netflix.eureka.: off + com.netflix.discovery.: off eureka: eureka.client.register-with-eureka: false eureka.client.fetch-registry: false - instance.hostname: fda-discovery-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: discovery-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready \ No newline at end of file diff --git a/fda-discovery-service/discovery/src/main/resources/application.yml b/fda-discovery-service/discovery/src/main/resources/application.yml index 05584759b034feaeffe7dc505a3ef4f2ba6af97f..55f8a5e25348b571a8993eacaad38195a3ec4483 100644 --- a/fda-discovery-service/discovery/src/main/resources/application.yml +++ b/fda-discovery-service/discovery/src/main/resources/application.yml @@ -3,8 +3,8 @@ spring: datasource: url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect @@ -16,7 +16,7 @@ spring: jdbc: time_zone: UTC application: - name: fda-discovery-service + name: discovery-service server.port: 9090 logging: pattern.console: "%d %highlight(%-5level) %msg%n" @@ -28,7 +28,7 @@ logging: eureka: eureka.client.register-with-eureka: false eureka.client.fetch-registry: false - instance.hostname: fda-discovery-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: discovery-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready \ No newline at end of file diff --git a/fda-gateway-service/gateway/src/main/resources/application-docker.yml b/fda-gateway-service/gateway/src/main/resources/application-docker.yml index 0121560d7579510ef7a6338d8299bc871a9957cf..a8130dd470bdbeaf6a21c45f47dda1e4c1be26ac 100644 --- a/fda-gateway-service/gateway/src/main/resources/application-docker.yml +++ b/fda-gateway-service/gateway/src/main/resources/application-docker.yml @@ -1,13 +1,13 @@ spring: main.banner-mode: off datasource: - url: jdbc:postgresql://fda-metadata-db:5432/fda - driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + url: jdbc:h2:mem:mydb + username: sa + password: password + driverClassName: org.h2.Driver jpa: show-sql: false - database-platform: org.hibernate.dialect.PostgreSQLDialect + database-platform: org.hibernate.dialect.H2Dialect hibernate: ddl-auto: validate open-in-view: false @@ -16,7 +16,7 @@ spring: jdbc: time_zone: UTC application: - name: fda-gateway-service + name: gateway-service springdoc.swagger-ui.enabled: false server.port: 9095 logging: @@ -26,7 +26,7 @@ logging: at.tuwien.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-discovery-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: discovery-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready \ No newline at end of file diff --git a/fda-gateway-service/gateway/src/main/resources/application.yml b/fda-gateway-service/gateway/src/main/resources/application.yml index 8d6622dfb68816bc3d6a344f6f939d0aacabab55..a8130dd470bdbeaf6a21c45f47dda1e4c1be26ac 100644 --- a/fda-gateway-service/gateway/src/main/resources/application.yml +++ b/fda-gateway-service/gateway/src/main/resources/application.yml @@ -1,13 +1,13 @@ spring: main.banner-mode: off datasource: - url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" - driver-class-name: org.postgresql.Driver - username: "${METADATA_USERNAME}" - password: "${METADATA_PASSWORD}" + url: jdbc:h2:mem:mydb + username: sa + password: password + driverClassName: org.h2.Driver jpa: show-sql: false - database-platform: org.hibernate.dialect.PostgreSQLDialect + database-platform: org.hibernate.dialect.H2Dialect hibernate: ddl-auto: validate open-in-view: false diff --git a/fda-gateway-service/pom.xml b/fda-gateway-service/pom.xml index f6bb5be45e479641bdc4127561a4857a7b6f6160..c1d3e947751194b6791f9a3c72ba1f7a148bb7d6 100644 --- a/fda-gateway-service/pom.xml +++ b/fda-gateway-service/pom.xml @@ -45,6 +45,16 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> + <!-- Embedded DataSource --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>runtime</scope> + </dependency> <!-- IDE --> <dependency> <groupId>org.projectlombok</groupId> diff --git a/fda-identifier-service/rest-service/src/main/resources/application-docker.yml b/fda-identifier-service/rest-service/src/main/resources/application-docker.yml index acf0f166c0760fecedbc849c9040595d29bb1a4c..c39949196d77ddb1a1b1a34f9ac67749bff3d33d 100644 --- a/fda-identifier-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-identifier-service/rest-service/src/main/resources/application-docker.yml @@ -2,7 +2,7 @@ app.version: '@project.version@' spring: main.banner-mode: off datasource: - url: jdbc:postgresql://fda-metadata-db:5432/fda + url: jdbc:postgresql://metadata-db:5432/fda driver-class-name: org.postgresql.Driver username: postgres password: postgres @@ -17,7 +17,7 @@ spring: jdbc: time_zone: UTC application: - name: fda-identifier-service + name: identifier-service cloud: loadbalancer.ribbon.enabled: false server.port: 9096 @@ -29,8 +29,8 @@ logging: at.tuwien.auth.UserPermissionEvaluator: trace org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-identifier-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: identifier-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready gateway.endpoint: "${GATEWAY_ENDPOINT}" \ No newline at end of file diff --git a/fda-identifier-service/rest-service/src/main/resources/application.yml b/fda-identifier-service/rest-service/src/main/resources/application.yml index 255c31e5a55a7e4778ca00ccbe5485bed5b3da01..9df952dc54c974dfb8ef818a866a092951a125b7 100644 --- a/fda-identifier-service/rest-service/src/main/resources/application.yml +++ b/fda-identifier-service/rest-service/src/main/resources/application.yml @@ -2,10 +2,10 @@ app.version: '@project.version@' spring: main.banner-mode: off datasource: - url: jdbc:postgresql://metadata-db:5432/fda + url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect @@ -29,7 +29,7 @@ logging: at.tuwien.auth.UserPermissionEvaluator: trace org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-identifier-service + instance.hostname: identifier-service client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready diff --git a/fda-metadata-db/api/src/main/java/at/tuwien/api/auth/SignupRequestDto.java b/fda-metadata-db/api/src/main/java/at/tuwien/api/auth/SignupRequestDto.java index a28f08f79fe55c10da93451a4df8766d559bad58..bebaba12dddb250951121e119f45b4b27a065e0d 100644 --- a/fda-metadata-db/api/src/main/java/at/tuwien/api/auth/SignupRequestDto.java +++ b/fda-metadata-db/api/src/main/java/at/tuwien/api/auth/SignupRequestDto.java @@ -5,6 +5,7 @@ import lombok.*; import javax.validation.constraints.Email; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; @Getter @Setter @@ -15,6 +16,7 @@ import javax.validation.constraints.NotNull; public class SignupRequestDto { @NotNull + @Pattern(regexp = "^[a-z0-9]{3,}$") @Parameter(name = "user name") private String username; diff --git a/fda-query-service/rest-service/src/main/resources/application-docker.yml b/fda-query-service/rest-service/src/main/resources/application-docker.yml index 5fe20159177864b2bd60a1cecf0de464fed7969d..77c04460c15034f08b0d091a37f0da076f4420f3 100644 --- a/fda-query-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-query-service/rest-service/src/main/resources/application-docker.yml @@ -17,9 +17,9 @@ spring: jdbc: time_zone: UTC application: - name: fda-query-service + name: query-service rabbitmq: - host: fda-broker-service + host: broker-service username: fda password: fda cloud: @@ -36,8 +36,8 @@ logging: at.tuwien.auth.UserPermissionEvaluator: trace org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-query-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: query-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: gateway.endpoint: "${GATEWAY_ENDPOINT}" ready.path: /ready diff --git a/fda-query-service/rest-service/src/main/resources/application.yml b/fda-query-service/rest-service/src/main/resources/application.yml index daa2620acaaafddbb37cfb05fd027e19ea43c248..1ccb95256cbd3b78888fdfc3baec0a3bb4e631aa 100644 --- a/fda-query-service/rest-service/src/main/resources/application.yml +++ b/fda-query-service/rest-service/src/main/resources/application.yml @@ -2,10 +2,10 @@ app.version: '@project.version@' spring: main.banner-mode: off datasource: - url: jdbc:postgresql://metadata-db:5432/fda + url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/fda-table-service/rest-service/src/main/resources/application-docker.yml b/fda-table-service/rest-service/src/main/resources/application-docker.yml index 6505cdc429eb6b9dda70e42143f1a98adaa42c99..2e82c75a92c03583c9da039916419c86f8468b62 100644 --- a/fda-table-service/rest-service/src/main/resources/application-docker.yml +++ b/fda-table-service/rest-service/src/main/resources/application-docker.yml @@ -17,9 +17,9 @@ spring: jdbc: time_zone: UTC application: - name: fda-table-service + name: table-service rabbitmq: - host: fda-broker-service + host: broker-service username: fda password: fda cloud: @@ -35,8 +35,8 @@ logging: at.tuwien.config.: debug org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug eureka: - instance.hostname: fda-table-service - client.serviceUrl.defaultZone: http://fda-discovery-service:9090/eureka/ + instance.hostname: table-service + client.serviceUrl.defaultZone: http://discovery-service:9090/eureka/ fda: ready.path: /ready gateway.endpoint: "${GATEWAY_ENDPOINT}" diff --git a/fda-table-service/rest-service/src/main/resources/application.yml b/fda-table-service/rest-service/src/main/resources/application.yml index 3ddc324581aebc9672c7a45ed0792a816a9618e1..63ee3d36d83a0c0f5ef62d9f8662ed62f8fce1c8 100644 --- a/fda-table-service/rest-service/src/main/resources/application.yml +++ b/fda-table-service/rest-service/src/main/resources/application.yml @@ -2,10 +2,10 @@ app.version: '@project.version@' spring: main.banner-mode: off datasource: - url: jdbc:postgresql://metadata-db:5432/fda + url: "jdbc:postgresql://metadata-db:5432/${METADATA_DB}" driver-class-name: org.postgresql.Driver - username: postgres - password: postgres + username: "${METADATA_USERNAME}" + password: "${METADATA_PASSWORD}" jpa: show-sql: false database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/fda-ui/pages/signup.vue b/fda-ui/pages/signup.vue index 6d95a57a97d7b96a2d663c37c3143ba4ed8e2f2e..113b158ac522c0c0329140efaec70d36913f494f 100644 --- a/fda-ui/pages/signup.vue +++ b/fda-ui/pages/signup.vue @@ -30,7 +30,8 @@ v-model="createAccount.username" autocomplete="off" required - :rules="[v => !!v || $t('Required')]" + :rules="[v => !!v || $t('Required'), + v => /^[a-z0-9]{3,}$/.test(v) || $t('Only lowercase letters, min. 3 length')]" hint="e.g. mmustermann" label="Username *" /> </v-col>