<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>身份驗證 on 又LAG隨性筆記</title><link>https://www.lagagain.com/tags/%E8%BA%AB%E4%BB%BD%E9%A9%97%E8%AD%89/</link><description>Recent content in 身份驗證 on 又LAG隨性筆記</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><lastBuildDate>Wed, 02 Dec 2026 06:30:00 +0800</lastBuildDate><atom:link href="https://www.lagagain.com/tags/%E8%BA%AB%E4%BB%BD%E9%A9%97%E8%AD%89/index.xml" rel="self" type="application/rss+xml"/><item><title>Ch16 - 身份驗證守門人，APISIX保護上游的兩種基本方式：Key-Auth和Basic-Auth</title><link>https://www.lagagain.com/post/2025-it%E9%90%B5%E4%BA%BA%E8%B3%BD-apisix%E4%BD%BF%E7%94%A8%E7%B6%93%E9%A9%97%E5%88%86%E4%BA%AB23/</link><pubDate>Wed, 02 Dec 2026 06:30:00 +0800</pubDate><guid>https://www.lagagain.com/post/2025-it%E9%90%B5%E4%BA%BA%E8%B3%BD-apisix%E4%BD%BF%E7%94%A8%E7%B6%93%E9%A9%97%E5%88%86%E4%BA%AB23/</guid><description>&lt;blockquote>
&lt;p>本系列文章於2025年，已在&lt;a href="https://ithelp.ithome.com.tw/users/20112470/ironman/8791">iT邦幫忙：【與雲原生精靈共舞：APISIX使用者的兩年旅程】&lt;/a>發布過。&lt;/p>
&lt;/blockquote>
&lt;blockquote>
&lt;p>您可以將 APISIX 網關作為所有業務的流量入口，它提供了 &lt;strong>動態路由、動態上游、動態憑證、A/B 測試、灰度發布（金絲雀發布）、藍綠部署、限速、防攻擊、收集指標、監控警報、可觀測性、服務治理&lt;/strong> 等功能。
&amp;ndash;〈APISIX文件-入門指南〉&lt;/p>
&lt;/blockquote>
&lt;p>「斷路器/限流」一章中，示範了以限流/限速和斷路器的插件保護上游的方式。在之後還會透過流量分割的插件，實現A/B測試、金絲雀部署、部分管理者不限流的例子。此外，APISIX還可以與身份驗證服務配合，透過身份驗證的插件，保護上游的存取，包含&lt;code>key-auth&lt;/code>、&lt;code>basic-auth&lt;/code>、&lt;code>ldap-auth&lt;/code>、&lt;code>jwt-auth&lt;/code>、&lt;code>openid-connect&lt;/code>、&lt;code>authz-keycloak&lt;/code>、&lt;code>opa&lt;/code>、&lt;code>forward-auth&lt;/code>、&lt;code>multi-auth&lt;/code>插件等。&lt;/p>
&lt;h1 id="key-auth">Key-Auth&lt;/h1>
&lt;p>&lt;code>key-auth&lt;/code>效果其實就像是[Admin API]使用&lt;code>X-API-KEY&lt;/code>作為驗證一樣。類似的，可以將「新竹百貨公司」只提供給VIP進入。為了使用插件，需要在&lt;code>apisix_config/config.yaml&lt;/code>的&lt;code>plugins&lt;/code>啓用該插件(預設是啓用的):&lt;/p>
&lt;div class="highlight">&lt;pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4">&lt;code class="language-yaml" data-lang="yaml">plugins:
- key-auth &lt;span style="color:#75715e"># priority: 2500&lt;/span>
- openid-connect &lt;span style="color:#75715e"># priority: 2599&lt;/span>
- cas-auth &lt;span style="color:#75715e"># priority: 2597&lt;/span>
- authz-casbin &lt;span style="color:#75715e"># priority: 2560&lt;/span>
- authz-casdoor &lt;span style="color:#75715e"># priority: 2559&lt;/span>
- wolf-rbac &lt;span style="color:#75715e"># priority: 2555&lt;/span>
- ldap-auth &lt;span style="color:#75715e"># priority: 2540&lt;/span>
- hmac-auth &lt;span style="color:#75715e"># priority: 2530&lt;/span>
- basic-auth &lt;span style="color:#75715e"># priority: 2520&lt;/span>
- jwt-auth &lt;span style="color:#75715e"># priority: 2510&lt;/span>
- consumer-restriction &lt;span style="color:#75715e"># priority: 2400&lt;/span>
- forward-auth &lt;span style="color:#75715e"># priority: 2002&lt;/span>
- opa &lt;span style="color:#75715e"># priority: 2001&lt;/span>
- authz-keycloak &lt;span style="color:#75715e"># priority: 2000&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>同樣可以在&lt;code>apisix_dashboard_config/config.yaml&lt;/code>啓用該插件，好讓在Dashboard Web UI同樣可以進行設定調整。&lt;/p>
&lt;p>然後針對「新竹百貨公司」的路由添加&lt;code>key-auth&lt;/code>插件：&lt;/p></description></item></channel></rss>