Skip to content

Commit

Permalink
Merge pull request #46 from arXiv/0.4.1-fixes
Browse files Browse the repository at this point in the history
0.4.1rc fixes
  • Loading branch information
erickpeirson committed Jul 30, 2019
2 parents 2de7be8 + c582e91 commit 61bef87
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 55 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ arxiv-vault = "==0.1.1rc14"
pytz = "*"
arxiv-auth = {path = "./users"}
mimesis = "*"
flask-sqlalchemy = "*"
"flask-s3" = "*"

[dev-packages]
mimesis = "==2.1.0"
Expand Down
140 changes: 89 additions & 51 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion accounts/accounts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import os

VERSION = '0.2'
VERSION = '0.4'
APP_VERSION = '0.4'
"""The application version."""

NAMESPACE = os.environ.get('NAMESPACE')
"""Namespace in which this service is deployed; to qualify keys for secrets."""
Expand Down Expand Up @@ -134,3 +136,10 @@
'minimum_ttl': 360000}
]
"""Requests for Vault secrets."""

FLASKS3_BUCKET_NAME = os.environ.get('FLASKS3_BUCKET_NAME', 'some_bucket')
FLASKS3_CDN_DOMAIN = os.environ.get('FLASKS3_CDN_DOMAIN', 'static.arxiv.org')
FLASKS3_USE_HTTPS = os.environ.get('FLASKS3_USE_HTTPS', 1)
FLASKS3_FORCE_MIMETYPE = os.environ.get('FLASKS3_FORCE_MIMETYPE', 1)
FLASKS3_ACTIVE = os.environ.get('FLASKS3_ACTIVE', 0)
"""Flask-S3 plugin settings."""
4 changes: 4 additions & 0 deletions accounts/accounts/factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Application factory for accounts app."""

from flask import Flask
from flask_s3 import FlaskS3

from arxiv import vault
from arxiv.base import Base
Expand All @@ -10,6 +11,8 @@
from accounts.routes import ui
from accounts.services import SessionStore, legacy, users

s3 = FlaskS3()


def create_web_app() -> Flask:
"""Initialize and configure the accounts application."""
Expand All @@ -23,6 +26,7 @@ def create_web_app() -> Flask:
app.register_blueprint(ui.blueprint)
Base(app) # Gives us access to the base UI templates and resources.
auth.Auth(app) # Handless sessions and authn/z.
s3.init_app(app)

middleware = [auth.middleware.AuthMiddleware]
if app.config['VAULT_ENABLED']:
Expand Down
7 changes: 4 additions & 3 deletions accounts/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from accounts.factory import create_web_app
import os

__flask_app__ = create_web_app()

__flask_app__ = None

def application(environ, start_response): # type: ignore
"""WSGI application."""
Expand All @@ -17,5 +16,7 @@ def application(environ, start_response): # type: ignore
if key == 'SERVER_NAME':
continue
os.environ[key] = str(value)
__flask_app__.config[key] = str(value)
global __flask_app__
if __flask_app__ is None:
__flask_app__ = create_web_app()
return __flask_app__(environ, start_response)

0 comments on commit 61bef87

Please sign in to comment.