HTTP 403禁止-Auth JASS Spring Camel

问题描述 投票:0回答:1

我具有以下配置,可以使用用户名/密码连接到活动目录,以对Camel中的REST DSL服务进行身份验证。 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>

[发送正确的凭据时返回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>

[更改它们并发送错误的凭据时返回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>

可能是由于角色或其他原因引起的?

如果您知道任何解决方案,我将不胜感激。

java spring ldap jetty jaas
1个回答
0
投票

我使用netty4而不是码头来解决。

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")
© www.soinside.com 2019 - 2024. All rights reserved.