如何将凭证传递给NiFi Rest API

Kum*_*mar 1 rest apache-nifi

我已经为Apache NiFi-1.1.1启用了LDAP身份验证。

使用ldap用户登录后,我可以访问NiFi Web UI。

当我尝试使用基本身份验证访问REST API时/process-groups/root,它显示

Unable to perform the desired action due to insufficient permissions. Contact the system administrator.

如何将凭证传递给NiFi REST API?如何使用令牌访问NiFi REST API?

提前致谢。

Mat*_*man 5

通过LDAP进行身份验证时,NiFi REST API将要求客户端将令牌与每个请求一起传递。要获得令牌,您需要传递凭据进行身份验证。

curl 'https://localhost:8443/nifi-api/access/token' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' --data 'username=<user>&password=<pass>' --compressed
Run Code Online (Sandbox Code Playgroud)

该请求将返回您需要在每个后续请求的标头中传递的令牌。例如:

curl 'https://localhost:8443/nifi-api/flow/current-user' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Authorization: Bearer <token>' -H 'Accept: application/json, text/javascript, */*; q=0.01' --compressed
Run Code Online (Sandbox Code Playgroud)