2016-02-05 19 views
0

我pipline低於使用Python-社會AUTH我期待訪問哪些後端供應商的人正在使用的管道

PIPELINE = (
    'social.pipeline.social_auth.social_details', 
    'social.pipeline.social_auth.social_uid', 
    'social.pipeline.social_auth.auth_allowed', 
    'social.pipeline.social_auth.social_user', 
    'create_user_and_set_email_as_username', 
    'social.pipeline.social_auth.associate_by_email', 
    'social.pipeline.social_auth.associate_user', 
    'social.pipeline.social_auth.load_extra_data', 
    'social.pipeline.user.user_details', 
    ) 

create_user_and_set_email_as_username的中間是我建立做一些額外的功能事情給用戶。現在到了這個階段,我希望能夠啓動那些不使用特定oauth客戶端的用戶。 (我們有一些企業客戶想強迫員工使用azure oauth2)。

我不知道如何訪問該函數中當前使用的後端。 IE瀏覽者剛剛點擊的內容以及他們嘗試使用的服務。嘗試pdb'ing和看戰略的組成部分,但沒有看到有用的東西。

我是否試圖在正確的地方做到這一點?

如何訪問他們嘗試使用的後端。嘗試了strategy.get_backends(),但列表可能不是當前的列表。

回答

0

我想出了我的意思。

expected_oauth_provider是你想讓他們使用。然後,在添加到管道中的任何函數中,您應該使用** kwargs並可以訪問它們真正在那裏使用的內容。

if expected_oauth_provider != kwargs.get('backend').name: 
    return HttpResponse("You cannot use your companies accounts that are not " + rule.force_oauth_provider, status=405) 
相關問題