-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat(server): add support for multiple auth tokens via env vars #339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. LGTM (unless I missed some Rust specific optimization I am not aware of, since I am not a Rust expert).
Oh, could you add a test to the fixtures as well? |
I was wondering if it would be better to entire file -> calls trim once instead of n of lines time |
Sure! I didn't see an option to set env vars tho... Did i miss something? |
One would have to run perf tests for the difference, but I doubt it is huge for a small to medium sized file with tokens. The only workflow optimization I can think of is that the file is not read and parsed every time a request is made, but only when the config is read or reloaded via If you want to try that, please go ahead. |
No, you are correct. @orhun are you ok with adding another hook to add env vars to the fixtures? e.g. in
and then we only need in the
P.S.: Hmm, since the |
That'd make definitely sense! I was a bit surprised to see that |
This is a good question. I think it developed this way. At the beginning there was only one token in the config file and one env var. I added the multiple tokens and delete tokens, and then it was refactored by somebody else to be used as a middleware with web grants. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! We can simplify it a bit :)
Hmm, yeah, if it is not much of a hassle. Bash is annoying.
We use a library called Line 417 in 1d5a9c6
Line 153 in 1d5a9c6
Implemented in #199 That is why
That means we need to store the tokens somewhere (probably in memory) and that's not how the grants library works. |
Alright, thank you for the explanation, should I then leave out the improvements mentioned by tessus (#339 (comment))? I'll also add the env handling to the fixture script. |
Should be all good now:
|
…a single fixture Define the custom_env function in your fixture to set environment variables.
Applied all requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks.
One last thing. Could you please update the README in the fixtures dir?
Can you please add the new function to the file format?
Thanks, I missed it. All good then! I think it is ready to be merged. |
Add support for reading a list of newline separated tokens from a file which path is being supplied through the following environment variables: - AUTH_FILE - DELETE_FILE
…error - add fixture for auth file testing - add fixture for delete file texting - expiring-file-upload would sometimes fail, so I increased the sleep duration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
Description
Add support for reading a list of newline separated tokens from a file
which path is being supplied through the following environment
variables:
Also add support for setting environment variables inside of fixtures through the optional
custom_env
function.Also describe this new functionality in the readme.
Motivation and Context
Need a way to supply multiple auth token akin to
AUTH_TOKEN
due to agenix behaviour.closes #338
How Has This Been Tested?
Added UTs for file content parsing. File reading has not received any UT, but has been manually tested.
Changelog Entry
Added
AUTH_FILE
andDELETION_FILE
point. This file needs to be a newline separated list of strings. Whitespace is discarded.Types of Changes
Checklist: