久久久久久久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 模擬相機)
主站蜘蛛池模板: 精品视频一区二区三区在线观看 | 一区二区国产精品 | 国产欧美一区二区三区另类精品 | 精品国产免费一区二区三区演员表 | 在线看免费 | 色欧美综合| 久久999 | 国产99久久久国产精品下药 | 中文字幕一二三区 | 午夜丁香视频在线观看 | 成人夜晚看av | 成人精品在线观看 | 91欧美精品成人综合在线观看 | 亚洲九九 | 日韩精品av一区二区三区 | 成人在线精品视频 | 精品国产乱码久久久 | 天堂免费 | 亚洲欧美在线一区 | 北条麻妃99精品青青久久 | 免费黄网站在线观看 | 亚洲精品久久久9婷婷中文字幕 | 成人区一区二区三区 | 久久亚洲一区二区 | www.日韩系列 | 国产精品久久久久久久午夜片 | 国产精品久久在线 | 亚洲一区中文字幕 | 在线伊人网 | 国产精品成人一区二区 | 久久久精品一区 | 国产精品一区一区三区 | 亚洲电影免费 | 久草网址 | 超碰在线97国产 | 伊人伊人网 | 亚洲国产成人精品久久 | 91精品国产一区二区三区 | 91精品国产日韩91久久久久久 | 久久狠狠 | 成人欧美一区二区 |