172e4b9 baseldap: refactor validator support in add_external_pre_callback

1 file Authored by abbra 3 years ago, Committed by rcritten 3 years ago,
    baseldap: refactor validator support in add_external_pre_callback
    
    baseldap.py:add_external_pre_callback() allows to redefine validators
    used to validate member names. Originally this was done to allow
    hostname validation and reused default validators associated with other
    parameter types.
    
    Provide extension of the validator callbacks to allow fine grained
    validation strategy. This is helpful in case we want to apply an
    alternative validation strategy in case default validator fails.
    
    New validators can be added to 'member_validator' registry in a similar
    way to how API objects are registered:
    
    from .baseldap import member_validator
    
    @member_validator(membertype='foo')
    def my_new_validator(ldap, dn, keys, options, value):
        <validate value here>
    
    Arguments passed to the validator are arguments passed to the
    add_external_pre_callback() augmented with the value to validate.
    
    Fixes: https://pagure.io/freeipa/issue/3226
    Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
    Signed-off-by: Peter Keresztes Schmidt <carbenium@outlook.com>
    Reviewed-By: Christian Heimes <cheimes@redhat.com>
    Reviewed-By: Rob Crittenden <rcritten@redhat.com>
    Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
    
        
file modified
+22 -9