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 }
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)
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') })
def reset(): authz.require(authz.logged_in()) session.clear() return redirect(url_for('base.index'))
def authorize(): return oauth_provider.authorize(callback=url_for('auth.callback'))