mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into notify-678
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import pathlib
|
||||
from functools import partial
|
||||
from time import monotonic
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
import jinja2
|
||||
from flask import (
|
||||
@@ -36,7 +37,6 @@ from werkzeug.local import LocalProxy
|
||||
from app import proxy_fix
|
||||
from app.asset_fingerprinter import asset_fingerprinter
|
||||
from app.config import configs
|
||||
from app.custom_auth import CustomBasicAuth
|
||||
from app.extensions import redis_client, zendesk_client
|
||||
from app.formatters import (
|
||||
convert_to_boolean,
|
||||
@@ -121,7 +121,6 @@ from app.url_converters import (
|
||||
login_manager = LoginManager()
|
||||
csrf = CSRFProtect()
|
||||
talisman = Talisman()
|
||||
basic_auth = CustomBasicAuth()
|
||||
|
||||
|
||||
# The current service attached to the request stack.
|
||||
@@ -234,8 +233,6 @@ def create_app(application):
|
||||
login_manager.session_protection = None
|
||||
login_manager.anonymous_user = AnonymousUser
|
||||
|
||||
setup_basic_auth(application)
|
||||
|
||||
# make sure we handle unicode correctly
|
||||
redis_client.redis_store.decode_responses = True
|
||||
|
||||
@@ -254,6 +251,7 @@ def create_app(application):
|
||||
|
||||
|
||||
def init_app(application):
|
||||
application.before_request(redirect_notify_to_beta)
|
||||
application.before_request(load_service_before_request)
|
||||
application.before_request(load_organization_before_request)
|
||||
application.before_request(request_helper.check_proxy_header_before_request)
|
||||
@@ -332,6 +330,23 @@ def make_session_permanent():
|
||||
session.permanent = True
|
||||
|
||||
|
||||
def create_beta_url(url):
|
||||
url_created = urlparse(url)
|
||||
url_list = list(url_created)
|
||||
url_list[1] = "beta.notify.gov"
|
||||
url_for_redirect = urlunparse(url_list)
|
||||
return url_for_redirect
|
||||
|
||||
|
||||
def redirect_notify_to_beta():
|
||||
if (
|
||||
current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||
and "beta.notify.gov" not in request.url
|
||||
):
|
||||
url_to_beta = create_beta_url(request.url)
|
||||
return redirect(url_to_beta, 302)
|
||||
|
||||
|
||||
def load_service_before_request():
|
||||
if "/static/" in request.url:
|
||||
request_ctx.service = None
|
||||
@@ -565,7 +580,3 @@ def init_jinja(application):
|
||||
]
|
||||
jinja_loader = jinja2.FileSystemLoader(template_folders)
|
||||
application.jinja_loader = jinja_loader
|
||||
|
||||
|
||||
def setup_basic_auth(application):
|
||||
application.basic_auth = CustomBasicAuth(application)
|
||||
|
||||
Reference in New Issue
Block a user