簡體   English   中英

wso2 api 管理器,可選認證(v1.9)

[英]wso2 api manager, optional authentication (v1.9)

我正在使用 wso2 的舊(v1.9)版本,我們試圖基本上擁有一個帶有可選身份驗證的端點。 如果資源的安全性設置為None ,如果請求帶有令牌(經過身份驗證),則不會將其發送到后端。 如果設置了授權 header,是否有某種方法可以強制 wso2 v1.9 在此類路由上進行身份驗證並將 JWT 轉發到后端?

在 API Manager v1.9 中,默認情況下它會從消息上下文中刪除 Auth header,並且不會傳遞給后端服務 [1]。

有一個名為 RemoveOAuthHeadersFromOutMessage 的屬性,您可以在其中禁用刪除此 header [2]。 但這是一個系統范圍的配置,它會影響系統中的所有 API。 如果將此值設置為 false,則對於所有 API,它不會刪除 Auth header。 在這種情況下,您可以使用全局序列或自定義序列 [3] 選擇性地刪除此身份驗證 header。

另一種解決方法:

您可以使用自定義處理程序 [4] 並在 API 安全處理程序之前應用此處理程序。 In this handler, you can copy the auth header value to a different header and then using a custom sequence you can copy the custom header value to auth header again. 在這種情況下,您不需要更改 RemoveOAuthHeadersFromOutMessage 的值。 但是在處理程序中,您必須有選擇地執行此操作。

[1] - https://github.com/wso2/carbon-apimgt/blob/1.2.5/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/ apimgt/gateway/handlers/security/oauth/OAuthAuthenticator.java#L96

[2] - https://docs.wso2.com/display/AM191/Working+with+Access+Tokens

[3] -https://docs.wso2.com/display/AM191/Adding+Mediation+Extensions

[4] - https://docs.wso2.com/display/AM191/Writing+Custom+Handlers

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM