One Star

Rest Basic Authentication in a route

Hi all,
I would like to know if it is possible to enforce a simple HTTP Basic Authentication while exposing a REST service within a mediation route.
The REST WS is intended to be the entry point of the route and every request received has to be authenticated in order to consume the service.
The route will be deployed on the Talend ESB Container.
I have seen that this is possible while producing a SOAP WS (cCXF - Use Authentication) and with the tRestRequest component choosing an Integration approach (Use HTTP Basic Auth ticked - Credentials evaluated against the user.properties file); unfortunately I cannot follow these paths due to a series of requirements.
Is it possible to achieve this in an elegant way (without having to write custom interceptors or without producing too many lines of custom code)?
Thanks for your time, every kind of help is greatly appreciated.
Ole
3 REPLIES
Employee

Re: Rest Basic Authentication in a route

CXFRS component will be supported shortly - you'd be able to register an existing interceptor such as CXF JAASLoginInterecptor enforcing the authentication. Perhaps you can use this interceptor right now ?
For example, have a look at this demo resource:
https://github.com/Talend/tesb-rt-se/blob/master/examples/camel/spring-security/server/src/main/reso...
CXFRS is not used directly but the jaxrs:server is used instead; but with the either approach you can register this interceptor, see more about it here:
https://cxf.apache.org/docs/security.html#Security-JAASLoginInterceptor
Other HTTP-centric Camel components may offer something else...
HTH, Sergey
One Star

Re: Rest Basic Authentication in a route

Thanks a lot Sergey, I'll give it a shot and I'll let you know.
One Star

Re: Rest Basic Authentication in a route

Hi,
is there an example on how integrating a cxfrs messagingEndpoint in a route?
I saw the documentation for the URI format: https://help.talend.com/search/all?query=URI+format&content-lang=en
Moreover there is a guide for service development https://help.talend.com/search/all?query=JAX-RS+Development&content-lang=en and the advanced code sample https://github.com/Talend/tesb-rt-se/tree/master/examples/cxf/jaxrs-advanced.
How can I reference the bean in the cxfrs URI? Do I really need to create a seperate bundle for it or can I just create a bean within the mediation perspective? The REST example in the ESB Demo uses jetty. I'm interested in a similar simple example using cxfrs.
Cheers
Dennis