0

私は Mule CE に取り組んでおり、Oauth2 を使用して (できれば) トークン ベースのセキュリティを実装する必要があります。認証サーバーを構成し、ログ ファイルにデフォルトのマッピングが表示されますが、"/oauth/token" でメッセージを送信しても何も起こりません。

OAuth2 の同様の構成は、Tomcat でスタンドアロンの Spring Web サービス アプリケーションとしてデプロイされた場合、Spring/Tomcat で正常に機能します。

ここに私のミュールの設定があります:

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
    xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.0"
    xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.1"
    xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:ss="http://www.springframework.org/schema/security"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
    xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd 
http://www.mulesoft.org/schema/mule/xml 
http://www.mulesoft.org/schema/mule/xml/3.3/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http 
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core 
http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/https 
http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.mulesoft.org/schema/mule/jersey 
http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd 
http://www.mulesoft.org/schema/mule/spring-security 
http://www.mulesoft.org/schema/mule/spring-security/3.3/mule-spring-security.xsd
http://www.springframework.org/schema/security/oauth2 
http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.mulesoft.org/schema/mule/pattern 
http://www.mulesoft.org/schema/mule/pattern/3.3/mule-pattern.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd ">




    <mule-ss:security-manager>
        <mule-ss:delegate-security-provider
            name="memory-provider" delegate-ref="authenticationManager" />
    </mule-ss:security-manager>
    <spring:beans>
        <ss:authentication-manager alias="authenticationManager">
            <ss:authentication-provider ref="myAuthenticationProvider" />
        </ss:authentication-manager>
        <oauth:client-details-service id="clientDetailsService">
            <oauth:client client-id="admin"
                authorized-grant-types="password,authorization_code,refresh_token,implicit,client_credentials"
                authorities="ROLE_USER, ROLE_TRUSTED_CLIENT" scope="read,write,trust"
                access-token-validity="60" />
        </oauth:client-details-service>
        <oauth:authorization-server
            client-details-service-ref="clientDetailsService" token-services-ref="tokenServices">
            <oauth:authorization-code />
            <oauth:implicit />
            <oauth:refresh-token />
            <oauth:client-credentials />
            <oauth:password />
        </oauth:authorization-server>
    </spring:beans>

    <spring:beans>

        <mvc:annotation-driven />
        <spring:bean id="myAuthenticationProvider"
            class="com.sachin.tech.security.MyUserAuthenticationProvider" />

        <spring:bean id="oauthAuthenticationEntryPoint"
            class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
            <spring:property name="realmName" value="myCustomerAppRealm" />
        </spring:bean>

        <spring:bean id="oauth2AccessDeniedHandler"
            class="org.springframework.security.web.access.AccessDeniedHandlerImpl" />

        <spring:bean id="clientCredentialsTokenEndpointFilter"
            class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
            <spring:property name="authenticationManager" ref="authenticationManager" />
        </spring:bean>

        <spring:bean id="tokenStore"
            class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore" />

        <spring:bean id="tokenServices"
            class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
            <spring:property name="tokenStore" ref="tokenStore" />
            <spring:property name="supportRefreshToken" value="true" />
            <spring:property name="accessTokenValiditySeconds"
                value="60" />
        </spring:bean>

    </spring:beans>

    <flow name="wsauthentication_2" doc:name="wsauthentication_2">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8098" doc:name="MyHTTPInbound2_2"
            doc:description="wsauthentication_2 Desc">
        </http:inbound-endpoint>
        <echo-component doc:name="Echo" />
    </flow>

</mule>

マッピングはログで問題ないようです:

13:48:01,789 DEBUG FrameworkEndpointHandlerMapping:125 - Looking for request mappings in application context: org.mule.config.spring.MuleApplicationContext@7fe3a7ec: startup date [Tue Apr 23 13:47:56 IST 2013]; root of context hierarchy
13:48:01,836  INFO FrameworkEndpointHandlerMapping:197 - Mapped "{[/oauth/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.WhitelabelApprovalEndpoint.handleError(javax.servlet.http.HttpServletRequest)
13:48:01,836  INFO FrameworkEndpointHandlerMapping:197 - Mapped "{[/oauth/confirm_access],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.WhitelabelApprovalEndpoint.getAccessConfirmation(java.util.Map<java.lang.String, java.lang.Object>) throws java.lang.Exception
13:48:01,851  INFO FrameworkEndpointHandlerMapping:197 - Mapped "{[/oauth/authorize],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.authorize(java.util.Map<java.lang.String, java.lang.Object>,java.lang.String,java.util.Map<java.lang.String, java.lang.String>,org.springframework.web.bind.support.SessionStatus,java.security.Principal)
13:48:01,851  INFO FrameworkEndpointHandlerMapping:197 - Mapped "{[/oauth/authorize],methods=[POST],params=[user_oauth_approval],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.View org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.approveOrDeny(java.util.Map<java.lang.String, java.lang.String>,java.util.Map<java.lang.String, ?>,org.springframework.web.bind.support.SessionStatus,java.security.Principal)
13:48:01,851  INFO FrameworkEndpointHandlerMapping:197 - Mapped "{[/oauth/token],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.getAccessToken(java.security.Principal,java.lang.String,java.util.Map<java.lang.String, java.lang.String>)

助けてください。

4

1 に答える 1

0

Sprint OAuth が実際にJava Web コンテナーので機能するとは思えません。

Mule EE の場合、Enterprise Security パッケージの OAuth2 プロバイダを使用できます。

Mule CE の場合、組み込みの Jetty コンテナを実行して、その背後にある Mule のサーブレット エンドポイントを使用することができます。これにより、Spring OAuth が機能する環境が提供されるはずです。インスピレーションについては、Mule ディストリビューションで提供されている Bookstore の例を参照してください。

于 2013-04-24T16:30:43.253 に答える