0001-auth2_fc-set-default-scopes-to-profile-and-email-392.patch
src/authentic2_auth_fc/app_settings.py | ||
---|---|---|
128 | 128 | |
129 | 129 |
@property |
130 | 130 |
def scopes(self): |
131 |
return self._setting('SCOPES', []) |
|
131 |
return self._setting('SCOPES', ['profile', 'email'])
|
|
132 | 132 | |
133 | 133 |
@property |
134 | 134 |
def popup(self): |
src/authentic2_auth_fc/views.py | ||
---|---|---|
159 | 159 | |
160 | 160 |
class FcOAuthSessionViewMixin(LoggerMixin): |
161 | 161 |
'''Add the OAuth2 dance to a view''' |
162 |
scopes = ['openid', 'profile', 'birth', 'email'] |
|
163 | 162 |
redirect_field_name = REDIRECT_FIELD_NAME |
164 | 163 |
in_popup = False |
165 | 164 |
token = None |
... | ... | |
210 | 209 |
return self.redirect(request, next_url=there, *args, **kwargs) |
211 | 210 | |
212 | 211 |
def get_scopes(self): |
213 |
if app_settings.scopes: |
|
214 |
return list(set(['openid'] + app_settings.scopes)) |
|
215 |
else: |
|
216 |
return self.scopes |
|
212 |
return list(set(['openid'] + app_settings.scopes)) |
|
217 | 213 | |
218 | 214 |
def get_ressource(self, url, verify): |
219 | 215 |
try: |
... | ... | |
327 | 323 |
elif 'error' in request.GET: |
328 | 324 |
return self.authorization_error(request, *args, **kwargs) |
329 | 325 |
else: |
326 |
scopes = self.get_scopes() |
|
330 | 327 |
if 'fd_scopes' in request.GET: |
331 |
scopes = request.GET.get('fd_scopes') |
|
332 |
scopes = scopes.split() |
|
333 |
self.scopes.extend(scopes) |
|
334 |
return ask_authorization(request, self.get_scopes(), self.logger) |
|
328 |
scopes = list(set(scopes) | set(request.GET['fd_scopes'].split())) |
|
329 |
return ask_authorization(request, scopes, self.logger) |
|
335 | 330 | |
336 | 331 | |
337 | 332 |
class PopupViewMixin(object): |
tests/auth_fc/test_auth_fc.py | ||
---|---|---|
78 | 78 |
assert 'client_id' in parsed |
79 | 79 |
assert parsed['client_id'] == 'xxx' |
80 | 80 |
assert 'scope' in parsed |
81 |
assert set(parsed['scope'].split()) == set(['openid', 'profile', 'birth', 'email'])
|
|
81 |
assert set(parsed['scope'].split()) == set(['openid', 'profile', 'email']) |
|
82 | 82 |
assert 'state' in parsed |
83 | 83 |
assert 'nonce' in parsed |
84 | 84 |
assert parsed['state'] == parsed['nonce'] |
85 |
- |