質問編集履歴
1
回答を受けてのソースコード、質問文の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
Spring Securityを使っています。"/auth/logout"というログアウト用URIにアクセスした際に、ログイン時にクッキーとして発行した認証用トークンを削除するようにしたいと思い、WebSecurityConfigurerAdapter継承クラスを以下ソースコードのように設定したのですが、Postmanを使って当該URIにアクセスすると以下エラーメッセージのように404エラーが発生してしまいます。
|
4
|
+
|
5
|
+
(追記)
|
6
|
+
ログイン用のURIである"/login"は、以下ソースコード(追記)のUsernamePasswordAuthenticationFilter継承クラスにおいてコンストラクタで指定しており、このURIへのリクエストは正常に作動します。
|
4
7
|
### エラーメッセージ
|
5
8
|
|
6
9
|
```
|
@@ -55,5 +58,27 @@
|
|
55
58
|
}
|
56
59
|
|
57
60
|
}
|
61
|
+
```
|
62
|
+
|
63
|
+
### ソースコード(追記)
|
64
|
+
```Java
|
65
|
+
public class MyAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
|
66
|
+
|
67
|
+
private AuthenticationManager authenticationManager;
|
68
|
+
private PasswordEncoder passwordEncoder;
|
69
|
+
|
70
|
+
public MyAuthenticationFilter(AuthenticationManager authenticationManager , PasswordEncoder passwordEncoder) {
|
71
|
+
|
72
|
+
this.authenticationManager = authenticationManager;
|
73
|
+
this.passwordEncoder = passwordEncoder;
|
74
|
+
// ログイン用URIの指定
|
75
|
+
this.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/login" , "POST"));
|
76
|
+
|
77
|
+
this.setUsernameParameter("email");
|
78
|
+
this.setPasswordParameter("password");
|
79
|
+
|
80
|
+
}
|
81
|
+
}
|
82
|
+
```
|
58
83
|
|
59
84
|
|