ydb-python-sdk icon indicating copy to clipboard operation
ydb-python-sdk copied to clipboard

Preload private_key in JwtTokenSource

Open LuckySting opened this issue 1 year ago • 0 comments

Loading cryptography keys from pem-encoded bytes string takes a lot of time (~250ms). Due to private_key is not changed during the life of JwtTokenSource it could be done only once, which would significantly speed up token issuing.

Pull request type

Please check the type of change your PR introduces:

  • [ ] Bugfix
  • [x] Feature
  • [ ] Code style update (formatting, renaming)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] Documentation content changes
  • [ ] Other (please describe):

What is the current behavior?

Currently the private key is loaded on each call of token() method, which takes ~250ms.

Issue Number: N/A

What is the new behavior?

Now the private key is loaded only once in class constructor, which leads to speed up of token() method from 250ms to 4ms.

Other information

LuckySting avatar Nov 06 '24 16:11 LuckySting