Editorial fixes - #322
Editorial fixes#322
Conversation
|
tagged @a-alle for the relationship suggestions because it was your PR when it was added and @Liam-Doodson for the rest. feel free to forward |
|
|
||
| An example of configuring user switching on a per request basis can be found in the example below. Note that the username and password are provided in HTTP headers `User` and `Password`, but this would not be recommended for production use: | ||
| The example below showcases the configuration of user switching on a per request basis. | ||
| Note that the username and password are provided via the HTTP headers `User` and `Password`. |
There was a problem hiding this comment.
Should we just use different examples if this is not recommended in prod? (We might have the same issue in MCP actually but that's for a different PR:))
There was a problem hiding this comment.
what would be the standard way of providing username + password under production use circumstances, and would this make the example considerably longer?
i absolutely see the point - if we can provide an example without the "asterisk" (don't use this in prod!), that would be great. maybe it was written this way with conciseness considerations in mind?
There was a problem hiding this comment.
We'd need to verify it works but using bearer auth with an oidc provider configured for the db would be more secure. i.e. something like this:
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { Neo4jGraphQL, Neo4jGraphQLContext } from "@neo4j/graphql";
import neo4j from "neo4j-driver";
const typeDefs = `#graphql
type Movie @node {
title: String!
}
`;
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("username", "password")
);
const neo4jGraphql = new Neo4jGraphQL({
typeDefs,
driver,
});
const schema = await neo4jGraphql.getSchema();
const server = new ApolloServer<Neo4jGraphQLContext>({
schema,
});
const { url } = await startStandaloneServer(server, {
context: async ({ req }) => {
const authHeader = req.headers.authorization ?? "";
const [scheme, token] = authHeader.split(" ");
if (scheme !== "Bearer" || !token) {
throw new Error("Missing or malformed Bearer token");
}
return {
sessionConfig: {
auth: neo4j.auth.bearer(token),
},
};
},
});
console.log(`🚀 Server ready at: ${url}`);
We'd probably have to check that snippet actually works and clarify that the bearer token needs to be signed by an oidc provider configured for the db
There was a problem hiding this comment.
This could probably be done in a follow-up PR though tbh as it requires a bit more correctness checking than the rest of these changes
Co-authored-by: kerem <kerem.gocen@neo4j.com>
Co-authored-by: Liam-Doodson <114480811+Liam-Doodson@users.noreply.github.com>
|
Thanks for the documentation updates. The preview documentation has now been torn down - reopening this PR will republish it. |
No description provided.