【发布时间】:2015-10-07 13:02:51
【问题描述】:
我已经使用 Mule 密码授权类型流程实现了 OAuth2 提供程序,如 https://developer.mulesoft.com/docs/display/current/Creating+an+OAuth+2.0a+Web+Service+Provider 所示。但它以 JSON 格式返回令牌响应;我想要 XML 格式的,我该怎么做?
<spring:beans>
<ss:authentication-manager id="resourceOwnerAuthenticationManager">
<ss:authentication-provider>
<ss:user-service id="resourceOwnerUserService">
<ss:user name="user" password="password" authorities="RESOURCE_OWNER" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider
name="resourceOwnerSecurityProvider"
delegate-ref="resourceOwnerAuthenticationManager" />
</mule-ss:security-manager>
<oauth2-provider:config
name="oauth2Provider"
providerName="SampleAPI"
supportedGrantTypes="RESOURCE_OWNER_PASSWORD_CREDENTIALS"
port="8083"
authorizationEndpointPath="sampleapi/api/authorize"
accessTokenEndpointPath="sampleapi/api/token"
resourceOwnerSecurityProvider-ref="resourceOwnerSecurityProvider"
scopes="READ_RESOURCE POST_RESOURCE" doc:name="OAuth provider module">
<oauth2-provider:clients>
<oauth2-provider:client clientId="myclientid3" secret="myclientsecret"
type="CONFIDENTIAL" clientName="Mule Bookstore" description="Mule-powered On-line Bookstore">
<oauth2-provider:redirect-uris>
<oauth2-provider:redirect-uri>http://localhost*</oauth2-provider:redirect-uri>
</oauth2-provider:redirect-uris>
<oauth2-provider:authorized-grant-types>
<oauth2-provider:authorized-grant-type>PASSWORD</oauth2-provider:authorized-grant-type>
</oauth2-provider:authorized-grant-types>
<oauth2-provider:scopes>
<oauth2-provider:scope>READ_RESOURCE</oauth2-provider:scope>
<oauth2-provider:scope>POST_RESOURCE</oauth2-provider:scope>
</oauth2-provider:scopes>
</oauth2-provider:client>
</oauth2-provider:clients>
</oauth2-provider:config>
【问题讨论】:
-
为什么需要 in 和 xml 格式。 ?
-
因为我的 RAML 服务采用 XML 格式,并且我希望令牌采用这种格式,因此我不需要 OAuth2 令牌的一种格式和 REST 服务的另一种格式。可以吗。带有 SPring Security 的 OAuth2 Provider 具有该功能。可以在 Mule OAuth2 实现中实现吗?
-
我希望您只需要 OAuth 令牌。在这种情况下,您可以封装调用检索 Token i 消息丰富器的组件,然后仅将令牌设置为 FlowVariables 并在您需要时在流中使用它们。这对您的用例有用吗?
-
谢谢 Neeraj。实际上,在我的要求中,只有 OAuth2 和 REST 服务托管在 Mule ESB 上。 REST 消费者是基于 Java 和基于 Microsoft SSIS 的多个;我也需要 XML 格式的令牌。
-
你好 Naveen,这不可能吗?由于我的服务使用 XML 进行通信,因此我也希望有 XML 格式的 TOKEN 响应。
标签: spring-security oauth-2.0 mule mule-studio