import requests
import json


def get_current_user_info(anchore_auth):
    """
    Return the metadata about the current user as supplied by the anchore.io service. Includes permissions and tier access.

    :return: Dict of user metadata
    """

    user_url = anchore_auth['client_info_url'] + '/' + anchore_auth['username']
    user_timeout = 60
    retries = 3
    result = requests.get(user_url, headers={'x-anchore-password': anchore_auth['password']})
    if result.status_code == 200:
        user_data = json.loads(result.content)
    else:
        raise requests.HTTPError('Error response from service: {}'.format(result.status_code))
    return user_data