Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Spring Security Oath2 and Jwt for knowing how it work

I have successfully implemented Spring Boot Oath2 and Jwt in my Spring Boot Application. It work nice. Now i want know how it work, specially how it process access token when server receive any hit but to do that i'm unable to find the class in where i will put the break points because it handle all work internally. So to debug my application for knowing how it process every request from client, in where or in which class do in need to put break points? i can put break points inside my class which i created but that's not the scenery because Sprint Boot Oath2 and Jwt do that task internally by default, i need to put break in their.

like image 669
Rhidoy Avatar asked Oct 27 '25 12:10

Rhidoy


2 Answers

If you want to debug /oauth/token which generates the Access Token and Refresh Token you need to add a break point in TokenEndpoint.postAccessToken or TokenEndpoint.getAccessToken method based on Request Method type.

If you want to debug the process which validates the Access Token and Authenticates/Authorizes users then you need to add a break point in OAuth2AuthenticationProcessingFilter.doFilter method which responsible for extracting Access Token from Authorization header and authenticating/authorizing users.

like image 77
shazin Avatar answered Oct 30 '25 05:10

shazin


You should add a break point in spring.security.oauth2 in org.springframework.security.oauth2.provider.endpoint.TokenEndpoint method getAccessToken and postAccessToken and in org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter method doFilter and also in org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint method checkToken

like image 42
Saeid Babaei Avatar answered Oct 30 '25 06:10

Saeid Babaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!