def redirect_to_custom_form(request, auth_entry, kwargs):
 backend_name = request.backend.name
 provider_id = provider.Registry.get_from_pipeline({'backend': backend_name, 'kwargs': kwargs}).provider_id
 form_info = AUTH_ENTRY_CUSTOM[auth_entry]
 secret_key = form_info['secret_key']
 if isinstance(secret_key, unicode):
  secret_key = secret_key.encode('utf-8')
 custom_form_url = form_info['url']
 data_str = json.dumps({'auth_entry': auth_entry, 'backend_name': backend_name, 'provider_id': provider_id, 'user_details': kwargs['details']})
 digest = hmac.new(secret_key, msg=data_str, digestmod=hashlib.sha256).digest()
 request.session['tpa_custom_auth_entry_data'] = {'data': base64.b64encode(data_str), 'hmac': base64.b64encode(digest), 'post_url': custom_form_url}
 return redirect(reverse('tpa_post_to_custom_auth_form'))

def redirect_to_custom_form ( request , auth_entry , kwargs ) : backend_name = request . backend . name provider_id = provider . Registry . get_from_pipeline ( { 'backend' : backend_name , 'kwargs' : kwargs } ) . provider_id form_info = AUTH_ENTRY_CUSTOM [ auth_entry ] secret_key = form_info [ 'secret_key' ] if isinstance ( secret_key , unicode ) : secret_key = secret_key . encode ( 'utf-8' ) custom_form_url = form_info [ 'url' ] data_str = json . dumps ( { 'auth_entry' : auth_entry , 'backend_name' : backend_name , 'provider_id' : provider_id , 'user_details' : kwargs [ 'details' ] } ) digest = hmac . new ( secret_key , msg = data_str , digestmod = hashlib . sha256 ) . digest ( ) request . session [ 'tpa_custom_auth_entry_data' ] = { 'data' : base64 . b64encode ( data_str ) , 'hmac' : base64 . b64encode ( digest ) , 'post_url' : custom_form_url } return redirect ( reverse ( 'tpa_post_to_custom_auth_form' ) )
if auth_entry is found in auth_entry_custom .