-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support for creating ServiceAccount from string instead of file path #28
Comments
@makarski This crate currently will read the service account file each time an access token needs to be generated. I'm wondering if this capability is intentional i.e. to support hot swapping credential files? I can keep this capability during my refactor, but it would be simpler without this support. |
@chris13524 thanks for bringing this up and apologies for the late reply. Indeed, I went for the baseline scenario with the files in the first place. However, I can clearly see that you have a valid use case. Help me understand whether I interpret your discussion in the linked issue correctly. The proposed initialization of a In that case I'd be happy to review your PR and make the library better 👍 |
@makarski yes exactly, my goal is to provide a string/bytes/ I do have a design question for you: if you want to keep the behavior that for the file case that this crate will read the latest version of the file each time |
Amazing! As to your question, I would imagine that on default the file would be read only once. It'd be interesting to implement a listener that could be instructed that the file should be reloaded, i.e. as you mentioned hotswapping the key. Currently, if the file is swapped, one would need to implement logic on the caller side and create a new instance of a ServiceAccount. Happy to brainstorm possible design solutions in this thread. |
Unless I'm misunderstanding the code, this is not the case currently, which is why I'm raising the question. Inside
I agree this would be simpler and is what I would expect |
Right now the file is lazily evaluated and will error when the first request is performed e.g. if the credentials file is invalid. This would probably be better anyway if it was read at time of construction in order to detect for errors earlier. Sounds like this was not intended |
You are right and I agree with you, that is clearly an improvement we could go for - load once, keep in memory and avoid reloading from disc. I could look into that on the weekend to implement the change, or alternatively will be happy to review a PR. |
Thanks! I'll include the change in my PR for this issue since it's highly related |
My use case involves handling many auth credentials which are stored in a database. So reading from a file is not ideal.
I'm willing to contribute this support myself :)
The text was updated successfully, but these errors were encountered: