You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gerald Kallas <ca...@mailbox.org> on 2020/02/04 23:30:52 UTC
Camel Servlet based REST API - Basic Authentication?
Dear community,
with some help from your folks here I've created a Camel Servlet based REST API (see below).
The next step will be to add HTTP Basic Authentication (filter) to protect the Servlet Endpoint (API). I did a lot of research but wasn't able to find anything that helps.
So my question, were can I find an example for adding HTTP Basic Authentication to the Servlet endpoint. I'd prefer Blueprint DSL as much as possible.
Thanks in advance
- Gerald
Here my code ..
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<reference id="httpService" interface="org.osgi.service.http.HttpService"/>
<bean id="camelHttpTransportServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/api"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="camelHttpTransportServlet"/>
<property name="servletName" value="camelHttpTransportServlet"/>
</bean>
</blueprint>
lns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext id="isp.routes.api.RST" xmlns="http://camel.apache.org/schema/blueprint" streamCache="true">
<endpoint id="isp.endpoint.api.RST" uri="rest-api:///api-doc?componentName=servlet" />
<restConfiguration
bindingMode="off"
component="servlet"
contextPath="/api"
host="DEV"
apiContextPath="/api-doc"
apiContextListing="false"
enableCORS="true">
<endpointProperty key="servletName" value="camelHttpTransportServlet" />
<dataFormatProperty key="prettyPrint" value="true"/>
<apiProperty key="schemes" value="https"/>
<apiProperty key="base.path" value="/api"/>
<apiProperty key="api.description" value="DEV - API Say"/>
</restConfiguration>
<rest path="/say">
<get uri="/hello" consumes="application/json" id="isp.routes.api.RST001">
<to uri="direct:hello"/>
</get>
</rest>
<route id="isp.routes.api.impl.RST003">
<from uri="direct:hello"/>
<setHeader name="Content-Type">
<constant>application/json</constant>
</setHeader>
<transform>
<constant>{"text": "Hello World"}</constant>
</transform>
</route>
</camelContext>
</blueprint>