[Laravel] passport 인증 실패 익셉션 발생시 Authoization header 를 날림
인증 실패 발생시 클라이언트의 device id 와 액세스 토큰을 로그로 남겨야 할 일이 있어 작업을 하던 도중 액세스 토큰이 보이질 않아 당황. 코드를 좀 살펴보니 passport 에서 Authoization header 를 날려버리길래 궁금해서 살펴보니 이러한 히스토리가 있었다.
누군가가 이걸 왜 날리냐고 이슈에 질문..
https://github.com/laravel/passport/issues/1309
Do not overwrite the authorization header · Issue #1309 · laravel/passport
Hi, in the TokenGuard the authorization header will be overwritten when the authentication request was invalid passport/src/Guards/TokenGuard.php Line 208 in 7ddaa0f $request->headers->set('Authori...
github.com
알고보니 예전에 이러한 이슈 때문에 추가된 코드.
passport 토큰 가드 -> 익셉션 핸들러 report -> passport 토큰가드 이런식으로 무한루프 이슈 발생
그렇다고 갑자기 헤더에 있는 값을 날려버리니 뭔가 깔끔하지 못한 방법같긴 한데..
https://github.com/laravel/passport/issues/632
Infinite loop, stack overflow · Issue #632 · laravel/passport
Hi, I have two projects, both using L5.5 and latest Laravel Passport. Both projects runs under a docker environment, but the first one works, the last don't. Actually, both worked, but after some p...
github.com
우선 작업을 위해 passport/src/Guards/TokenGuard.php 를 상속받은 클래스를 만들어 메소드 오버라이딩을 통해 로깅 코드를 추가하였다. 그리고 새로 만든 클래스는 서비스프로바이더를 통해 기존의 TokenGuard 를 덮어씌워서 해결 하였다.