Exemplo n.º 1
0
 def to_dict(self):
     return {
         'name': self.name,
         'label': self.label,
         'metadata_uri': url_for('tables.view', table_name=self.name),
         'rows_uri': url_for('tables.rows', table_name=self.name),
         'columns_num': len(self.columns),
         'rows_num': 0,  # len(QueryPager(engine, q))
         'columns': self.columns
     }
Exemplo n.º 2
0
Arquivo: auth.py Projeto: occrp/ouija
def callback():
    next_url = url_for('base.index')
    resp = oauth_provider.authorized_response()
    if resp is None or isinstance(resp, OAuthException):
        # FIXME: notify the user, somehow.
        return redirect(next_url)
    session['oauth'] = resp
    session['roles'] = [authz.GUEST, authz.USER]
    if 'googleapis.com' in oauth_provider.base_url:
        me = oauth_provider.get('userinfo')
        session['user'] = {
            'id': me.data.get('id'),
            'name': me.data.get('name'),
            'email': me.data.get('email'),
            'is_admin': False
        }
        session['roles'].append(me.data.get('email'))
    elif 'occrp.org' in oauth_provider.base_url or \
            'investigativedashboard.org' in oauth_provider.base_url:
        me = oauth_provider.get('api/2/accounts/profile/')
        session['user'] = {
            'id': me.data.get('id'),
            'name': me.data.get('display_name'),
            'email': me.data.get('email'),
            'is_admin': me.data.get('is_admin', False)
        }
        session['roles'].append(me.data.get('email'))
        for group in me.data.get('groups', []):
            group_id = 'idashboard:%s' % group.get('id')
            session['roles'].append(group_id)
    else:
        raise RuntimeError("Unknown OAuth URL: %r" % oauth_provider.base_url)
    return redirect(next_url)
Exemplo n.º 3
0
Arquivo: auth.py Projeto: occrp/ouija
def get_session():
    return jsonify({
        'logged_in': request.logged_in,
        'user': request.auth_user,
        'roles': list(request.auth_roles),
        'login_uri': url_for('auth.authorize')
    })
Exemplo n.º 4
0
Arquivo: auth.py Projeto: occrp/ouija
def reset():
    authz.require(authz.logged_in())
    session.clear()
    return redirect(url_for('base.index'))
Exemplo n.º 5
0
Arquivo: auth.py Projeto: occrp/ouija
def authorize():
    return oauth_provider.authorize(callback=url_for('auth.callback'))