-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
Use resolver in security middleware #1553
Conversation
Pull Request Test Coverage Report for Build 2531413147
💛 - Coveralls |
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, LGTM! Had 1 question though.
I really like the idea of making the operation class a simple class that only contains functionality to the operation object as specified in the spec (e.g. fetch parameters from the common definitions, or in case of security, get the applicable security for this operation in case it's defined both globally and on the operation).
connexion/middleware/security.py
Outdated
try: | ||
self.add_operation(path, method) | ||
except ResolverError: | ||
# ResolverErrors are handled in routing middleware |
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.
Why don't we propagate the error in this case?
If the resolving fails, it is normally already raised in the routing middleware, or am I mistaken?
But if it is already raised there, then we don't need to account for it here?
So, not sure what the flow is here :)
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.
Resolution is done at start up. So
- if the
ResolverError
is not handled in the routing middleware, start up will fail and this code will indeed never be reached. - If the
ResolverError
is handled in the routing middleware, it will still be raised here during start-up, but a request will never reach the operation since it will already be handled by theresolver_error_handler
in the routing middleware.
I can add some more explanation to the comment, but open to suggestions on how to handle it more clearly in code.
f928a79
to
396ce08
Compare
Continues on #1514.
This PR continues the implementation of the security middleware, which was started in #1514. I took some shortcuts in the original PR, one of them the naive 'resolution' of the
operation_id
by fetching it from the spec instead of relying on a resolver.connexion/connexion/middleware/security.py
Line 93 in b561ecf
This PR replaces this with resolution via resolver.
You'll see that I rely on the original Connexion
Operation
classes for this, instead of on theResolver
directly. I propose to further hollow out theOperation
classes during the refactoring into a middleware stack, until it becomes a 'data class' providing an interface for the specification of the operation across openapi versions. This is similar to theSpecification
class, but on an operation level.Specific middleware operations such as
SecurityOperation
andRoutingOperation
can then use thisOperation
object to initialize themselves. I added this for theRoutingOperation
as a separate commit.