a726d1f2c2d88fbd8c66560f445d28aead5c2196
[cascardo/ipsilon.git] / ipsilon / providers / openid / extensions / fas_teams.py
1 # Copyright (C) 2014  Ipsilon project Contributors, for licensee see COPYING
2
3 from __future__ import absolute_import
4
5 from ipsilon.providers.openid.extensions.teams import Teams
6 from openid_teams import teams
7
8
9 class OpenidExtension(Teams):
10
11     def __init__(self, *pargs):
12         super(OpenidExtension, self).__init__('Fedora Teams')
13
14     def _resp(self, request, userdata):
15         req = teams.TeamsRequest.fromOpenIDRequest(request)
16         if req is None:
17             return {}
18         if '_FAS_ALL_GROUPS_' in req.requested:
19             # We will send all groups the user is a member of
20             req.requested = userdata.get('_groups', [])
21         data = userdata.get('_groups', [])
22         return teams.TeamsResponse.extractResponse(req, data)