Revision 2f8a7c0e

b/snf-astakos-app/astakos/api/services.py
98 98
        ],
99 99
        'resources': {},
100 100
    },
101

  
102
    'astakos_oa2': {
103
        'type': 'astakos_auth',
104
        'component': 'astakos',
105
        'prefix': 'oa2',
106
        'public': True,
107
        'endpoints': [
108
            {'versionId': '',
109
             'publicURL': None},
110
        ],
111
        'resources': {},
112
    }
113 101
}
102

  
103
from astakos.oa2.services import oa2_services
104
astakos_services.update(oa2_services)
b/snf-astakos-app/astakos/im/settings.py
55 55
KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_identity.prefix')
56 56
WEBLOGIN_PREFIX = get_path(astakos_services, 'astakos_weblogin.prefix')
57 57
ADMIN_PREFIX = get_path(astakos_services, 'astakos_admin.prefix')
58
OA2_PREFIX = get_path(astakos_services, 'astakos_oa2.prefix')
59 58

  
60 59
# Set the expiration time of newly created auth tokens
61 60
# to be this many hours after their creation time.
b/snf-astakos-app/astakos/oa2/backends/base.py
197 197
    __metaclass__ = BackendBase
198 198

  
199 199
    base_url = ''
200
    endpoints_prefix = '/oa2/'
200
    endpoints_prefix = 'oa2/'
201 201

  
202 202
    token_endpoint = 'token/'
203 203
    token_length = 30
204
    token_expires = 300
204
    token_expires = 20
205 205

  
206 206
    authorization_endpoint = 'auth/'
207 207
    authorization_code_length = 60
......
217 217
    code_model = AuthorizationCode
218 218
    user_model = User
219 219

  
220
    def __init__(self, base_url='', endpoints_prefix='/oa2/', id='oa2',
221
                 **kwargs):
220
    def __init__(self, base_url='', endpoints_prefix='oa2/', id='oa2',
221
                 token_endpoint='token/', token_length=30,
222
                 token_expires=20, authorization_endpoint='auth/',
223
                 authorization_code_length=60, **kwargs):
222 224
        self.base_url = base_url
223 225
        self.endpoints_prefix = endpoints_prefix
226
        self.token_endpoint = token_endpoint
227
        self.token_length = token_length
228
        self.token_expires = token_expires
229
        self.authorization_endpoint = authorization_endpoint
230
        self.authorization_code_length = authorization_code_length
224 231
        self.id = id
225 232
        self._errors_to_http = kwargs.get('errors_to_http', True)
226 233

  
b/snf-astakos-app/astakos/oa2/backends/djangobackend.py
12 12
from django.http import HttpResponseNotAllowed
13 13
from django.views.decorators.csrf import csrf_exempt
14 14

  
15
from synnefo.lib import join_urls
16

  
15 17
import logging
16 18
logger = logging.getLogger(__name__)
17 19

  
......
104 106
        return oa2base.Request(**params)
105 107

  
106 108
    def get_url_patterns(self):
107
        sep = '/' if self.endpoints_prefix else ''
108 109
        _patterns = patterns(
109 110
            '',
110
            url(r'^%s%sauth/?$' % (self.endpoints_prefix, sep),
111
            url(r'^%s/?$' % join_urls(self.endpoints_prefix,
112
                                      self.authorization_endpoint.rstrip('/')),
111 113
                self.auth_view,
112 114
                name='%s_authenticate' % self.id),
113
            url(r'^%s%stoken/?$' % (self.endpoints_prefix, sep),
115
            url(r'^%s/?$' % join_urls(self.endpoints_prefix,
116
                                      self.token_endpoint.rstrip('/')),
114 117
                self.token_view,
115 118
                name='%s_token' % self.id),
116 119
        )
b/snf-astakos-app/astakos/oa2/services.py
1
# Copyright (C) 2013 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33

  
34

  
35
oa2_services = {
36
    'astakos_oa2': {
37
        'type': 'astakos_auth',
38
        'component': 'astakos',
39
        'prefix': 'oa2',
40
        'public': True,
41
        'endpoints': [
42
            {'versionId': '',
43
             'publicURL': None},
44
        ],
45
        'resources': {},
46
    }
47
}
b/snf-astakos-app/astakos/oa2/settings.py
5 5
    return getattr(settings, 'OA2_%s' % key, default)
6 6

  
7 7
USER_MODEL = get_setting('USER_MODEL', 'auth.User')
8

  
9
ENDPOINT_PREFIX = get_setting('ENDPOINT_PREFIX', 'oa2/')
10

  
11
TOKEN_ENDPOINT = get_setting('TOKEN_ENDPOINT', 'token/')
12

  
13
AUTHORIZATION_ENDPOINT = get_setting('AUTHORIZATION_ENDPOINT', 'auth/')
14

  
15
# Set the length of newly created authorization codes to 60 characters
16
AUTHORIZATION_CODE_LENGTH = get_setting('AUTHORIZATION_CODE_LENGTH', 60)
17

  
18
# Set the length of newly created access tokens to 30 characters
19
TOKEN_LENGTH = get_setting('TOKEN_LENGTH', 30)
20

  
21
# Set the expiration time of newly created access tokens to 20 seconds
22
TOKEN_EXPIRES = get_setting('TOKEN_EXPIRES', 20)
b/snf-astakos-app/astakos/oa2/urls.py
33 33

  
34 34
from astakos.oa2.backends import DjangoBackend
35 35

  
36
oa2_backend = DjangoBackend(endpoints_prefix='')
36
from astakos.oa2 import settings
37

  
38
oa2_backend = DjangoBackend(endpoints_prefix=settings.ENDPOINT_PREFIX,
39
                            token_endpoint=settings.TOKEN_ENDPOINT,
40
                            token_length=settings.TOKEN_LENGTH,
41
                            token_expires=settings.TOKEN_EXPIRES,
42
                            authorization_endpoint=
43
                            settings.AUTHORIZATION_ENDPOINT,
44
                            authorization_code_length=
45
                            settings.AUTHORIZATION_CODE_LENGTH)
37 46
urlpatterns = oa2_backend.get_url_patterns()
b/snf-astakos-app/astakos/scripts/snf_service_export.py
72 72
        'resources': {},
73 73
    },
74 74

  
75
    'astakos_oa2': {
76
        'type': 'astakos_auth',
77
        'component': 'astakos',
78
        'prefix': 'oa2',
79
        'public': True,
80
        'endpoints': [
81
            {'versionId': '',
82
             'publicURL': None},
83
        ],
84
        'resources': {},
85
    }
86 75
}
87 76

  
77
from astakos.oa2.services import oa2_services
78
astakos_services.update(oa2_services)
79

  
88 80
cyclades_services = {
89 81
    'cyclades_compute': {
90 82
        'type': 'compute',
b/snf-astakos-app/astakos/urls.py
34 34
from django.conf.urls import include, patterns
35 35

  
36 36
from astakos.im.settings import BASE_PATH, ACCOUNTS_PREFIX, \
37
    VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX, ADMIN_PREFIX, OA2_PREFIX
37
    VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX, ADMIN_PREFIX
38 38
from snf_django.lib.api.utils import prefix_pattern
39 39
from snf_django.utils.urls import \
40 40
    extend_with_root_redirects, extend_endpoint_with_slash
......
53 53
    (prefix_pattern(KEYSTONE_PREFIX), include('astakos.api.keystone_urls')),
54 54
    (prefix_pattern(WEBLOGIN_PREFIX), include('astakos.im.weblogin_urls')),
55 55
    (prefix_pattern(ADMIN_PREFIX), include('astakos.admin.admin_urls')),
56
    (prefix_pattern(OA2_PREFIX), include('astakos.oa2.urls')),
56
    ('', include('astakos.oa2.urls')),
57 57
)
58 58

  
59

  
60 59
urlpatterns += patterns(
61 60
    '',
62 61
    (prefix_pattern(BASE_PATH), include(astakos_patterns)),
b/snf-astakos-app/conf/20-snf-astakos-oa2-app-settings.py
1
#USER_MODEL = get_setting('USER_MODEL', 'auth.User')
2
#
3
#ENDPOINT_PREFIX = get_setting('ENDPOINT_PREFIX', 'oa2/')
4
#
5
#TOKEN_ENDPOINT = get_setting('TOKEN_ENDPOINT', 'token/')
6
#
7
#AUTHORIZATION_ENDPOINT = get_setting('AUTHORIZATION_ENDPOINT', 'auth/')
8
#
9
## Set the length of newly created authorization codes to 60 characters
10
#AUTHORIZATION_CODE_LENGTH = get_setting('AUTHORIZATION_CODE_LENGTH', 60)
11
#
12
## Set the length of newly created access tokens to 30 characters
13
#TOKEN_LENGTH = get_setting('TOKEN_LENGTH', 30)
14
#
15
## Set the expiration time of newly created access tokens to 20 seconds
16
#TOKEN_EXPIRES = get_setting('TOKEN_EXPIRES', 20)

Also available in: Unified diff