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

JWT not being re-generated by default #51

Closed
jvictorcf opened this issue Jul 1, 2020 · 7 comments
Closed

JWT not being re-generated by default #51

jvictorcf opened this issue Jul 1, 2020 · 7 comments

Comments

@jvictorcf
Copy link

What would you like to change?

We had some issues regarding JWT not being re-generated when our JWT didn't contain the "exp" property in the payload.
Since this is used in conjunction with a one-time password, I believe that in the case of the JWT not containing the "exp" property, we should always re-generate it (i.e. re-generating should be the default behaviour).
My fear is that if we ever handle a payload that doesn't have an "exp" property, we'll be always returning the same token until spring is restarted.

I'd like to know what the team thinks about it. This is only my interpretation.

References:
One-time password:


Re-generation logic:
return expDate != null && Date.from(now().plus(refreshTimeDelta)).after(expDate);

How do you think that would improve the project?

I think it could prevent problems in production and make functional testing less dependant on testers using the "exp" property.

If this entry is related to a bug, please provide the steps to reproduce it

  1. Mock the return of the "/lease" endpoint to be a valid JWT with no "exp" property.
  2. Generate the token (AuthTokenGenerator.generate())
  3. Reset the mock
  4. Mock it again with another valid JWT token also with no "exp" property.
  5. Generate the token (AuthTokenGenerator.generate())
    You will see that steps 2 and 5 will generate the same token (i.e. the service no longer queries the "/lease" endpoint.
@timja
Copy link
Contributor

timja commented Jul 1, 2020

When does it not have the exp property?

@jvictorcf
Copy link
Author

jvictorcf commented Jul 1, 2020

I'm not sure, @timja. This comes from IDAM and it seems the property is there at the moment. But from this component's perspective, we can never be sure.
And If the property is ever missing, does that mean the token never expires or does it mean it's a one-time token (and should, therefore, be re-generated every time the method is called)?

@timja
Copy link
Contributor

timja commented Jul 1, 2020

It's part of the API contract though, it should always be there =/.

@jvictorcf
Copy link
Author

Is it? If that's the case, then might not be a problem while the ServiceAuthTokenGenerator implementation is used.
I guess I'm thinking of service-auth-provider-java-client as a separate component that have its own rules regardless of whether "exp" is provided.

@timja
Copy link
Contributor

timja commented Jul 1, 2020

Are you mocking the value that's being returned by the s2s server?

If so it sounds like you aren't mocking it correctly.

@jvictorcf
Copy link
Author

Hi @timja. We are mocking it and you're right, the value was wrong (as it didn't have the "exp" property).
That's fixed now. My only concern (and reason for raising this discussion) is what would happen if this payload came from production without the "exp" property.
If the current behaviour (not refreshing unless there is an "exp" property) is expected, then that's fine. Happy to close this.

@timja
Copy link
Contributor

timja commented Jul 2, 2020

It's part of the API contract, so no not an issue

@timja timja closed this as completed Jul 2, 2020
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

No branches or pull requests

2 participants