def api_access_config(request, template_name='im/api_access_config.html', content_type='text/plain', extra_context=None, filename='.kamakirc'): if settings.KAMAKI_CONFIG_CLOUD_NAME: cloud_name = settings.KAMAKI_CONFIG_CLOUD_NAME else: cloud_name = branding_settings.SERVICE_NAME.replace(' ', '_').lower() url = get_public_endpoint(settings.astakos_services, 'identity') context = { 'user': request.user, 'services': Component.catalog(), 'token_url': url, 'cloud_name': cloud_name } extra_context = extra_context or {} context.update(extra_context) content = branding.render_to_string(template_name, context, RequestContext(request)) response = HttpResponse(content_type=content_type) response.status_code = 200 response['Content-Disposition'] = 'attachment; filename="%s"' % filename response.content = content return response
def extend_with_root_redirects(patterns_obj, filled_services, service_type, base_path): """ Append additional redirect url entries for `/` and `/<base_path>` paths. `/` redirects to `/<base_path>` and `/<base_path>` to the resolved service type url. This is used in synnefo components root urlpatterns to append sane default redirects to the chosen service url. """ service_url = get_public_endpoint(filled_services, service_type) root_url_entry = None if base_path and base_path != '/': # redirect slash to /<base_path>/ root_url_entry = url( '^$', 'redirect_to', {'url': join_urls('/', base_path.rstrip('/'), '/')}) base_path_pattern = prefix_pattern(base_path) + '$' base_path_pattern_no_slash = prefix_pattern(base_path).rstrip('/') + '$' # redirect /<base_path> and /<base_path>/ to service_url public endpoint base_url_entry = url(base_path_pattern, 'redirect_to', {'url': service_url}) base_url_entry_no_slash = url(base_path_pattern_no_slash, 'redirect_to', {'url': service_url}) # urls order matter. Setting base_url_entry first allows us to avoid # redirect loops when base_path is empty or `/` patterns_obj += patterns('django.views.generic.simple', base_url_entry, base_url_entry_no_slash) if root_url_entry: # register root entry only for non root base_path deployments patterns_obj += patterns('django.views.generic.simple', root_url_entry)
def api_access(request, template_name='im/api_access.html', extra_context=None): """ API access view. """ context = {} url = get_public_endpoint(settings.astakos_services, 'identity') context['services'] = Component.catalog() context['token_url'] = url context['user'] = request.user context['client_url'] = settings.API_CLIENT_URL if extra_context: context.update(extra_context) context_instance = get_context(request, context) return render_response(template_name, context_instance=context_instance)
# they share the PITHOS_ settings prefix for most of their settings. BASE_URL = getattr(settings, 'PITHOS_BASE_URL', "https://object-store.example.synnefo.org/pithos/") BASE_HOST, BASE_PATH = parse_base_url(BASE_URL) pithos_services = deepcopy(vanilla_pithos_services) fill_endpoints(pithos_services, BASE_URL) PITHOS_PREFIX = get_path(pithos_services, 'pithos_object-store.prefix') PUBLIC_PREFIX = get_path(pithos_services, 'pithos_public.prefix') UI_PREFIX = get_path(pithos_services, 'pithos_ui.prefix') if not BASE_PATH.startswith("/"): BASE_PATH = "/" + BASE_PATH PITHOS_URL = get_public_endpoint(pithos_services, 'object-store', 'v1') PITHOS_UI_URL = get_public_endpoint(pithos_services, 'pithos_ui', '') AUTH_COOKIE_NAME = getattr(settings, 'PITHOS_UI_AUTH_COOKIE_NAME', '_pithos2_a') CLOUDBAR_ACTIVE_SERVICE = getattr(settings, 'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE', 'pithos') # -------------------------------------------------------------------- # Process Astakos settings ASTAKOS_ACCOUNT_PROXY_PATH = join_urls( '/', pithos_settings.ASTAKOS_ACCOUNT_PROXY_PATH) ASTAKOS_UI_PROXY_PATH = join_urls('/', pithos_settings.ASTAKOS_UI_PROXY_PATH)
# Service Token acquired by identity provider. SERVICE_TOKEN = getattr(settings, 'PITHOS_SERVICE_TOKEN', '') RADOS_STORAGE = getattr(settings, 'PITHOS_RADOS_STORAGE', False) RADOS_POOL_BLOCKS = getattr(settings, 'PITHOS_RADOS_POOL_BLOCKS', 'blocks') RADOS_POOL_MAPS = getattr(settings, 'PITHOS_RADOS_POOL_MAPS', 'maps') # This enables a ui compatibility layer for the introduction of UUIDs in # identity management. WARNING: Setting to True will break your installation. TRANSLATE_UUIDS = getattr(settings, 'PITHOS_TRANSLATE_UUIDS', False) # Set PROXY_USER_SERVICES to True to have snf-pithos-app handle all Astakos # user-visible services (feedback, login, etc.) by proxying them to a running # Astakos. # Set to False if snf astakos-app is running on the same machine, so it handles # the requests on its own. PROXY_USER_SERVICES = getattr(settings, 'PITHOS_PROXY_USER_SERVICES', True) # Set how many random bytes to use for constructing the URL of Pithos public files PUBLIC_URL_SECURITY = getattr(settings, 'PITHOS_PUBLIC_URL_SECURITY', 16) # Set the alphabet to use for constructing the URL of Pithos public files PUBLIC_URL_ALPHABET = getattr( settings, 'PITHOS_PUBLIC_URL_ALPHABET', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') ASTAKOS_UI_URL = get_public_endpoint(astakos_services, 'astakos_ui', '').rstrip('/') # Astakos login URL to redirect if the user information is missing LOGIN_URL = join_urls(ASTAKOS_UI_URL, 'login')
# they share the PITHOS_ settings prefix for most of their settings. BASE_URL = getattr(settings, 'PITHOS_BASE_URL', "https://object-store.example.synnefo.org/pithos/") BASE_HOST, BASE_PATH = parse_base_url(BASE_URL) pithos_services = deepcopy(vanilla_pithos_services) fill_endpoints(pithos_services, BASE_URL) PITHOS_PREFIX = get_path(pithos_services, 'pithos_object-store.prefix') PUBLIC_PREFIX = get_path(pithos_services, 'pithos_public.prefix') UI_PREFIX = get_path(pithos_services, 'pithos_ui.prefix') if not BASE_PATH.startswith("/"): BASE_PATH = "/" + BASE_PATH PITHOS_URL = get_public_endpoint(pithos_services, 'object-store', 'v1') PITHOS_UI_URL = get_public_endpoint(pithos_services, 'pithos_ui', '') AUTH_COOKIE_NAME = getattr(settings, 'PITHOS_UI_AUTH_COOKIE_NAME', '_pithos2_a') CLOUDBAR_ACTIVE_SERVICE = getattr( settings, 'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE', 'pithos') # -------------------------------------------------------------------- # Process Astakos settings ASTAKOS_ACCOUNT_PROXY_PATH = join_urls(
# Service Token acquired by identity provider. SERVICE_TOKEN = getattr(settings, 'PITHOS_SERVICE_TOKEN', '') RADOS_STORAGE = getattr(settings, 'PITHOS_RADOS_STORAGE', False) RADOS_POOL_BLOCKS= getattr(settings, 'PITHOS_RADOS_POOL_BLOCKS', 'blocks') RADOS_POOL_MAPS = getattr(settings, 'PITHOS_RADOS_POOL_MAPS', 'maps') # This enables a ui compatibility layer for the introduction of UUIDs in # identity management. WARNING: Setting to True will break your installation. TRANSLATE_UUIDS = getattr(settings, 'PITHOS_TRANSLATE_UUIDS', False) # Set PROXY_USER_SERVICES to True to have snf-pithos-app handle all Astakos # user-visible services (feedback, login, etc.) by proxying them to a running # Astakos. # Set to False if snf astakos-app is running on the same machine, so it handles # the requests on its own. PROXY_USER_SERVICES = getattr(settings, 'PITHOS_PROXY_USER_SERVICES', True) # Set how many random bytes to use for constructing the URL of Pithos public files PUBLIC_URL_SECURITY = getattr(settings, 'PITHOS_PUBLIC_URL_SECURITY', 16) # Set the alphabet to use for constructing the URL of Pithos public files PUBLIC_URL_ALPHABET = getattr( settings, 'PITHOS_PUBLIC_URL_ALPHABET', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') ASTAKOS_UI_URL = get_public_endpoint(astakos_services, 'astakos_ui', '').rstrip('/') # Astakos login URL to redirect if the user information is missing LOGIN_URL = join_urls(ASTAKOS_UI_URL, 'login')