-
Notifications
You must be signed in to change notification settings - Fork 21
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
Alternative white lisiting method because configuration.allowlist_regexp
is error prone
#71
Comments
The thinking was that a micro service would not have a ton of non-authed routes. The app you are referring too is a full stack app that exposes a microservice, which is a pattern we recommend against and that we should avoid. I think this is why your allow list is so complicated. The simplest way I can think of to clean it up would be to accept an array of regexps: configuration.allow_list = [
"/referrals/foo",
"/resque-web",
# etc.
] and then wrap those with I'm not understanding how this plays into the need to store the api client in the environment that. Those should be totally separate concerns from what is allowed/denied. |
Correct. The team is taking steps to move to the recommended architecture in this specific case.
That would be a big improvement in readability within the Stitches initializer within an app and would address some of the pain. But the discoverability of the |
Yeah, the allow list was added kinda hastily as we realized we needed a way to easily opt out some routes from auth—I would agree it's a "thing about routing" and thus kinda belongs in the routes file (thus your point that it's more discoverable). The main "feature" I would want to keep is "auth by default", i.e if you add a route in |
Correct. What it can't do is set the client on the response as is currently happening here: stitches/lib/stitches/api_key.rb Lines 44 to 45 in 80231b3
|
It might not need to, but to leave the |
I'll put a PR together to give us something concrete to point to |
The pain of #61 highlights that this regex is cumbersome to maintain. In referrals, we have an entry that looks like this:
It turns out that there was an overly permissive entry in there which essentially white listed all of the referrals API - not desirable and tests are being back filled.
I'd like to add something that's a bit easier to read/maintain. I spent some time trying to replace the middleware by creating a Rails custom constraint. Constraints have a handle on the request, but not on the response and so I ran into trouble when trying to replicate these lines:
stitches/lib/stitches/api_key.rb
Lines 44 to 45 in 80231b3
Is there a) still a need for these lines, and b) a way to move them out of the middleware? Or maybe some third way to make it more obvious in routes.rb what does/does not require the api_key? A less desirable option would be to add a before_filter in the controllers but I'm guessing that choice was avoided on purpose?
The text was updated successfully, but these errors were encountered: