2015-03-25 54 views
3

我想auto-autorize some trusted apps我們的軌道API與看門如何指定門衛skip_authorization塊的superapp(s)列表?

# Skip Authorization for trusted clients 
Doorkeeper.configure 
    skip_authorization do |resource_owner, client| 
    client.superapp? || resource_owner.admin? 
    end 
end 

this comment,它是應用程序能夠理解的概念。

這應該使用client_id(s)白名單來完成嗎? 如何指定superapp(s)的列表? 在此先感謝!

回答

3

Superapp是一個應該自定義實現的概念。
編號:https://github.com/doorkeeper-gem/doorkeeper/issues/488

你可以自動批准受信任的應用程序最簡單的方法是,如果你使用受信任的客戶端的應用程序ID如下圖所示:

# config/initializers/doorkeeper.rb 
    skip_authorization do |resource_owner, client| 
    client.uid == "client application id goes here" 
    end 

也許你也可以使用範圍,使客戶的範圍字段被「信任」(就我所知,直接進入數據庫)。

但是,我相信,範圍不應該以這種方式使用。他們通常會通知resource_owner它是哪種類型的客戶端,以便他/她可以選擇是否授權。
Ref:https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes

我希望這有助於!如果有人有更好的實現方法,那將會很好。

0

我認爲最好創建一個遷移來在oauth_applications表上添加一個superapp布爾型字段。

那麼你可以做

# Skip Authorization for trusted clients 
Doorkeeper.configure 
    skip_authorization do |resource_owner, client| 
    client.superapp? 
    end 
end 

如果應用程序有superapp布爾設置爲true則授權步驟將被跳過,它會自動授權無需用戶操作的應用程序。