我正在尝试在我们的(常规而非AKS)kubernetes群集和Azure AD之间设置SSO。由于我不知道如何将令牌转发到kube-dashboard,因此我目前正在尝试在计算机上安装kubectl二进制文件。当不涉及任何组,但是我们要按安全组过滤(AAD上的帐户是从我们的本地Active Directory同步的)时,它就可以工作,不涉及kube RBAC。
安装程序的灵感来自https://medium.com/@olemarkus/using-azure-ad-to-authenticate-to-kubernetes-eb143d3cce10和https://docs.microsoft.com/fr-fr/azure/aks/azure -ad-integration:
- --oidc-client-id=spn:abc123
- --oidc-issuer-url=https://sts.windows.net/OurAADTenantID
kubectl config set-cluster test-legacy-2 --server=https://192.168.x.y:4443 --certificate-authority=/somelocation/ca.pem
kubectl config set-credentials [email protected] --auth-provider=azure --auth-provider-arg=environment=AzurePublicCloud --auth-provider-arg=client-id=xyz456 --auth-provider-arg=tenant-id=OurAADTenantID --auth-provider-arg=apiserver-id=abc123
同样在Azure客户端应用清单中,必须指定:
"allowPublicClient":true,
"oauth2AllowIdTokenImplicitFlow":true
否则出现错误“无法获取令牌:获取新的新令牌:等待设备代码身份验证完成:autorest / adal / devicetoken:检索OAuth令牌时出错:未知错误”。在https://github.com/MicrosoftDocs/azure-docs/issues/10326上找到
当尝试过滤我根据https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens在JWT中找到的某个安全组时,问题开始
我收到了格式错误,即使JWT Azure向我发送的确包含正确格式的组(字符串的json数组)
配置:
"groupMembershipClaims": "SecurityGroup",
- --oidc-groups-claim=groups
- --oidc-required-claim=groups=bbc2eedf-79cd-4505-9fb4-39856ed3790e
此处的字符串是我的目标安全组的GUID。
我正在接收error: You must be logged in to the server (Unauthorized)
kubectl的输出,而kube api服务器日志向我提供了这一点authentication.go:62] Unable to authenticate the request due to an error: [invalid bearer token, [invalid bearer token, oidc: parse claim groups: json: cannot unmarshal array into Go value of type string]]
但是我不明白为什么当我解码我拥有的JWT时为什么不开心
"groups": [
"00530f35-0013-4237-8947-6e3f6a7895ca",
"bbc2eedf-79cd-4505-9fb4-39856ed3790e",
"17dff614-fd68-4a38-906c-69561daec8b7"
],
据我所知,这是一个格式良好的字符串json数组...
为何api服务器抱怨JWT?
但是我找到了解决方法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句