From 55fe05c218eb6b209d2f0e8c20339dacfedf4fdb Mon Sep 17 00:00:00 2001 From: Mustafa Yontar Date: Mon, 1 Feb 2021 12:47:26 +0300 Subject: [PATCH] add docker-compose for developers create a apikey mechanism --- docker-compose-dev.yaml | 31 +++++++++++++++++++++++++++++++ docker-compose.yaml | 11 ----------- models/EmbededDocuments.py | 10 ++++++++++ models/Union.py | 2 ++ 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 docker-compose-dev.yaml diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml new file mode 100644 index 0000000..895fc5f --- /dev/null +++ b/docker-compose-dev.yaml @@ -0,0 +1,31 @@ +version: "3.3" +services: + mongo: + image: mongo + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: xcoder + MONGO_INITDB_ROOT_PASSWORD: 4dun4710 + volumes: + - ./mongo_data_dir/:/data/db/ + mongo-express: + image: mongo-express + restart: always + ports: + - 8081:8081 + environment: + ME_CONFIG_MONGODB_ADMINUSERNAME: xcoder + ME_CONFIG_MONGODB_ADMINPASSWORD: 4dun4710 + ME_CONFIG_OPTIONS_EDITORTHEME: ambiance + ME_CONFIG_BASICAUTH_USERNAME: xcoder + ME_CONFIG_BASICAUTH_PASSWORD: 4dun4710 + web: + build: . + + ports: + - "5000:5000" + environment: + ADUNATIO_PRIV_KEY: /code/privkey.pem + FLASK_DEBUG: 1 + volumes: + - .:/code diff --git a/docker-compose.yaml b/docker-compose.yaml index 895fc5f..259208a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,17 +8,6 @@ services: MONGO_INITDB_ROOT_PASSWORD: 4dun4710 volumes: - ./mongo_data_dir/:/data/db/ - mongo-express: - image: mongo-express - restart: always - ports: - - 8081:8081 - environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: xcoder - ME_CONFIG_MONGODB_ADMINPASSWORD: 4dun4710 - ME_CONFIG_OPTIONS_EDITORTHEME: ambiance - ME_CONFIG_BASICAUTH_USERNAME: xcoder - ME_CONFIG_BASICAUTH_PASSWORD: 4dun4710 web: build: . diff --git a/models/EmbededDocuments.py b/models/EmbededDocuments.py index b350b72..18a8ab5 100644 --- a/models/EmbededDocuments.py +++ b/models/EmbededDocuments.py @@ -1,6 +1,16 @@ +from datetime import datetime + from mongoengine import * +class ApiKey(EmbeddedDocument): + secret = StringField() + key = StringField() + rights = ListField(StringField()) + create_date = DateTimeField(default=datetime.utcnow) + creator = ReferenceField("User") + + class Descriptions(EmbeddedDocument): text = StringField() user = ReferenceField("User") diff --git a/models/Union.py b/models/Union.py index 11af4dc..3320d8f 100644 --- a/models/Union.py +++ b/models/Union.py @@ -3,6 +3,7 @@ from werkzeug.security import generate_password_hash from string import ascii_letters, digits from random import choices +from models.EmbededDocuments import ApiKey from restapi import Methods @@ -25,6 +26,7 @@ class Union(Document): legal_registration_number = StringField() headquarter = StringField() email = StringField() + api_key = ListField(EmbeddedDocumentField(ApiKey)) def save(self, *args, **kwargs): super(Union, self).save(*args, **kwargs)