[英]SpringBoot OAuth2: Purpose of the .scopes() function?
我目前正在學習有關SpringBoots OAuth2.0實現的信息,並且遇到了以下教程: http : //www.tinmegali.com/en/2017/06/25/oauth2-using-spring/ 。
它包含這段代碼:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("trusted-app")
.authorizedGrantTypes("client_credentials", "password", "refresh_token")
.authorities("ROLE_TRUSTED_CLIENT")
.scopes("read", "write")
.resourceIds(resourceId)
.accessTokenValiditySeconds(accessTokenValiditySeconds)
.refreshTokenValiditySeconds(refreshTokenValiditySeconds)
.secret("secret");
}
我在互聯網上四處尋找有關scopes
函數的文檔,但是我根本找不到它的作用,包括在官方的SpringBoot API參考中。 我可以肯定地說的是,它需要多個string
參數。
上面的代碼段中scopes()
函數的作用是什么? 傳遞("read", "write")
與傳遞"all"
或完全任意的東西(例如"donkey"
("read", "write")
實際的區別是什么?
根據我的理解,這就是您的客戶體驗。 創建BaseClinetDetails.java實例時,可以為客戶端設置任何作用域,並且在進行身份驗證時,可以使用isScoped()方法檢查是否提供了任何作用域。 如果不是,則請求的范圍將被忽略。
如果isScoped()返回true,則可以使用getScope()方法獲取所有范圍,並確定身份驗證請求是否為您預定義的范圍。
盡管文檔尚不清楚,但我嘗試設置隨機字符串,但並沒有停止一切。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.