Return a fedora.client.fas2.AccountSystem object if the provided
    configuration contains a FAS username and password.

def get_fas(config):
    """ Return a fedora.client.fas2.AccountSystem object if the provided
    configuration contains a FAS username and password.
    """
    global _FAS
    if _FAS is not None:
        return _FAS

    # In some development environments, having fas_credentials around is a
    # pain.. so, let things proceed here, but emit a warning.
    try:
        creds = config['fas_credentials']
    except KeyError:
        log.warn("No fas_credentials available.  Unable to query FAS.")
        return None

    default_url = 'https://admin.fedoraproject.org/accounts/'

    _FAS = AccountSystem(
        creds.get('base_url', default_url),
        username=creds['username'],
        password=creds['password'],
        cache_session=False,
        insecure=creds.get('insecure', False)
    )

    return _FAS