Bug 1086639 - REST Task fails with 401 when using business-central/rest endpoint
Summary: REST Task fails with 401 when using business-central/rest endpoint
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ER3
: 6.1.0
Assignee: Marco Rietveld
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-11 08:48 UTC by Anton Giertli
Modified: 2020-03-27 20:07 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-03-27 20:07:03 UTC
Type: Enhancement
Embargoed:


Attachments (Terms of Use)
bpmn process (15.32 KB, application/xml)
2014-04-11 08:48 UTC, Anton Giertli
no flags Details
401 (1.34 KB, text/plain)
2014-04-11 08:49 UTC, Anton Giertli
no flags Details
server log (32.75 KB, text/plain)
2014-12-18 15:58 UTC, Ivo Bek
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1209479 0 high CLOSED Cannot query REST interface of business central from a REST task that uses default RestWorkItemHandler 2021-02-22 00:41:40 UTC
Red Hat Knowledge Base (Solution) 793983 0 None None None Never

Internal Links: 1209479

Description Anton Giertli 2014-04-11 08:48:58 UTC
Created attachment 885299 [details]
bpmn process

Description of problem:

You can't use built-in rest task for querying *OUR* own REST API.

The likely reason for this is that our rest api does not use basic auth but some sort of mixed one so you need to set AUTH_HEADER manually.

This is apparently not possible with the current implementation of REST Task, this capability needs to be added - so use can configure it via task variable which will be handled correctly in the handler class.

Testing/using REST Task with business-central/rest URL is very often case.

Version-Release number of selected component (if applicable):

bpm 6.0.0
bpm 6.0.1
How reproducible:
always

Steps to Reproduce:
1. Configure rest task with url which points to business-central rest api
2. start the process
3. 

Actual results:

REST Task configured with url pointing to business-central/rest endpoint fails with 401

Expected results:

REST Task configured with url pointing to business-central/rest endpoint is properly executed
Additional info:


I have attached simple project which I have used for testing as well as the error I have received in the server.log - it's standard 401 displayed in JBoss.

Comment 1 Anton Giertli 2014-04-11 08:49:41 UTC
Created attachment 885300 [details]
401

Comment 3 Anton Giertli 2014-04-11 08:51:46 UTC
It would be neat if there shouldn't be any additional configuration, but handler class would recognize our own rest endpoint and executed the necessary authentication.

Comment 6 Maciej Swiderski 2014-04-11 13:09:45 UTC
there are two issues that need to be addressed:
1. we need to use preemptive authentication and this has already been fixed by https://issues.jboss.org/browse/JBPM-4298 on master
2. specify default user and password for the RestWorkItemHandler in the CustomWorkItemHandler.conf file it can be as simple as two empty string

with that REST work item handler works fine with kie-wb REST api. So it should be enough to back port the jira. As it comes for the other case we might want to first handler to change the auth type when user and password is given as parameters. As currently it is globally configured per handler instance. Votes?

Comment 7 Maciej Swiderski 2014-08-27 05:53:02 UTC
The jira mentioned in comment 6 will be included in 6.1 version so the remaining part is to configure handler to use BASIC authentication. My vote is to stick with what we have now and if needed reconfigure it using deployment descriptors per kjar/project. What do you think?

Comment 8 Maciej Swiderski 2014-11-17 12:24:14 UTC
any project can enable rest work item handler to use basic auth that allows to use business central REST api without an issue. gunner asset mgmt stuff actually uses it, see here [1] how it can be enabled in deployment descriptor and then user name and password can be given as work item parameters.

Note that you can give actual user name and password in deployment descriptor as well though it will not be encrypted in any way.

[1] https://github.com/droolsjbpm/guvnor/blob/master/guvnor-asset-mgmt/guvnor-asset-mgmt-project/src/main/resources/META-INF/kie-deployment-descriptor.xml#L29

Marking as modified as with proper configuration REST work item handler can interact with business central REST api.

Comment 9 Ivo Bek 2014-12-18 15:54:25 UTC
Failed in BPMS 6.1.0.ER3

Every REST operation requested within a process instance timeouts because it cannot commit a session. I will attach the server log.

To reproduce the same problem:
 1) Create a new project
 2) Configure Deployment Descriptor to set the username and password. For example:

   new org.jbpm.process.workitem.rest.RESTWorkItemHandler("ibek","ibek1234;")

 3) Create a BPMN process definition consisting of a REST service task starting a new process. For example:

http://localhost:8080/business-central/rest/runtime/org.jboss:integration:2.0.0-SNAPSHOT/process/org.jboss.qa.bpms.ScriptTask/start

 4) Build and deploy the project
 5) Start the process with REST service task - notice the form won't disappear and an error dialog will show up.

The important thing is, that the REST operation is executed (new process started, signal sent, ...) however the parent process will fail.

Comment 10 Ivo Bek 2014-12-18 15:58:17 UTC
Created attachment 970631 [details]
server log

Attached the server log.

Notice the line from the server log below:

16:33:28,677 INFO  [stdout] (http-localhost.localdomain/127.0.0.1:8080-1) Hello World!!!

That means, the REST start process operation was actually executed.

Comment 11 Maciej Swiderski 2014-12-18 16:08:25 UTC
Ivo, 

do you by any change use singleton session and both processes are in the same project/kjar?

Comment 12 Ivo Bek 2014-12-18 16:40:29 UTC
Verified in BPMS 6.1.0.ER3

As Maciej assumed, the problems were caused by use of singleton session. After change to per process instance session and adding Multi-Version Concurrency Control (MVCC), executions of REST operations worked fine.

Thank you, Maciej

Comment 13 Jiri Svitak 2015-04-07 13:14:27 UTC
We have discovered a limitation of the current solution, see BZ1209479.
Http authentication method of a REST task cannot be explicitly set.
It can be set only indirectly like this
new org.jbpm.process.workitem.rest.RESTWorkItemHandler("ibek","ibek1234;")
see [1]. This means a limitation, because imagine a process definition which has several REST tasks, where each one uses a different remote endpoint and a different auth method. One configuration of one RestWorkItemHandler cannot handle that.

Documentation team, can you please document this? 

[1] https://github.com/droolsjbpm/jbpm/blob/6.2.x/jbpm-workitems/src/main/java/org/jbpm/process/workitem/rest/RESTWorkItemHandler.java#L128

Comment 14 Kris Verlaenen 2015-04-07 13:55:02 UTC
Afaik this should be possible, you can use "Username" and "Password" parameters to override the defaults provided in the constructor:
https://github.com/droolsjbpm/jbpm/blob/6.2.x/jbpm-workitems/src/main/java/org/jbpm/process/workitem/rest/RESTWorkItemHandler.java#L281

Comment 15 Jiri Svitak 2015-04-07 14:39:19 UTC
Kris,
have you read the linked bugzilla description? You can set "Username" and "Password" as you say, but the problem is elsewhere. You cannot set explicitly http auth type.

Comment 16 Kris Verlaenen 2015-04-09 19:26:27 UTC
Yes, you can't use different auth type currently (you can only override username/password), I suggest you open a new BZ as feature request to tackle this part.


Note You need to log in before you can comment on or make changes to this bug.