2016-12-08 8 views
0

こんにちは私は春のセキュリティに関するヘルプを探しています。IOSとAndroidのスタックにサービスするSpring REST APIがありますアプリケーションにログインするために使用されるoauth/tokenエンドポイントを持っています。そのバウンスセキュリティクラスorg.springframework.security.oauth2.provider.endpointをそのまま使用します。私は、ログイン時にモバイルデバイスからのAPIコールを統合するために、ユーザーに関連するAPIから追加情報を応答に送信しようとしています。私はこれをどうやって行うのか、最善のアプローチは何か...私は新しいTokenEndpointクラスを作るべきでしょうか?これは私が春のセキュリティのために設定されたXMLのいくつかを持っている方法です。"oauth/token"を変更するSpring REST API org.springframework.security.oauth2.provider.endpoint追加情報を返すTokenEndpoint

<!-- OAUTH CONFIGS --> 
<bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"> 
    <property name="realmName" value="hcnavigator" /> 
</bean> 

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

<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"> 
    <constructor-arg> 
     <list> 
      <bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" /> 
      <bean class="org.springframework.security.access.vote.RoleVoter" /> 
      <bean class="org.springframework.security.access.vote.AuthenticatedVoter" /> 
     </list> 
    </constructor-arg> 
</bean> 

答えて

0

TokenEnhancer(http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/token/TokenEnhancer.html)は何が必要です。あなたはあなたのトークンサービス(http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/token/DefaultTokenServices.html)にそれを注入することができます。 TokenEnhancerはトークンが生成された後に呼び出され、enhance(...)メソッドの中でトークン応答に追加情報を追加できます。

+0

これは完璧に機能しました! –

+0

それを聞いて幸せ:) –

関連する問題