OAuth2:保護非用戶資源 (OAuth2: Protecting non-user resources)


問題描述

OAuth2:保護非用戶資源 (OAuth2: Protecting non‑user resources)

我有一個 API。假設它允許用戶在排行榜上更新他們的分數。這使用 OAuth2。

代表用戶使用 OAuth2 的客戶端擁有 32 個字符的 ID 和機密。

我也有一些“公共”資源,不歸用戶所有。比如說獲取整體排行榜。

我希望客戶能夠通過 API 訪問它們。然而,這些客戶可能不是用戶(其他網站說),實現 OAuth 流程似乎過於復雜。但是,我還希望客戶能夠識別自己以跟踪誰在使用它,並在需要時實施速率檢查。

OAuth2 中有什麼允許這樣做的嗎?client_credentials 用於“受信任的客戶”,而這些不會是這樣的。

或者,我是否對這些端點使用不同形式的身份驗證,以便客戶端執行 Authorization: Token [CLIENT_ID] 而不是 Authorization: Bearer [OAUTH2_TOKEN]?


參考解法

方法 1:

For the non‑protected resources, you can put those on the internet without any OAuth protection.

However, if you do that, you can't really trust the information the client sends you. So it depends on how important it is to validate the client ID they send.

If it's for throttling, that might be enough justification to run that through OAuth so someone doesn't lie about their client ID and steal someone else's bandwith. But that's a judgement call.

If you need to trust the information that they're sending in, even if it's just an identifier, then you're probably better off having them send in their access token, rather than coming up with a special protocol & definition of a different token.

Or just trust the ID they send.

(by Apemantussea‑rob)

參考文件

  1. OAuth2: Protecting non‑user resources (CC BY‑SA 2.5/3.0/4.0)

#oauth-2.0 #API #REST






相關問題

OAuth2 用戶映射和丟失我的 Cookie (OAuth2 User Mapping and Loosing my Cookies)

如何在打開 Facebook 登錄對話框之前告訴 iPhone 應用用戶會發生什麼 (How to tell an iphone app user what will happen before opening Facebook login dialogue)

帶有 spring-security 的 OAuth2 - 通過 HTTP 方法限制 REST 訪問 (OAuth2 with spring-security - limit REST access by HTTP method)

帶有Phonegap 2.3.0的Facebook oAuth沒有在成功url返回令牌作為url參數 (Facebook oAuth with Phonegap 2.3.0 not returning token as url param at success url)

Dwolla API Key、Client_id 和 Client_Secret 有什麼區別? (What is the different between Dwolla API Key, Client_id & Client_Secret?)

Linkedin 應用程序具有 OAuth 用戶令牌和 OAuth 用戶密鑰,它們會過期嗎? (Linkedin Application has OAuth User Token and OAuth User Secret, Do they Expire?)

OAuth2:保護非用戶資源 (OAuth2: Protecting non-user resources)

IOS的foursquare oauth2 (foursquare oauth2 for IOS)

Spring Boot 2 Oauth 如何實現隱式代碼流 (Spring Boot 2 Oauth how to implement Implicit Code Flow)

FusionAuth - 基於邀請的用戶登錄與社交登錄 (FusionAuth - Invite based user on-boarding with social logins)

為什麼每次發送請求時都刷新訪問令牌是個壞主意? (Why is it a bad idea to refresh access token every time when I sent request?)

如何配置必須使用“密碼”授權類型從授權服務器請求令牌的客戶端 Java 應用程序? (How do I configure a client Java application which must request a token from an authorization server using a 'password' grant type?)







留言討論