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

Upgrade jsonwebtoken #154

Merged
5 commits merged into from
Sep 22, 2022
Merged

Upgrade jsonwebtoken #154

5 commits merged into from
Sep 22, 2022

Conversation

ghost
Copy link

@ghost ghost commented Aug 29, 2022

Description

2022-08-29 13:07:43.695 ERROR 39352 --- [nio-9001-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter] with root cause

java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
        at io.jsonwebtoken.impl.Base64Codec.decode(Base64Codec.java:26) ~[jjwt-0.9.1.jar:0.9.1]
        at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:99) ~[jjwt-0.9.1.jar:0.9.1]
        at edu.tamu.weaver.token.service.TokenService.createToken(TokenService.java:82) ~[token-2.1.1-RC12.jar:na]
        at edu.tamu.weaver.token.service.TokenService.craftToken(TokenService.java:130) ~[token-2.1.1-RC12.jar:na]
        at edu.tamu.weaver.token.provider.controller.TokenController.token(TokenController.java:45) ~[token-provider-2.1.1-RC12.jar:na]

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Building and deploying multiple Weaver UIs against AuthService.

  • AuthService
  • MyLibraryUI
  • DirectoryUI
  • MAGPIE UI
  • Project Management UI
  • Library Service System Status UI
  • Get It For Me Button UI
  • CAP
  • SAGE

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@ghost ghost requested a review from kaladay August 29, 2022 18:09
@coveralls
Copy link

coveralls commented Aug 29, 2022

Pull Request Test Coverage Report for Build 2956432040

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 2929102844: 0.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

@ghost ghost removed the request for review from kaladay August 29, 2022 20:45
Comment on lines +158 to +162
String hash = no.toString(16);

while (hash.length() < 32) {
hash = "0" + hash;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not following this logic.

If length < 32, why prepend a 0.

Copy link
Author

@ghost ghost Aug 30, 2022

Choose a reason for hiding this comment

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

It ensures it is a 256 bit to use with HS512 signature algorithm.

Copy link
Author

@ghost ghost Aug 30, 2022

Choose a reason for hiding this comment

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

So the confusing part in this service is that the secret was used for both signing the JWT and then encrypting the JWT. With the jsonwebtoken upgrade the methods we used have been deprecated and require a key or key pair now to sign the JWT. I just added this hack to hash the secret to a 256 bit secret.

@ghost ghost requested review from kaladay, jcreel and jeremythuff September 13, 2022 13:11
@ghost ghost requested review from mumptastic and rmathew1011 September 21, 2022 15:21
@ghost ghost merged commit aca4e11 into 2.x Sep 22, 2022
@ghost ghost deleted the 2.x-jsonwebtoken-upgrade branch September 22, 2022 12:45
This pull request was closed.
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.

4 participants