Commit 4e3030f7 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Remove PITHOS_AUTHENTICATION_USERS setting

Remove this setting as it introduces unnecessary complexity. Also,
it will need to be supported by snf-astakos-client. If needed by
tests to bypass communication with astakos, a mocking library should
be used.
parent fa7650ae
Changelog
=========
v0.14
-----
(* Unreleased *)
* Remove PITHOS_AUTHENTICATION_USERS setting
v0.13.0
------
* settings *PITHOS_PROXY_USER_SERVICES*, *PITHOS_USER_CATALOG_URL*, *PITHOS_USER_FEEDBACK_URL*,
......
......@@ -31,7 +31,6 @@ Configure in ``settings.py`` or a ``.conf`` file in ``/etc/synnefo`` if using sn
Name Default value Description
=============================== ================================================================ ============================================================
PITHOS_AUTHENTICATION_URL \https://<astakos.host>/im/authenticate/ Astakos Authentication URL
PITHOS_AUTHENTICATION_USERS A dictionary of sample users (token to username) Set to empty or None to disable
PITHOS_ASTAKOS_COOKIE_NAME _pithos2_a Cookie name to retrieve fallback token
PITHOS_BACKEND_DB_MODULE pithos.backends.lib.sqlalchemy
PITHOS_BACKEND_DB_CONNECTION sqlite:////tmp/pithos-backend.db SQLAlchemy database connection string
......
#PITHOS_AUTHENTICATION_URL = 'https://accounts.example.synnefo.org/im/authenticate/'
#PITHOS_AUTHENTICATION_USERS = {}
# Cookie name to search for fallback token
#PITHOS_ASTAKOS_COOKIE_NAME = '_pithos2_a'
......
......@@ -43,8 +43,8 @@ from django.http import (
from django.utils.http import urlencode
from django.views.decorators.csrf import csrf_exempt
from pithos.api.settings import (
AUTHENTICATION_USERS, USER_LOGIN_URL, USER_FEEDBACK_URL, USER_CATALOG_URL)
from pithos.api.settings import (USER_LOGIN_URL, USER_FEEDBACK_URL,
USER_CATALOG_URL)
from synnefo.lib.pool.http import PooledHTTPConnection
......@@ -53,8 +53,7 @@ logger = logging.getLogger(__name__)
def delegate_to_login_service(request):
url = USER_LOGIN_URL
users = AUTHENTICATION_USERS
if users or not url:
if not url:
return HttpResponseNotFound()
p = urlparse(url)
......
......@@ -61,8 +61,7 @@ from pithos.api.util import (
)
from pithos.api.settings import (UPDATE_MD5, TRANSLATE_UUIDS,
SERVICE_TOKEN, AUTHENTICATION_URL,
AUTHENTICATION_USERS)
SERVICE_TOKEN, AUTHENTICATION_URL)
from pithos.backends.base import (
NotAllowedError, QuotaError, ContainerNotEmpty, ItemNotExists,
......@@ -81,8 +80,7 @@ def get_uuids(names):
uuids = _get_uuids(SERVICE_TOKEN, names,
url=AUTHENTICATION_URL.replace(
'im/authenticate',
'service/api/user_catalogs'),
override_users=AUTHENTICATION_USERS)
'service/api/user_catalogs'))
except Exception, e:
logger.exception(e)
return {}
......
......@@ -3,7 +3,6 @@ from django.conf import settings
AUTHENTICATION_URL = getattr(settings, 'PITHOS_AUTHENTICATION_URL',
'https://accounts.example.synnefo.org/im/authenticate/')
AUTHENTICATION_USERS = getattr(settings, 'PITHOS_AUTHENTICATION_USERS', {})
ASTAKOS_URL = AUTHENTICATION_URL.replace("im/authenticate/", "")
COOKIE_NAME = getattr(settings, 'PITHOS_ASTAKOS_COOKIE_NAME', '_pithos2_a')
......
......@@ -59,7 +59,7 @@ from pithos.api.settings import (BACKEND_DB_MODULE, BACKEND_DB_CONNECTION,
QUOTAHOLDER_POOLSIZE,
BACKEND_QUOTA, BACKEND_VERSIONING,
BACKEND_FREE_VERSIONING,
AUTHENTICATION_URL, AUTHENTICATION_USERS,
AUTHENTICATION_URL,
COOKIE_NAME, USER_CATALOG_URL,
RADOS_STORAGE, RADOS_POOL_BLOCKS,
RADOS_POOL_MAPS, TRANSLATE_UUIDS,
......@@ -274,8 +274,7 @@ def is_uuid(str):
##########################
def retrieve_displayname(token, uuid, fail_silently=True):
displayname = get_displayname(
token, uuid, USER_CATALOG_URL, AUTHENTICATION_USERS)
displayname = get_displayname(token, uuid, USER_CATALOG_URL)
if not displayname and not fail_silently:
raise ItemNotExists(uuid)
elif not displayname:
......@@ -284,8 +283,7 @@ def retrieve_displayname(token, uuid, fail_silently=True):
return displayname
def retrieve_displaynames(token, uuids, return_dict=False, fail_silently=True):
catalog = get_displaynames(
token, uuids, USER_CATALOG_URL, AUTHENTICATION_USERS) or {}
catalog = get_displaynames(token, uuids, USER_CATALOG_URL) or {}
missing = list(set(uuids) - set(catalog))
if missing and not fail_silently:
raise ItemNotExists('Unknown displaynames: %s' % ', '.join(missing))
......@@ -295,15 +293,13 @@ def retrieve_uuid(token, displayname):
if is_uuid(displayname):
return displayname
uuid = get_user_uuid(
token, displayname, USER_CATALOG_URL, AUTHENTICATION_USERS)
uuid = get_user_uuid(token, displayname, USER_CATALOG_URL)
if not uuid:
raise ItemNotExists(displayname)
return uuid
def retrieve_uuids(token, displaynames, return_dict=False, fail_silently=True):
catalog = get_uuids(
token, displaynames, USER_CATALOG_URL, AUTHENTICATION_USERS) or {}
catalog = get_uuids(token, displaynames, USER_CATALOG_URL) or {}
missing = list(set(displaynames) - set(catalog))
if missing and not fail_silently:
raise ItemNotExists('Unknown uuids: %s' % ', '.join(missing))
......@@ -1007,8 +1003,7 @@ def update_response_headers(request, response):
def get_pithos_usage(token):
"""Get Pithos Usage from astakos."""
user_info = user_for_token(token, AUTHENTICATION_URL, AUTHENTICATION_USERS,
usage=True)
user_info = user_for_token(token, AUTHENTICATION_URL, usage=True)
usage = user_info.get("usage", [])
for u in usage:
if u.get('name') == 'pithos+.diskspace':
......
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