0
我相信所有這些都只是使用默認值,我們使用jdbc作爲我們的令牌存儲,客戶端詳細信息是默認值。看起來我們有一個自定義userApprovalHandler。如何將<oauth:authorization-server>轉換爲Java Config?
<oauth:authorization-server
client-details-service-ref="clientDetails"
token-services-ref="tokenServices"
user-approval-handler-ref="userApprovalHandler">
<oauth:client-credentials />
<oauth:password authentication-manager-ref="authenticationManager"/>
</oauth:authorization-server>
我知道我們必須添加@EnableAuthorizationServer
,但我不知道如果我真的需要實現因爲這些AuthorizationServerConfigurer
或者都有註釋,如果春天可以計算出來(它有時)?我也不確定什麼正確的方法來設置其中的一些。例如我還沒有找到要設置client-credentials
或password
的地點。我不太確定他們是如何翻譯的。
這是我想出迄今
@Configuration
@EnableAuthorizationServer
public class OAuth2Config implements AuthorizationServerConfigurer
{
@Autowired private ClientDetailsService clientDetails;
@Autowired private AuthorizationServerTokenServices tokenServices;
@Override
public void configure(final AuthorizationServerSecurityConfigurer security) throws Exception
{
}
@Override
public void configure(final ClientDetailsServiceConfigurer clients) throws Exception
{
clients.withClientDetails(clientDetails);
}
@Override
public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception
{
endpoints.tokenServices(tokenServices);
}
}
因爲這似乎是一個小片段和Java的配置不應該更大,如果你能提供這些完整的配置類的例子選項會很棒。