feat(api): Implement refresh token strategy #235
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remember to add the following code in
shared/config/.env
and.env.test
This pull request introduces a refresh token mechanism to the authentication system, enhancing the security and usability of the token-based authentication. The most important changes include the addition of new methods for handling refresh tokens, updates to existing services and DTOs, and the implementation of integration tests for the new functionality.
Authentication Enhancements:
refreshToken
method toAuthenticationController
to handle refresh token requests.refreshAuthTokens
method inAuthenticationService
to refresh authentication tokens using the refresh token.logIn
method inAuthenticationService
to return both access and refresh tokens.JWT Management:
refreshAuthTokens
andcreateAuthTokenPair
methods toJwtManager
to handle token creation and refreshing.signAccessToken
andcreateRefreshToken
methods inJwtManager
to generate tokens with expiration times.Configuration and Utilities:
auth-config.handler.ts
and.env.test
file. [1] [2]TimeUtils
utility for parsing duration strings into seconds.Integration Tests:
refresh-token.spec.ts
.DTO and Contract Updates:
UserWithAuthTokens
DTO to include refresh token information. [1] [2]AuthTokenPair
type andRefreshTokenSchema
for handling refresh token responses and requests. [1] [2]auth.contract.ts
to include the newrefreshToken
endpoint.