Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
with:
context: .
file: docker/Dockerfile
push: ${{ github.event.release != null }}
push: true #${{ github.event.release != null }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
sudo apt-get install libsasl2-dev libldap2-dev libssl-dev
- name: Setup Python
uses: actions/setup-python@v2
with:
Expand Down
20 changes: 10 additions & 10 deletions _lib/db.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from contextlib import contextmanager
import os
import random
import re
import sys
import time
import re
import os
from contextlib import contextmanager
from uuid import uuid4

import logbook

import click

import logbook

_DATABASE_URI_RE = re.compile(r"(?P<driver>(?P<db_type>sqlite|postgresql)(\+.*)?):\/\/(?P<host>[^/]*)\/(?P<db>.+)")

Expand All @@ -24,14 +22,15 @@ def _create_sqlite(path):

def _create_postgres(match):
import sqlalchemy

from flask_app.models import db

uri = match.group(0)
db_name = match.group('db')
try:
sqlalchemy.create_engine(uri).connect()
sqlalchemy.create_engine(uri, server_sider_cursors=True).connect()
except sqlalchemy.exc.OperationalError:
engine = sqlalchemy.create_engine('{}://{}/postgres'.format(match.group('driver'), match.group('host')))
engine = sqlalchemy.create_engine('{}://{}/postgres'.format(match.group('driver'), match.group('host')), server_sider_cursors=True)
conn = engine.connect()
conn.execute("commit")
conn.execute("create database {} with encoding = 'UTF8'".format(db_name))
Expand Down Expand Up @@ -77,7 +76,7 @@ def wait(num_retries=60, retry_sleep_seconds=1):
if retry > 0:
time.sleep(retry_sleep_seconds)
try:
sqlalchemy.create_engine(uri).connect()
sqlalchemy.create_engine(uri, server_sider_cursors=True).connect()
except sqlalchemy.exc.OperationalError as e:
if 'does not exist' in str(e):
break
Expand Down Expand Up @@ -130,9 +129,10 @@ def downgrade():

@contextmanager
def _migrate_context(app=None):
import flask_migrate

from flask_app.app import create_app
from flask_app.models import db
import flask_migrate
if app is None:
app = create_app()

Expand Down
1 change: 1 addition & 0 deletions flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def create_app(config=None, setup_logging=True):
app.config.update(yaml.full_load(yaml_file))

app.config.update(config)
print(app.config)

app.before_request(profile_request_start)
app.after_request(profile_request_end)
Expand Down
4 changes: 4 additions & 0 deletions flask_app/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def testing_login():
def login():

credentials = request.get_json(silent=True)
_logger.info(f"Credentials request: {credentials}")
if not isinstance(credentials, dict):
error_abort('Credentials provided are not a JSON object')

Expand All @@ -66,11 +67,13 @@ def login():

def _login_with_credentials(credentials):
config = get_runtime_config_private_dict()
_logger.info(f"Private conf: {config}")
username = credentials.get('username')
password = credentials.get('password')

email = _fix_email(username, config)
user = User.query.filter_by(email=email).first()
_logger.info(f"Found user: {user}")

if current_app.config['TESTING']:
if user is None:
Expand All @@ -82,6 +85,7 @@ def _login_with_credentials(credentials):

if user is not None and user.password:
if verify_password(password, user.password):
_logger.info(f"password: {password} db password: {user.password}")
login_user(user)
return _make_success_login_response(user)
_logger.debug('Could not login user locally (no user or password mismatch)')
Expand Down
1 change: 1 addition & 0 deletions flask_app/utils/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def get_oauth2_identity_azure(auth_code, redirect_uri):
"""Gets identity from azure auth_code"""

config_dict = config.get_runtime_config_private_dict()
_logger.info(f"PRivate Config: {config_dict}")
client_id = config_dict['azure_oauth2_client_id']
client_secret = config_dict['azure_oauth2_client_secret']
authority = f"https://login.microsoftonline.com/{config_dict['azure_oauth2_tenant_id']}"
Expand Down