在我将 ElasticCloud 与 Azure AD 集成以进行单点登录后,我无法将 Curl 命令与 AD 身份验证一起使用,这是我正在尝试的:
curl -X PUT -u myuser:mypassword "elasticcloudhost:port/myindex" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '{"settings" : {"number_of_shards" : 1,"number_of_replicas" : 1}}'
错误信息是:
{"statusCode":404,"error":"Not Found","message":"Not Found"}
我可以使用浏览器将我的 Azure 用户和密码连接到 kibana,它首先会被重定向到 microsoft-login 页面,然后转到 Kibana 页面,但是它不适用于 Curl 命令。
这是我用于集成的方法:
https://www.elastic.co/blog/saml-based-single-sign-on-with-elasticsearch-and-azure-active-directory
有谁知道如何使它工作?任何帮助,将不胜感激。
更新:
在这里,我尝试从 Azure AD 应用程序获取访问令牌,然后在 Curl 命令中使用它来获取索引:
#!/bin/bash
host="myApplicationIDURI"
project="test"
token=$(curl -X POST -d "grant_type=client_credentials&client_id=myclientID&client_secret=myclientsecret&resource=myApplicationIDURI" https://login.microsoftonline.com/mytenantID/oauth2/token | awk -F',' '/access_token/ {print $7}' | cut -d ":" -f2 | cut -d'"' -f 2)
echo $token
curl -X GET "$myApplicationIDURI/$project" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -H "Authorization: Bearer $token"
结果:
{
"statusCode": 401,
"error": "Unauthorized",
"message": "[security_exception] missing authentication credentials for REST request [/_security/_authenticate], with { header={ WWW-Authenticate={ 0=\"Bearer realm=\\\"security\\\"\" & 1=\"ApiKey\" & 2=\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\" } } }"
}
我在我的应用程序清单下添加了这个应用程序:
{
"allowedMemberTypes": [
"Application"
],
"description": "Access webapp as an application.",
"displayName": "access_as_application",
"id": "b963********",
"isEnabled": true,
"lang": null,
"origin": "Application",
"value": "access_as_application"
},
还有 API 权限:
这是我的 kibana.yml
xpack.security.authc.providers: ["saml", "basic"]
server.xsrf.whitelist: ["/api/security/v1/saml"]
xpack.security.authc.saml.realm: azuread-saml
和弹性搜索.yml:
xpack:
security:
authc:
realms:
saml:
azuread-saml:
order: 2
attributes.principal: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"
attributes.groups: "http://schemas.microsoft.com/ws/2008/06/identity/claims/rolename"
idp.metadata.path: "https://login.microsoftonline.com/mytenantID/federationmetadata/2007-06/federationmetadata.xml?appid=myapiID"
idp.entity_id: "https://sts.windows.net/mytenantID/"
sp.entity_id: "myAppURI"
sp.acs: "myappURI/api/security/v1/saml"
sp.logout: "myAppURI/logout"
我在日志中看到的错误是:“内置令牌服务无法解码令牌”