Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access NiFi using proxy user request

Tags:

c#

apache-nifi

I want to access NiFi and do some actions through external web application created in C# using proxy user request. For that,

I have created C# web application and hosted as secure connection(https).

I need to access NiFi components using its REST API service without authorization token. Added C# web application certificate into NiFi truststore and added certificate name as user (CN=machineName) in NiFi. Also, added "proxy user request" policy for the newly added user.

In C# web application, added "X-ProxiedEntitiesChain = <username>" in header while requesting NiFi API. But it returns "unknown user" error in response. Please find the sample code below,

var httpWebReq=(HttpWebRequest)WebRequest.Create("https://testhost:8080/nifi-api/access");
httpWebReq.Headers["X-ProxiedEntitiesChain"] = "<username>";
httpWebReq.Method = "GET";
var response = (HttpWebResponse)httpWebReq.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString; 
like image 579
Nijandhan Avatar asked Nov 07 '22 04:11

Nijandhan


1 Answers

Based on the available information the most likely problem is that you are not using a properly authorized user.

Check that you are using the proper username, and confirm that it is actually authorized for access.

(And of course make sure you don't just pass the string "username")

like image 183
Dennis Jaheruddin Avatar answered Nov 23 '22 23:11

Dennis Jaheruddin