-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add docs for the CSRF prevention plugin #1060
Conversation
✅ Deploy Preview for apollo-router-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@SimonSapin your pull request is missing a changelog! |
docs/source/configuration/csrf.mdx
Outdated
|
||
Note that all HTTP header names are case-insensitive. | ||
|
||
> CSRF prevention is only applied to requests that will execute GraphQL operations, not to requests that would load [landing pages](../api/plugin/landing-pages) or run [health checks](../monitoring/health-checks).) |
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.
This probably needs change, at least for fixing the links.
Does the router have a landing page, health checks, or anything else that’s not GraphQL requests? Do these go through plugins?
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.
Yes, we have other routes. Looking at this code, for health check, landing page and graphql endpoint the request first goes through CORS, then plugins. While for plugin specific endpoint, the request goes through directly:
router/apollo-router/src/axum_http_server_factory.rs
Lines 101 to 132 in f7fc365
.route( | |
&graphql_endpoint, | |
get({ | |
let display_landing_page = configuration.server.landing_page; | |
move |host: Host, | |
service: Extension<BufferedService>, | |
http_request: Request<Body>| { | |
handle_get(host, service, http_request, display_landing_page) | |
} | |
}) | |
.post(handle_post), | |
) | |
.layer( | |
TraceLayer::new_for_http() | |
.make_span_with(PropagatingMakeSpan::new()) | |
.on_response(|resp: &Response<_>, _duration: Duration, span: &Span| { | |
if resp.status() >= StatusCode::BAD_REQUEST { | |
span.record( | |
"otel.status_code", | |
&opentelemetry::trace::StatusCode::Error.as_str(), | |
); | |
} else { | |
span.record( | |
"otel.status_code", | |
&opentelemetry::trace::StatusCode::Ok.as_str(), | |
); | |
} | |
}), | |
) | |
.route("/.well-known/apollo/server-health", get(health_check)) | |
.layer(Extension(boxed_service)) | |
.layer(cors); |
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.
I’ve removed the note for now and opened #1081 to follow up.
This closes #1039, right? |
Oh indeed. I’ve added the magic keyword in the PR description. |
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.
This looks great, congratulations! 🎉
4e4d742
to
8884b78
Compare
8884b78
to
7ac52bc
Compare
Fixes #1039
The plugin was added in #1006
Docs are imported from Apollo Server’s own docs and adapted.