HTTP 403禁止-Auth JASS Spring Camel

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTTP 403禁止-Auth JASS Spring Camel相关的知识,希望对你有一定的参考价值。

我具有以下配置,可以使用用户名/密码连接到活动目录,以对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>

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

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

答案

我使用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")

以上是关于HTTP 403禁止-Auth JASS Spring Camel的主要内容,如果未能解决你的问题,请参考以下文章

KeyCloak用户rest api返回403禁止,为啥?

如何解决安装IIS时出现HTTP错误403禁止访问?

启用 API 身份验证时,Apache 气流 REST API 调用失败并出现 403 禁止

HTTP 错误 403.9 - 禁止访问:连接的用户过多

windows server 2003 iis配置 出现 http 403 禁止访问,怎么办,网页内显示“你无权查看该网页”

HTTP 403 禁止