2017-07-12 67 views
1

有誰知道如何使用DynamoDB提供彈簧安全驗證?換句話說,您將如何使用DynamoDB轉換/代表以下configAuthentication方法?使用DynamoDB的Spring安全驗證

@Autowired 
public void configAuthentication(AuthenticationManagerBuilder auth) 
throws Exception { 
    auth.jdbcAuthentication().dataSource(dataSource) 
      .usersByUsernameQuery("select username, password, enabled from appuser where username = ?") 
      .authoritiesByUsernameQuery("select username, rolename from appuser natural join user_role natural join role where username = ?;"); 
} 
+0

https://github.com/michaellavelle/spring-security-spring-data-dynamodb是我發現的最接近正式答案,但它在三年內還沒有更新,所以我很懷疑該包。您已經在使用目前正在維護的https://github.com/derjust/spring-data-dynamodb,但我沒有看到關於JWT/Spring Security的任何信息。 –

回答

1

您可以使用任何東西作爲Spring Security身份驗證後端。您需要在實現UserDetailsService接口的類中編寫自定義查詢邏輯,並返回實現接口的域對象,但可以使用該類。

您的配置想類似

@Override 
    public void configure(AuthenticationManagerBuilder auth) throws Exception { 
    auth.userDetailsService(myCustomDynamoDbDetailService); 
} 

哪裏myCustomDynamoDBDetailService是你的類,它實現UserDetailService和由DynamoDB的用戶名不查找。

相關問題