- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Apache Nifi Rest Api Authorization
- Labels:
-
Apache NiFi
Created ‎02-21-2024 02:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to stop a processor on the same machine with restApi but 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 token manually again.Is there a way I can authorize automatically?
- I am using the executeScript processor when calling the API.Script engine is Groovy.
- My Nifi version 1.23.2 and Nifi is secure and not clustered.I login with ldap on UI.
This is the part where I call the API in the script:
def post = new URL(NifiBaseUrl.value + NifiComponentId.value).openConnection();
post.setSSLSocketFactory(sslContext.getSocketFactory())
post.setRequestMethod("PUT")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/json")
post.getOutputStream().write(content.getBytes("UTF-8"));
post.getResponseCode()
Error:
java.io.IOException: Server returned HTTP response code: 401 for URL
Created ‎02-26-2024 07:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@plapla
What you have encountered is not an error. 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.
You'll need to authorize client/user for "execute code" restricted components policy:
NiFi UI --> global menu --> policies --> access restricted components --> execute code
If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created ‎09-05-2024 07:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Salmidin
Please create a new community question with the details of your issue. It seem unrelated to this thread issue. 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.
NiFi needs to be configured with a production ready authorizer for the "Polices" and "Users" options to be visible in the NiFi Global menu.
Fell free to ping me @MattWho in your new community question.
Thanks,
Matt
Created ‎02-26-2024 10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I create a user with certificate DN.As you said, I gave this user "execute code" permission.This way the problem is solved.
The problem was not solved without creating a user

- « Previous
-
- 1
- 2
- Next »