Skip to content
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

Calling middleware handler when routing is not hit #201

Open
tnoborio opened this issue Apr 30, 2021 · 1 comment
Open

Calling middleware handler when routing is not hit #201

tnoborio opened this issue Apr 30, 2021 · 1 comment

Comments

@tnoborio
Copy link

I would like to output the Principal to the log if the authentication is successful.
when the API routing exists, I could log it out by writing the following.

However, when the routing is not hit, the middleware handler is not called.

https://github.com/go-openapi/runtime/blob/master/middleware/router.go#L82-L88

Is there any way to deal with this?

@fredbi
Copy link
Member

fredbi commented Dec 14, 2023

I am afraid this is not possible.

Given that the need for authentication is defined dynamically per route from the spec, we don't authenticate before we get a chance to match the route.

Dealing with a spec that determines which endpoints are subject to authentication is very different from doing it manually by injecting, say, some authentication middleware at the top of your routing tree or on a subtree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants