<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Apache Nifi Rest Api Authorization in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383749#M245043</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Is &lt;SPAN&gt;SSL Context Service&lt;/SPAN&gt; alone sufficient or is it necessary to purchase tokens via invokeHttp first?&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2024 09:34:49 GMT</pubDate>
    <dc:creator>plapla</dc:creator>
    <dc:date>2024-02-22T09:34:49Z</dc:date>
    <item>
      <title>Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383694#M245016</link>
      <description>&lt;P&gt;I want to stop a processor on the same machine&amp;nbsp; with restApi but&amp;nbsp;I get an authorization error when I call the rest api.I can solve this problem with bearer token, but since the token has expired, I need to change the bearer&amp;nbsp; token manually again.Is there a way I can authorize automatically?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I am using the executeScript processor when calling the API.Script engine is Groovy.&lt;/LI&gt;&lt;LI&gt;My Nifi version&amp;nbsp;1.23.2 and Nifi is secure&amp;nbsp; and not clustered.I login with ldap on UI.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plapla_0-1708509284146.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39755iCD3DAE6B57F87061/image-size/medium?v=v2&amp;amp;px=400" role="button" title="plapla_0-1708509284146.png" alt="plapla_0-1708509284146.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is the part where I call the API in the script:&lt;/P&gt;&lt;P&gt;def post = new URL(NifiBaseUrl.value + NifiComponentId.value).openConnection();&lt;BR /&gt;post.setSSLSocketFactory(sslContext.getSocketFactory())&lt;BR /&gt;post.setRequestMethod("PUT")&lt;BR /&gt;post.setDoOutput(true)&lt;BR /&gt;post.setRequestProperty("Content-Type", "application/json")&lt;BR /&gt;post.getOutputStream().write(content.getBytes("UTF-8"));&lt;BR /&gt;post.getResponseCode()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;java.io.IOException: Server returned HTTP response code: 401 for URL&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 10:00:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383694#M245016</guid>
      <dc:creator>plapla</dc:creator>
      <dc:date>2024-02-21T10:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383711#M245028</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Have you tried using the InvokeHttp processor for this instead of writing a script ? The thing is if you have nifi secured you have to pass the SSL Context to make an authorized call . I know when I try to call the nifi api to start\stop a processor using the invokehttp I have to pass the SSL Context Service, otherwise I will get the 401 error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you find this is helpful please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 15:09:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383711#M245028</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-02-21T15:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383749#M245043</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Is &lt;SPAN&gt;SSL Context Service&lt;/SPAN&gt; alone sufficient or is it necessary to purchase tokens via invokeHttp first?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 09:34:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383749#M245043</guid>
      <dc:creator>plapla</dc:creator>
      <dc:date>2024-02-22T09:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383759#M245049</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/107497"&gt;@plapla&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;A secured NiFi is secured over HTTPS which means a TLS exchange happens to secure the connection with NiFi.&amp;nbsp; A secured NiFi will always support a mutual TLS exchange.&lt;BR /&gt;&lt;BR /&gt;If no other methods of user authentication are configured, NiFI will "REQUIRE" a clientAuth certificate be presented in the TLS exchange with NiFi.&lt;BR /&gt;&lt;BR /&gt;When NiFi is configured with an additional user authentication method (for example, you have enabled the ldap-provider for user authentication), NiFi will "WANT" a clientAuth certificate in the TLS exchange.&amp;nbsp; If a clientAuth certificate is not provided in the TLS exchange/handshake, NiFi moves on to the next authentication method configured.&lt;BR /&gt;&lt;BR /&gt;The ldap-provider will require obtaining a user token as you saw that then needs to be included with all subsequent rest-api calls.&amp;nbsp; And you are correct that the token does expire.&amp;nbsp; That is why it is easier and a better option to use mutual TLS based authentication when doing automation like this.&amp;nbsp; The clientAuth certificate is simply included in every rest-api request and there is no token involved.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;About the ClientAuth certificate...&amp;nbsp; The full DN from the certificate is what is used to identify the user.&amp;nbsp; The full DN is evaluated against any identity.mapping.pattern.xxx properties configured in the nifi.properties file.&amp;nbsp; If a configured pattern (java regex) matches against the DN, the identity.mapping.value.xxx and identity.mapping.transform.xxx is applied.&amp;nbsp; These identity mappings are often used to trim the CN value from the complete DN.&amp;nbsp; The resulting string after any mappings are applied is what is then used to look up authorizations for that client/user.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 14:13:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383759#M245049</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2024-02-22T14:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383760#M245050</link>
      <description>&lt;P&gt;If you have your nifi instance secure with truststore &amp;amp; keystore , you can use the same for creating SSL Context Service using StandardSSLContextService or StandardRestrictedSSLContextService . Either services you need to populate the truststore &amp;amp; keystore information that you used to secure nifi, but you have to pass SSL information to the code in your executescript processor. There is a way to access controller services from ExecuteScript, refere to part3 of : &lt;A href="https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018" target="_blank"&gt;https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But then again why not use the out of the box InvokeHttp processor , and pass the created service to the SSL Context Service property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 14:18:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383760#M245050</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-02-22T14:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383761#M245051</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/107497"&gt;@plapla&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;TLS based user/client authentication does not use tokens. You just need to make sure the clientAuth PrivateKey certificate in the keystore used is both trusted by the Nifi's configured truststore in the nifi.properties file and authorized against the NiFi policy(s) required to access the specific rest-api endpoint requested.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 14:18:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383761#M245051</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2024-02-22T14:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383865#M245112</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;As I said, nifi is secure and authenticates via ldap when logging into the frontend.&lt;/P&gt;&lt;P&gt;I defined StandartRestrictedSslContextService on controller services.StandardRestrictedSslContextService uses the trustStore and keyStore files I created before. The same files are defined in nifi.properties.&lt;/P&gt;&lt;P&gt;When I call the API with invokeHttp using this service, I get the following error:&lt;STRONG&gt;Unable to modify Components requiring additional permission: execute code. Contact the system administrator.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If I send a userToken with the authorization parameter to the invokeHttp processor, I get a successful response.&lt;/P&gt;&lt;P&gt;Since using userToken complicates the flow, it would be better to use SSL service.But I have no idea how to overcome the error I shared above.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plapla_0-1708936559100.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39779i413596A1C21D1C1E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="plapla_0-1708936559100.png" alt="plapla_0-1708936559100.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plapla_1-1708936612014.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39780i0E9FF39DB610DB29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="plapla_1-1708936612014.png" alt="plapla_1-1708936612014.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 08:41:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383865#M245112</guid>
      <dc:creator>plapla</dc:creator>
      <dc:date>2024-02-26T08:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383894#M245118</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/107497"&gt;@plapla&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What you have encountered is not an error.&amp;nbsp; NiFi is telling you that the client/user Identity derived from the clientAuth certificate in your keystore is not authorized for them mentioned NiFi authorization policy that is needed for the specific rest call being made.&lt;BR /&gt;&lt;BR /&gt;You'll need to authorize client/user for "&lt;STRONG&gt;execute code&lt;/STRONG&gt;" restricted components policy:&lt;BR /&gt;NiFi UI --&amp;gt; global menu --&amp;gt; policies --&amp;gt; access restricted components --&amp;gt; execute code&lt;/P&gt;&lt;P&gt;If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on one or more of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 15:32:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383894#M245118</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2024-02-26T15:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383918#M245131</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create a user with certificate DN.As you said, I gave this user "execute code" permission.This way the problem is solved.&lt;/P&gt;&lt;P&gt;The problem was not solved without creating a user&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 06:29:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/383918#M245131</guid>
      <dc:creator>plapla</dc:creator>
      <dc:date>2024-02-27T06:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/388111#M246529</link>
      <description>&lt;P&gt;Do not need to SSL Context (in my case Secure Nifi 1.14.0) , i tried it, just put certificate files, where it supposed to stay. U can get Token first within InvokeHttpRequest and set it new Attribute (named accessToken)&amp;nbsp; on Update Attribute process, then add new attribute to second InvokeHttpRequest (named Authorization --&amp;gt; Bearer ${accessToken}). thats it.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 11:41:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/388111#M246529</guid>
      <dc:creator>alik_2024</dc:creator>
      <dc:date>2024-05-20T11:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/392611#M248188</link>
      <description>&lt;P&gt;this policy menu itself is not there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 14:35:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/392611#M248188</guid>
      <dc:creator>Salmidin</dc:creator>
      <dc:date>2024-08-27T14:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi Rest Api Authorization</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/393106#M248341</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/112189"&gt;@Salmidin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please create a new community question with the details of your issue. It seem unrelated to this thread issue.&amp;nbsp; The "Policies" missing from the global menu indicates your NiFi is either using Single User Authorizer (default out of box) or is not setup to be secure.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1725548057809.png" style="width: 378px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/41665i311F49D079F4CEC9/image-dimensions/378x804?v=v2" width="378" height="804" role="button" title="MattWho_0-1725548057809.png" alt="MattWho_0-1725548057809.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;NiFi needs to be configured with a production ready authorizer for the "Polices" and "Users" options to be visible in the NiFi Global menu.&lt;BR /&gt;&lt;BR /&gt;Fell free to ping me&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;in your new community question.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Matt&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 14:55:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Rest-Api-Authorization/m-p/393106#M248341</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2024-09-05T14:55:51Z</dc:date>
    </item>
  </channel>
</rss>

