久久久久久久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 模擬相機)
主站蜘蛛池模板: 自拍偷拍亚洲视频 | 精国产品一区二区三区四季综 | www精品美女久久久tv | 一级黄色录像片子 | 亚洲性视频网站 | 亚洲免费人成在线视频观看 | 91久久精品国产91久久性色tv | 日本成人中文字幕在线观看 | 国产精品一区二区不卡 | 亚洲高清av在线 | 亚洲精品乱码久久久久久按摩观 | 亚洲激情视频在线 | 欧美成人精品激情在线观看 | 99成人免费视频 | 日本高清视频在线播放 | 青青草一区二区 | 国产精品日本一区二区在线播放 | 亚洲免费网站 | 一区二区中文 | 亚洲天堂av在线 | 男女免费在线观看视频 | 国产精品久久久久一区二区 | 亚洲va欧美va人人爽午夜 | 亚洲 91| 亚洲毛片在线 | 久久夜色精品国产 | 欧美一区中文字幕 | 国产精品中文字幕在线观看 | 国产线视频精品免费观看视频 | 亚洲精品国产综合区久久久久久久 | 激情一区二区三区 | 欧美亚洲激情 | 日韩网站在线观看 | 国产午夜精品一区二区三区在线观看 | 色婷婷国产精品 | 五月天婷婷激情 | www.日韩欧美| 日本激情视频在线播放 | 天堂av中文在线 | 日韩资源 | h在线免费观看 |