Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor JwtService to expose issuer/secret #1768

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Conversation

iamacook
Copy link
Member

Summary

The JwtService currently signs, verifies and decodes tokens according to our environment variables and there is no way of overriding these values.

As the Firebase datasource requires a JWT token signed with a custom issuer/secret, this refactors the aforementioned service to facilitate it.

Changes

  • Expose the option to specify issuer/secret to JwtClient, otherwise defaulting to env. vars. in JwtService
  • Remove options that override claims on token, instead opting for their spec, e.g. iat, nbf, exp (instead of issuedAt, notBefore, expiresIn)
  • Accept/return dates for the all spec. specific dateclaims
  • Use JwtService in FirebaseCloudMessagingApiService instead of jsonwebtoken
  • Update tests accordingly

@iamacook iamacook self-assigned this Jul 17, 2024
@iamacook iamacook marked this pull request as ready for review July 17, 2024 08:29
@iamacook iamacook requested a review from a team as a code owner July 17, 2024 08:29
@coveralls
Copy link

coveralls commented Jul 17, 2024

Pull Request Test Coverage Report for Build 9991392254

Details

  • 3 of 16 (18.75%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 48.141%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/datasources/jwt/jwt-claims.entity.ts 0 1 0.0%
src/domain/auth/auth.repository.ts 0 1 0.0%
src/domain/common/utils/time.ts 1 2 50.0%
src/routes/auth/auth.controller.ts 0 1 0.0%
src/datasources/jwt/jwt.module.ts 1 4 25.0%
src/datasources/jwt/jwt.service.ts 1 7 14.29%
Totals Coverage Status
Change from base Build 9991351602: -0.1%
Covered Lines: 4282
Relevant Lines: 7149

💛 - Coveralls

hectorgomezv
hectorgomezv previously approved these changes Jul 17, 2024
Copy link
Member

@hectorgomezv hectorgomezv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻👏🏻👏🏻

Base automatically changed from push-notifications-datasource to main July 18, 2024 12:19
@iamacook iamacook dismissed hectorgomezv’s stale review July 18, 2024 12:19

The base branch was changed.

@iamacook iamacook merged commit 092b282 into main Jul 18, 2024
16 checks passed
@iamacook iamacook deleted the jwt-service-refactor branch July 18, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants