0001-handle-the-correctly-authorized_scopes-attribute-for.patch
authentic2_idp_oauth2/models.py | ||
---|---|---|
1 | 1 |
from django.core.exceptions import ValidationError |
2 |
from django.core.validators import RegexValidator |
|
2 | 3 |
from django.db import models |
3 | 4 |
from django.utils.translation import ugettext_lazy as _ |
4 | 5 |
from django.template import Template |
... | ... | |
8 | 9 |
from authentic2.models import LogoutUrlAbstract |
9 | 10 |
from authentic2.managers import GetBySlugManager |
10 | 11 | |
12 | ||
13 | ||
11 | 14 |
class A2Client(LogoutUrlAbstract, Client): |
12 | 15 | |
13 | 16 |
authorized_scopes = models.CharField('automatically granted scopes', |
14 |
max_length=256, blank=True, null=True, |
|
15 |
help_text=_('space separated scopes')) |
|
17 |
max_length=256, blank=True, |
|
18 |
help_text=_('space separated scopes'), |
|
19 |
validators = [RegexValidator(('^[a-z]+([ \+][a-z]+)+$'))] |
|
20 |
) |
|
16 | 21 |
class Meta: |
17 | 22 |
verbose_name = _('client') |
18 | 23 |
verbose_name_plural = _('clients') |
19 | 24 | |
25 |
def clean(self): |
|
26 |
self.authorized_scopes = self.authorized_scopes.strip() |
|
27 | ||
20 | 28 | |
21 | 29 |
class AttributeRelease(models.Model): |
22 | 30 |
client = models.ForeignKey(A2Client, verbose_name=_('client')) |
authentic2_idp_oauth2/views.py | ||
---|---|---|
91 | 91 | |
92 | 92 |
automatic_grant = app_settings.AUTOMATIC_GRANT |
93 | 93 |
if hasattr(client, 'a2client'): |
94 |
client_scopes = client.a2client.authorized_scopes.split(' ') |
|
94 |
client_scopes = client.a2client.authorized_scopes |
|
95 |
client_scopes = filter(None, map(unicode.strip, client_scopes.strip().split(' '))) |
|
95 | 96 |
automatic_grant += ((client.url, client_scopes),) |
96 | 97 | |
97 | 98 |
for url_prefix, scopes in automatic_grant: |
98 |
- |