szerhusenBC / jwt-spring-security-demo

A demo for using JWT (Json Web Token) with Spring Security and Spring Boot 2
MIT License
3.04k stars 1.33k forks source link

filter chain fire mulitple times(3 times) #88

Closed hafizan closed 5 years ago

hafizan commented 6 years ago

i check log evertime the request made.. it will check 3 times. why is that? log: 2018-06-04 12:12:44.756 WARN 17534 --- [nio-8080-exec-5] o.z.s.JwtAuthenticationTokenFilter : couldn't find bearer string, will ignore the header 2018-06-04 12:12:44.756 INFO 17534 --- [nio-8080-exec-5] o.z.s.JwtAuthenticationTokenFilter : checking authentication for user null 2018-06-04 12:12:44.807 WARN 17534 --- [nio-8080-exec-6] o.z.s.JwtAuthenticationTokenFilter : couldn't find bearer string, will ignore the header 2018-06-04 12:12:44.807 INFO 17534 --- [nio-8080-exec-6] o.z.s.JwtAuthenticationTokenFilter : checking authentication for user null 2018-06-04 12:12:44.808 WARN 17534 --- [nio-8080-exec-7] o.z.s.JwtAuthenticationTokenFilter : couldn't find bearer string, will ignore the header 2018-06-04 12:12:44.808 INFO 17534 --- [nio-8080-exec-7] o.z.s.JwtAuthenticationTokenFilter : checking authentication for user null 2018-06-04 12:12:46.201 WARN 17534 --- [nio-8080-exec-8] o.z.s.JwtAuthenticationTokenFilter : couldn't find bearer string, will ignore the header 2018-06-04 12:12:46.201 INFO 17534 --- [nio-8080-exec-8] o.z.s.JwtAuthenticationTokenFilter : checking authentication for user null

szerhusenBC commented 6 years ago

I tried it with the JS client from the demo and I can't reproduce your problem. I only have one log entry when I request the admin endpoint without authentication. Can you provide more information?

hafizan commented 6 years ago

i use angular 6 for the frontend. and everytime request made, even for login, it will fire like logs above.

cefothe commented 6 years ago

Can you send us your network monitor ? To see how many requests your client make

On Tue, 31 Jul 2018, 12:42 hafizan, notifications@github.com wrote:

i use angular 6 for the frontend. and everytime request made, even for login, it will fire like logs above.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/szerhusenBC/jwt-spring-security-demo/issues/88#issuecomment-409161048, or mute the thread https://github.com/notifications/unsubscribe-auth/AHAHoA_wmTLNAiVOebgy9Vq83D77g-4dks5uMCaXgaJpZM4UYbA1 .

hafizan commented 6 years ago

i try inspect network monitor for request. it looks like it send two request. one OPTIONS method and the other one POST, others request also same, if i send GET request it will together with OPTIONS. so each request become 2.

szerhusenBC commented 6 years ago

OK, this gives us the cause of two log entries. I still don't know why you have three of them. When I perform a request against my demo I only have one entry.

szerhusenBC commented 6 years ago

Perhaps this can help you handling the OPTIONS request:

https://github.com/szerhusenBC/jwt-spring-security-demo/issues/68

hafizan commented 6 years ago

okay..thank you so much for this solution

szerhusenBC commented 6 years ago

@hafizan You're welcome ;) If it is okay I would close this ticket now.

szerhusenBC commented 5 years ago

Closed, because I published a complete new version.