Returns true if the request is authorized for the job
    if provided. If no job is provided, the user has to be admin
    to be authorized.

def is_authorized(job=None):
    '''Returns true if the request is authorized for the job
    if provided. If no job is provided, the user has to be admin
    to be authorized.
    '''
    if flogin.current_user.is_authenticated:
        return True
    if job:
        job_key = flask.request.headers.get('Authorization')
        if job_key == app.config.get('SECRET_KEY'):
            return True
        return job['job_key'] == job_key
    return False