天天看點

【Azure API 管理】APIM關閉開發者門戶的辦法

問題描述

APIM預設提供了開發者門戶,可以讓使用者體驗如何來調用接口。但如果不想開發這個功能的情況下,是否有辦法關閉呢?

【Azure API 管理】APIM關閉開發者門戶的辦法

問題解答

答案是:開發人員門戶是沒有辦法關閉的。但是作為另一種的代替方案,如自定義域名時,不為開發者門戶配置DNS,删除開發者門戶的登入權限(Identities)。進而實作讓使用者通路開發者門戶,但是無法登入的效果。

解決方法

第一種:對于新建立的 APIM服務,預設情況下是不會不釋出開發人員門戶的。如果不主動釋出它,則實際上等于禁用。但是,如果有意或無意,釋出了它,則沒有支援取消釋出它的方法,就可以參考下面第二種,第三種方式。

第二種:當要自定義APIM的通路域名時,不配置 APIM開發門戶的DNS 映射。雖然還是可以通過預設的域名進行通路,但是一般人很難弄清楚預設名稱和預設域名,可以實作阻止絕大多數人的通路。

第三種:可以使用以下兩個配置,使得開發門戶達到不可使用的效果:

  • 通過删除所有辨別類型來禁用注冊(這可以在 Azure 門戶中完成 - 選擇 API 管理執行個體,然後單擊"辨別"并删除每個辨別類型)。
  • 強制将匿名使用者定向到注冊頁(這是在 Azure 門戶的同一部分中完成的)。
【Azure API 管理】APIM關閉開發者門戶的辦法

方案參考

Support disabling developer portal :https://github.com/Azure/api-management-developer-portal/issues/833

Please consider adding an option to completely disable the developer portal. For example, customers who have their own custom portal will not want to have a platform-provided portal accessible.

Currently there are some workarounds (see below), but it would be even better to have the option to not have the developer portal made available by the platform.

Workarounds

  1. For new API Management instances, the developer portal is not published by default. If a customer does not publish it themselves then it is effectively disabled. However, if a customer publishes it (intentionally or accidentally) there is no supported way to unpublish it.
  2. Customers can avoid mapping a DNS name to the developer portal hostname provided by the platform. This does not prevent someone from figuring it out, but it makes it much less likely they will do so.
  3. Customers can configure the developer portal with the following two settings, which together have the effect of making the developer portal unusable:
    • Disable sign-up by removing all identity types (this can be done in the Azure portal - choose the API Management instance, then click Identities and remove each identity type).
    • Force anonymous users to be directed to the sign-up page (this is done in the same part of the Azure portal).

當在複雜的環境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 雲中,恰是如此!

繼續閱讀