我在 Kubernetes 集群上运行了 oauth2-proxy,我通过 ArtifactHUB > Helm > OAuth2 Proxy 图表使用 Helm 部署了该集群。我刚刚将 oauth2-proxy 从带有图表
v7.1.3
的 4.2.2
升级到带有图表 v7.4.0
的 6.16.1
,并开始看到以下错误:
[main.go:60] ERROR: Failed to initialise OAuth2 Proxy: error intiailising provider: could not create provider data: error building OIDC ProviderVerifier: invalid provider verifier options: missing required setting: issuer-url
这是什么问题。怎么解决?
我参考了文档中的 OAuth2 Proxy > Docs > Azure Auth Provider,通过在默认值文件的配置文件中添加
azure_tenant
和 oidc_issuer_url
来使其工作,如下所示:
之前:
# Oauth client configuration specifics
config:
configFile: |-
email_domains = [ "*" ]
upstreams = [ "file:///dev/null" ]
http_address = "0.0.0.0:4180"
provider = "azure"
之后:
# Oauth client configuration specifics
config:
configFile: |-
email_domains = [ "*" ]
upstreams = [ "file:///dev/null" ]
http_address = "0.0.0.0:4180"
provider = "azure"
azure_tenant = "${azure_tenant_id}"
oidc_issuer_url = "https://sts.windows.net/${azure_tenant_id}/"
如果此更改后失败并出现以下错误:
Error redeeming code during OAuth2 callback: unable to get email and/or groups claims from token: unable to get claims from token: could not initialise claim extractor: failed to parse ID Token: oidc: malformed jwt, expected 3 parts got 1
然后将配置中的
oidc_issuer_url
设置为 "https://login.microsoftonline.com/${azure_tenant_id}/v2.0"
,而不是 V2 Azure Auth 端点。
注意:
${azure_tenant_id}
将替换为实际的 Azure 应用程序租户 ID,您可以在此处找到该 ID:Azure Active Directory (AD) > 应用程序注册 > 所有应用程序 > [APP NAME]
> 概述 > Essentials > Directory (tenant) ID
其中 [APP NAME]
是 oauth2-proxy 注册应用程序的名称。