Revision f9d665e4

b/snf-astakos-app/astakos/admin/views.py
36 36
from django.utils import simplejson as json
37 37
from snf_django.lib import api
38 38
from astakos.im import settings
39
from synnefo.lib.services import get_path
39 40

  
40 41
from astakos.admin import stats
41 42

  
42 43
logger = logging.getLogger(__name__)
43 44

  
44 45
PERMITTED_GROUPS = settings.ADMIN_STATS_PERMITTED_GROUPS
46
try:
47
    AUTH_URL = get_path(settings.astakos_services,
48
                        "astakos_identity.endpoints")[0]["publicURL"]
49
except (IndexError, KeyError) as e:
50
    logger.error("Failed to load Astakos Auth URL: %s", e)
51
    AUTH_URL = None
45 52

  
46 53

  
47 54
@api.api_method(http_method='GET', user_required=False, token_required=False,
......
54 61

  
55 62

  
56 63
@api.api_method(http_method='GET', user_required=True, token_required=True,
64
                astakos_auth_url=AUTH_URL,
57 65
                logger=logger, serializations=['json'])
58 66
@api.user_in_groups(permitted_groups=PERMITTED_GROUPS,
59 67
                    logger=logger)
b/snf-django-lib/snf_django/lib/api/__init__.py
106 106
                # Authenticate
107 107
                if user_required:
108 108
                    assert(token_required), "Can not get user without token"
109
                    astakos = astakos_auth_url or settings.ASTAKOS_AUTH_URL
110
                    astakos = AstakosClient(token, astakos,
109
                    astakos_url = astakos_auth_url
110
                    if astakos_url is None:
111
                        try:
112
                            astakos_url = settings.ASTAKOS_AUTH_URL
113
                        except AttributeError:
114
                            logger.error("Cannot authenticate without having"
115
                                         " an Astakos Authentication URL")
116
                            raise
117
                    astakos = AstakosClient(token, astakos_url,
111 118
                                            use_pool=True,
112 119
                                            retry=2,
113 120
                                            logger=logger)

Also available in: Unified diff