refactor: replace MerchantJwt with MerchantJwtWithProfileId in AuthenticationType
Type of Change
- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Replaced MerchantJwt with MerchantJwtWithProfileId in Authentication data.
fixes #5937
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
- Supports profile-based authentication
- Making the
user_idfield non-optional for better type safety - Aligning with the new authentication flow requirements
How did you test it?
Pending
Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [x] I addressed lints thrown by
cargo clippy - [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
@ThisIsMani, how do i test the changes as the cargo test isnt working.
@ThisIsMani, how do I test the implementation?
Hey @Rxbber-dxcky, apologies for the delay.
Can you logging the auth_type variable and see the output in the following file.
https://github.com/juspay/hyperswitch/blob/9cd8f001f7360d9b8877fe94b9c185fc237e525c/crates/router/src/services/api.rs#L731
Okay @ThisIsMani, I'll try to do that.
@Rxbber-dxcky, you can trigger the log by doing any API call which uses JWT Auth... Let me know if you need more details.
@Rxbber-dxcky, were you able to test your changes?
@ThisIsMani , I used WSL to use cargo run and its execution gets stopped at router compiling. I think it's probably due to lack of memory. I'll try running it using an actual distro and get back to you.
@ThisIsMani , I can compile the code but whenever I try to use an api call i get the api key invalid for JWT auth. I tried different ways to do it like creating a new user and generating the api key and using pre existing test api key and also tried to configure cookies. And nothing seems to work.
@ThisIsMani, how do i do an api call ?
Hey @Rxbber-dxcky, these are the steps to generate a valid JWT token. Let me know if you face issues.
Step 1:
curl --location 'https://live.hyperswitch.io/api/user/signup' \
--header 'Content-Type: application/json' \
--data '{
"email": "email",
"password": "password"
}'
You will get a token back.
Step 2:
curl --location 'https://live.hyperswitch.io/api/user/2fa/terminate?skip_two_factor_auth=true' \
--header 'Authorization: Bearer TOKEN_FROM_SIGNUP'
You will get another token back.
Using this token, you can hit any API that has JWTAuth.
@ThisIsMani, thank you for the info
@Rxbber-dxcky, were you able to test this? Let me know if you are still facing any issues.
Sorry for the delay, @ThisIsMani I have some academic work going on that's why I've been inactive.I'll complete the task by the next weekend or before.
@ThisIsMani, I have tested the implementation and the authentication is working fine.
@ThisIsMani, the refactoring is good, I didnt get any errors while testing