예제 #1
0
def get_token_apps(machine=None,
                   application=None,
                   application_module=None,
                   serial=None,
                   client_ip=None,
                   challenge=None):
    '''
    This method returns the authentication data for the
    requested application and token
    
    :param machine: the machine name (optional)
    :param application: the name of the application (optional)
    :param client: the IP of the client (required)
    :param serial: the serial number of a specific token (optional)
    :param challenge: a challenge parameter, that can be passed in selfTest
    '''
    if not client_ip:
        log.warning("No client IP.")
        return {}
    if not IPAddress(client_ip):
        log.warning("No valid client IP: %r" % client_ip)
        return {}

    # if the application has allow_bulk_action set, we need to
    # remove the IP filer.
    if application_module:
        if is_application_allow_bulk_call(application_module):
            client_ip = None
    res = showtoken(machine_name=machine,
                    client_ip=client_ip,
                    application=application,
                    serial=serial)
    '''
    depending on the application type we do need to take some action
    Each application should know, what to provide...
    Determine this by
     1. application
     2. token type
     3. serial number
    '''
    machines = res.get("machines")
    if application:
        for machine in machines.values():
            # add token information
            serial = machine.get("serial")
            token_type = getTokenType(serial)
            auth_item = get_auth_item(application,
                                      application_module,
                                      token_type,
                                      serial,
                                      challenge=challenge)
            machine["auth_item"] = auth_item
            # add options
            machine_options = get_options(machinetoken_id=machine.get("id"))
            machine["options"] = machine_options
  
    return res
예제 #2
0
 def test_03_allow_bulk_call(self):
     bulk = is_application_allow_bulk_call(
         "privacyidea.lib.applications.base")
     self.assertFalse(bulk)