回答編集履歴
1
宣言部のみ
answer
CHANGED
@@ -1,4 +1,26 @@
|
|
1
1
|
1. UserDetailsService の実装を自前でしましょう。
|
2
2
|
2. 自前のユーザー情報テーブルの エンティティは UserDetails を継承しましょう
|
3
3
|
|
4
|
-
そうすることでユーザー情報が認証情報として取得できます。
|
4
|
+
そうすることでユーザー情報が認証情報として取得できます。
|
5
|
+
|
6
|
+
|
7
|
+
細かい内部実装は公式ドキュメントにもかいてあるので宣言部だけ
|
8
|
+
```
|
9
|
+
@Service
|
10
|
+
public class UserService implements UserDetailsService {
|
11
|
+
```
|
12
|
+
|
13
|
+
```
|
14
|
+
@Entity
|
15
|
+
@Table(name = "users")
|
16
|
+
public class User implements UserDetails {
|
17
|
+
```
|
18
|
+
|
19
|
+
```
|
20
|
+
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
21
|
+
|
22
|
+
@Override
|
23
|
+
protected void configure(AuthenticationManagerBuilder a) throws Exception {
|
24
|
+
a.userDetailsService(userService).passwordEncoder(passwordEncoder());
|
25
|
+
|
26
|
+
```
|