久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何自定義 Spring Boot AccessTokenProvider?

How do I customize the Spring Boot AccessTokenProvider?(如何自定義 Spring Boot AccessTokenProvider?)
本文介紹了如何自定義 Spring Boot AccessTokenProvider?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想為我的 OAuth2 提供者增強令牌請求.我需要向 POST 請求添加一個附加參數.我不明白在哪里掛鉤到 Spring Boot 框架來完成這個.

I want to enhance the token request for my OAuth2 provider. I need to add an additional parameter to the POST request. I don't understand where to hook into the Spring Boot framework to accomplish this.

Spring Boot 框架提供了一個用于自定義 OAuth2RestTemplate 的鉤子,如自定義用戶信息 RestTemplate".我已經實現了以下定制器,它被實例化并按預期調用.不幸的是,發出令牌請求時似乎沒有調用我的提供程序.

The Spring Boot framework provides a hook for customizing the OAuth2RestTemplate as described in "Customizing the User Info RestTemplate". I have implemented the following customizer, which gets instantiated and called as expected. Unfortunately, my provider does not seem to get called when the token request is made.

public class AadUserInfoRestTemplateCustomizer implements UserInfoRestTemplateCustomizer {
    @Override
    public void customize(OAuth2RestTemplate oAuth2RestTemplate) {

        oAuth2RestTemplate.setAuthenticator(new AadOauth2RequestAuthenticator());

        // Attempt 1: Use my own token provider, but it never gets called...
        oAuth2RestTemplate.setAccessTokenProvider(new AadAccessTokenProvider());

        // Even better, if only OAuth2RestTemplate provided a getter for AccessTokenProvider, I could add interceptors and or enhancers
        // Can't do this :( AuthorizationCodeAccessTokenProvider provider = oAuth2RestTemplate.getAccessTokenProvider();
    }
}

問題:

如何設置自定義 AccessTokeProvder,或者更好的是,獲取對默認值的引用并使用攔截器或增強器掛鉤到請求中?

How does set a custom AccessTokeProvder, or even better, get a reference to the default one and hook into the request with an interceptor or enhancer?

代碼示例

在下面的分叉中,請查看/simple 模塊.將您的 AAD 租戶信息添加到/simple/src/main/resources/application.yml 文件中:

In the fork below, please see the /simple module. Add your AAD tenant info into the /simple/src/main/resources/application.yml file:

https://github.com/bmillerbma/tut-spring-boot-oauth2/tree/aad

注意事項:

  • 這個提交似乎是框架使這成為可能,但是如何利用這一功能呢?

  • This commit to the framework seems to make this possible, but how does one leverage this functionality?

這個問題似乎是相關的.不知何故,這個家伙添加了一個自定義提供程序.但是在哪里?

This question seems to be related. Somehow the fella added a custom provider. But where?

推薦答案

我遇到了同樣的問題并使用了這個解決方法,但因此我堅持使用 spring boot 1.3.8

I came across with the same issue and used this workaround but because of this I stuck with spring boot 1.3.8

所以我開始深入挖掘,然后我終于找到了一個更簡單的方法.只需在 userAuthorizationUri 之后添加資源參數即可.

So I started to dig deeper and then I finally found an easier method. Just add a resource parameter after the userAuthorizationUri.

security:
  oauth2:
    client:
      ...
      userAuthorizationUri: https://login.microsoftonline.com/<<tenantId>>/oauth2/authorize?resource=https://graph.windows.net
      ...

這篇關于如何自定義 Spring Boot AccessTokenProvider?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why does the android emulator camera stop unexpectedly?(為什么android模擬器相機會意外停止?)
Android camera , onPictureTaken(byte[] imgData, Camera camera) method amp; PictureCallback never called(Android camera , onPictureTaken(byte[] imgData, Camera camera) 方法 amp;PictureCallback 從未調用過) - IT屋-程序員軟件開發技
Understanding the libGDX Projection Matrix(了解 libGDX 投影矩陣)
QR code reading with camera - Android(使用相機讀取二維碼 - Android)
IP camera with OpenCv in Java(Java中帶有OpenCv的IP攝像頭)
Android mock Camera(Android 模擬相機)
主站蜘蛛池模板: 一级片在线观看视频 | 欧美一级在线观看 | 羞羞视频在线网站观看 | 色一级 | 视频在线一区二区 | 激情欧美一区二区三区 | a毛片 | 蜜月aⅴ国产精品 | 日韩中文字幕在线观看 | avhd101在线成人播放 | 国产一级一级 | 欧美一区二区成人 | 91美女在线观看 | 欧美福利视频 | 91精品国产91久久久久久密臀 | 国产日韩欧美二区 | 亚洲精品久久区二区三区蜜桃臀 | 亚洲看片网站 | 欧美另类视频 | 亚洲视频中文字幕 | 久久精品天堂 | 国产精品视频在线观看 | 九九九国产 | 成人亚洲性情网站www在线观看 | 久久久久国产一区二区三区四区 | 91久久伊人 | 九九久久这里只有精品 | 日本精品在线一区 | 亚洲精品视频一区二区三区 | 日韩精品在线播放 | 亚洲一区二区三区在线 | 97国产超碰 | 欧美精品久久久久久久久老牛影院 | 国产精品久久久久久久久久久免费看 | 国产成人高清成人av片在线看 | 国产日批| 欧美日韩国产在线 | 在线成人www免费观看视频 | 国产精品视频网 | 五月天婷婷综合 | 国产乱码精品一区二区三区忘忧草 |