Exemple #1
0
def check_auth(func):
    @wraps(func)
    def wrapped(*args, **kwargs):
        if not (is_staff("cs61a") and is_admin(email=get_user()["email"])):
            return login()
        return func(*args, **kwargs)

    return wrapped


create_oauth_client(app, "hosted-apps")

dna_api = dna.create_api_client(precheck=check_auth)
app.register_blueprint(dna_api, url_prefix="/dna")

dna_logs = dna.create_logs_client(precheck=check_auth)
app.register_blueprint(dna_logs, url_prefix="/logs")

# PR Proxy Setup
from dna.utils import Certbot
from dna.utils.nginx_utils import Server, Location
from common.rpc.hosted import create_pr_subdomain

proxy_cb = Certbot(CERTBOT_ARGS + ["-i", "nginx"])
pr_confs = f"{os.getcwd()}/data/pr_proxy"

if not os.path.exists(pr_confs):
    os.makedirs(pr_confs)

if not os.path.exists(f"/etc/nginx/conf.d/hosted_pr_proxy.conf"):
    with open(f"/etc/nginx/conf.d/hosted_pr_proxy.conf", "w") as f: