I have the following configuration to connect to an active directory with username/password to authenticate a REST DSL service in Camel. http://localhost:3000/api/data/1234
<!-- Jetty Security handling -->
<bean id="loginService" class="org.eclipse.jetty.jaas.JAASLoginService">
<property name="name" value="nameAuth"/>
<property name="loginModuleName" value="ldap-login-module"/>
</bean>
<bean id="identityService" class="org.eclipse.jetty.security.DefaultIdentityService"/>
<bean id="constraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC"/>
<property name="roles" value="Admin" />
<property name="authenticate" value="true"/>
</bean>
<bean id="constraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="constraint"/>
<property name="pathSpec" value="/*"/>
</bean>
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="authenticator">
<bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
</property>
<property name="constraintMappings">
<list>
<ref bean="constraintMapping"/>
</list>
</property>
<property name="loginService" ref="loginService"/>
<property name="identityService" ref="identityService"/>
</bean>
When sending correct credentials it returns 403:
<body>
<h2>HTTP ERROR 403</h2>
<p>Problem accessing /api/data/1234. Reason:
<pre> Forbidden</pre>
</p>
<hr><i><small>Powered by Jetty://</small></i>
<hr />
</body>
When changing them and sending wrong credentials returns 401
<body>
<h2>HTTP ERROR 401</h2>
<p>Problem accessing /api/data/1234. Reason:
<pre> Unauthorized</pre>
</p>
<hr><i><small>Powered by Jetty://</small></i>
<hr />
</body>
Can it be caused by the role or something?
I appreciate if you know of any solution.
I resolved it using netty4 and not jetty.
https://camel.apache.org/components/2.x/netty4-http-component.html
restConfiguration()
//.component("jetty")
.component("netty4-http")
//.endpointProperty("handlers", "#securityHandler")
.endpointProperty("securityConfiguration.realm", "ldap-login-module")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.