def get_login_providers_info():
    if config.get('DEFAULT_LOGIN_IDP'):
        default_idp = config['DEFAULT_LOGIN_IDP']
    elif ('default' in config.get('ENABLED_IDENTITY_PROVIDERS', {})):
        default_idp = config['ENABLED_IDENTITY_PROVIDERS']['default']
    else:
        logger.warning('DEFAULT_LOGIN_IDP not configured')
        default_idp = None
    if config['LOGIN_OPTIONS']:
        login_options = config['LOGIN_OPTIONS']
    elif ('providers' in config.get('ENABLED_IDENTITY_PROVIDERS', {})):
        enabled_providers = config['ENABLED_IDENTITY_PROVIDERS']['providers']
        login_options = [{'name': details.get('name'), 'idp': idp, 'desc': details.get('desc'), 'secondary': details.get('secondary')} for (idp, details) in enabled_providers.items()]
    else:
        logger.warning('LOGIN_OPTIONS not configured or empty')
        login_options = []
    try:
        all_provider_info = [provider_info(login_details) for login_details in login_options]
    except KeyError as e:
        raise InternalError('LOGIN_OPTIONS misconfigured: cannot find key {}'.format(e))
    default_provider_info = next((info for info in all_provider_info if (info['idp'] == default_idp)), None)
    if (not default_provider_info):
        raise InternalError('default provider misconfigured: DEFAULT_LOGIN_IDP is set to {}, which is not configured in LOGIN_OPTIONS'.format(default_idp))
    return (default_provider_info, all_provider_info)
def get_login_providers_info():
    if config.get('DEFAULT_LOGIN_IDP'):
        default_idp = config['DEFAULT_LOGIN_IDP']
    elif ('default' in config.get('ENABLED_IDENTITY_PROVIDERS', {})):
        default_idp = config['ENABLED_IDENTITY_PROVIDERS']['default']
    else:
        logger.warning('DEFAULT_LOGIN_IDP not configured')
        default_idp = None
    if config['LOGIN_OPTIONS']:
        login_options = config['LOGIN_OPTIONS']
    elif ('providers' in config.get('ENABLED_IDENTITY_PROVIDERS', {})):
        enabled_providers = config['ENABLED_IDENTITY_PROVIDERS']['providers']
        login_options = [{'name': details.get('name'), 'idp': idp, 'desc': details.get('desc'), 'secondary': details.get('secondary')} for (idp, details) in enabled_providers.items()]
    else:
        logger.warning('LOGIN_OPTIONS not configured or empty')
        login_options = []
    try:
        all_provider_info = [provider_info(login_details) for login_details in login_options]
    except KeyError as e:
        raise InternalError('LOGIN_OPTIONS misconfigured: cannot find key {}'.format(e))
    default_provider_info = next((info for info in all_provider_info if (info['idp'] == default_idp)), None)
    if (not default_provider_info):
        raise InternalError('default provider misconfigured: DEFAULT_LOGIN_IDP is set to {}, which is not configured in LOGIN_OPTIONS'.format(default_idp))
    return (default_provider_info, all_provider_info)