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

Is it possible to disable CSRF checks for certain resources/endpoints? #200

Open
preslavrachev opened this issue Feb 29, 2024 · 5 comments

Comments

@preslavrachev
Copy link

One of our applications uses Renarde and there are several controllers that inherit ffrom @Controller, as well as others that should serve as plain REST API endpoints. While I understand the security concerns, these endpoints really don't need this extra layer, as we really only use them internally. I even explicitly annotate endpoints with @Produces and @Consumes to indicate that we are not talking about a controller action, but a plain REST endpoint.

@Consumes("application/json")
@Produces("application/json")

However, the CSRF check would kick in everywhere and would require me to dig in for a CSRF token. Not only that, but if you add DEBUG logging you'll see this in the logs:

Request has the wrong media type: application/json

which makes no sense to me - my request is perfectly fine. It is the CSRF filter that is out of place here.

Anyway, is there a way to disable the filter for certain resources/endpoints? Also, correct me if I am wrong, but this is not the case in a vanilla Quarkus application - only if I add Renarde on top (which, I assume is because if pulls in the CSRF module dependency).

@FroMage
Copy link
Contributor

FroMage commented Mar 1, 2024

You can disable CSRF token verification for non-forms with the quarkus.csrf-reactive.require-form-url-encoded=false configuration.

You can also achieve CSRF token verification using an HTTP header for those APIs.

Does this help?

@preslavrachev
Copy link
Author

@FroMage it did help, indeed. I took some time to check if the CSRF tokens are still required where they should be (and they were), so I guess, this issue can be closed.

However, it opens up an interesting point about documenting it. I checked the entire Renarde documentation and found no mention of it, so I believe it is worth of adding it to the Security page. Should I open a PR?

@FroMage
Copy link
Contributor

FroMage commented Mar 12, 2024

Yes, that'd be great, thanks :)

@felipe-alves-moraes
Copy link

Any news on a documentation regarding those configuration options?
I just had a problem with the same when I enabled renarde into my project and all my "regular" non-mvc endpoints stopped working

@FroMage
Copy link
Contributor

FroMage commented Nov 19, 2024

No update yet, but I'd merge any PR that comes my way :)

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

No branches or pull requests

3 participants