from flask import session, request, redirect, url_for

from githubhookapp.core import app, github_api


@app.context_processor
def auth_context():
    return {
        'user': github_api('user') or {},
    }


@app.before_request
def auth_check():

    if 'access_token' in session:
        user = github_api('user')
        if (
            user['login'] not in app.config['GITHUB_ALLOWED_OWNERS'] and
            request.endpoint != 'not_authorized'
        ):
            return redirect(url_for('not_authorized'))
        return

    if request.endpoint not in ('login', 'github_login', 'github_callback'):
        return redirect(url_for('login'))

@@ -601,16 +601,26 @@
 allback'
+, 'static'
 ):%0A     

Allow static requests without authentication