Commit 848bc567 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

astakos: Configure oa2 app

parent 0d800994
......@@ -98,16 +98,7 @@ astakos_services = {
],
'resources': {},
},
'astakos_oa2': {
'type': 'astakos_auth',
'component': 'astakos',
'prefix': 'oa2',
'public': True,
'endpoints': [
{'versionId': '',
'publicURL': None},
],
'resources': {},
}
}
from astakos.oa2.services import oa2_services
astakos_services.update(oa2_services)
......@@ -55,7 +55,6 @@ VIEWS_PREFIX = get_path(astakos_services, 'astakos_ui.prefix')
KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_identity.prefix')
WEBLOGIN_PREFIX = get_path(astakos_services, 'astakos_weblogin.prefix')
ADMIN_PREFIX = get_path(astakos_services, 'astakos_admin.prefix')
OA2_PREFIX = get_path(astakos_services, 'astakos_oa2.prefix')
# Set the expiration time of newly created auth tokens
# to be this many hours after their creation time.
......
......@@ -197,11 +197,11 @@ class SimpleBackend(object):
__metaclass__ = BackendBase
base_url = ''
endpoints_prefix = '/oa2/'
endpoints_prefix = 'oa2/'
token_endpoint = 'token/'
token_length = 30
token_expires = 300
token_expires = 20
authorization_endpoint = 'auth/'
authorization_code_length = 60
......@@ -217,10 +217,17 @@ class SimpleBackend(object):
code_model = AuthorizationCode
user_model = User
def __init__(self, base_url='', endpoints_prefix='/oa2/', id='oa2',
**kwargs):
def __init__(self, base_url='', endpoints_prefix='oa2/', id='oa2',
token_endpoint='token/', token_length=30,
token_expires=20, authorization_endpoint='auth/',
authorization_code_length=60, **kwargs):
self.base_url = base_url
self.endpoints_prefix = endpoints_prefix
self.token_endpoint = token_endpoint
self.token_length = token_length
self.token_expires = token_expires
self.authorization_endpoint = authorization_endpoint
self.authorization_code_length = authorization_code_length
self.id = id
self._errors_to_http = kwargs.get('errors_to_http', True)
......
......@@ -12,6 +12,8 @@ from django.conf.urls.defaults import patterns, url
from django.http import HttpResponseNotAllowed
from django.views.decorators.csrf import csrf_exempt
from synnefo.lib import join_urls
import logging
logger = logging.getLogger(__name__)
......@@ -104,13 +106,14 @@ class DjangoBackend(DjangoBackendORMMixin, oa2base.SimpleBackend,
return oa2base.Request(**params)
def get_url_patterns(self):
sep = '/' if self.endpoints_prefix else ''
_patterns = patterns(
'',
url(r'^%s%sauth/?$' % (self.endpoints_prefix, sep),
url(r'^%s/?$' % join_urls(self.endpoints_prefix,
self.authorization_endpoint.rstrip('/')),
self.auth_view,
name='%s_authenticate' % self.id),
url(r'^%s%stoken/?$' % (self.endpoints_prefix, sep),
url(r'^%s/?$' % join_urls(self.endpoints_prefix,
self.token_endpoint.rstrip('/')),
self.token_view,
name='%s_token' % self.id),
)
......
# Copyright (C) 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
oa2_services = {
'astakos_oa2': {
'type': 'astakos_auth',
'component': 'astakos',
'prefix': 'oa2',
'public': True,
'endpoints': [
{'versionId': '',
'publicURL': None},
],
'resources': {},
}
}
......@@ -5,3 +5,18 @@ def get_setting(key, default):
return getattr(settings, 'OA2_%s' % key, default)
USER_MODEL = get_setting('USER_MODEL', 'auth.User')
ENDPOINT_PREFIX = get_setting('ENDPOINT_PREFIX', 'oa2/')
TOKEN_ENDPOINT = get_setting('TOKEN_ENDPOINT', 'token/')
AUTHORIZATION_ENDPOINT = get_setting('AUTHORIZATION_ENDPOINT', 'auth/')
# Set the length of newly created authorization codes to 60 characters
AUTHORIZATION_CODE_LENGTH = get_setting('AUTHORIZATION_CODE_LENGTH', 60)
# Set the length of newly created access tokens to 30 characters
TOKEN_LENGTH = get_setting('TOKEN_LENGTH', 30)
# Set the expiration time of newly created access tokens to 20 seconds
TOKEN_EXPIRES = get_setting('TOKEN_EXPIRES', 20)
......@@ -33,5 +33,14 @@
from astakos.oa2.backends import DjangoBackend
oa2_backend = DjangoBackend(endpoints_prefix='')
from astakos.oa2 import settings
oa2_backend = DjangoBackend(endpoints_prefix=settings.ENDPOINT_PREFIX,
token_endpoint=settings.TOKEN_ENDPOINT,
token_length=settings.TOKEN_LENGTH,
token_expires=settings.TOKEN_EXPIRES,
authorization_endpoint=
settings.AUTHORIZATION_ENDPOINT,
authorization_code_length=
settings.AUTHORIZATION_CODE_LENGTH)
urlpatterns = oa2_backend.get_url_patterns()
......@@ -72,19 +72,11 @@ astakos_services = {
'resources': {},
},
'astakos_oa2': {
'type': 'astakos_auth',
'component': 'astakos',
'prefix': 'oa2',
'public': True,
'endpoints': [
{'versionId': '',
'publicURL': None},
],
'resources': {},
}
}
from astakos.oa2.services import oa2_services
astakos_services.update(oa2_services)
cyclades_services = {
'cyclades_compute': {
'type': 'compute',
......
......@@ -34,7 +34,7 @@
from django.conf.urls import include, patterns
from astakos.im.settings import BASE_PATH, ACCOUNTS_PREFIX, \
VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX, ADMIN_PREFIX, OA2_PREFIX
VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX, ADMIN_PREFIX
from snf_django.lib.api.utils import prefix_pattern
from snf_django.utils.urls import \
extend_with_root_redirects, extend_endpoint_with_slash
......@@ -53,10 +53,9 @@ astakos_patterns = patterns(
(prefix_pattern(KEYSTONE_PREFIX), include('astakos.api.keystone_urls')),
(prefix_pattern(WEBLOGIN_PREFIX), include('astakos.im.weblogin_urls')),
(prefix_pattern(ADMIN_PREFIX), include('astakos.admin.admin_urls')),
(prefix_pattern(OA2_PREFIX), include('astakos.oa2.urls')),
('', include('astakos.oa2.urls')),
)
urlpatterns += patterns(
'',
(prefix_pattern(BASE_PATH), include(astakos_patterns)),
......
#USER_MODEL = get_setting('USER_MODEL', 'auth.User')
#
#ENDPOINT_PREFIX = get_setting('ENDPOINT_PREFIX', 'oa2/')
#
#TOKEN_ENDPOINT = get_setting('TOKEN_ENDPOINT', 'token/')
#
#AUTHORIZATION_ENDPOINT = get_setting('AUTHORIZATION_ENDPOINT', 'auth/')
#
## Set the length of newly created authorization codes to 60 characters
#AUTHORIZATION_CODE_LENGTH = get_setting('AUTHORIZATION_CODE_LENGTH', 60)
#
## Set the length of newly created access tokens to 30 characters
#TOKEN_LENGTH = get_setting('TOKEN_LENGTH', 30)
#
## Set the expiration time of newly created access tokens to 20 seconds
#TOKEN_EXPIRES = get_setting('TOKEN_EXPIRES', 20)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment