@opencreek/neo4j-graphql-plugin-auth
v2.2.0-oc.3
Published
Auth decode plugins for @opencreek/neo4j-graphql
Downloads
47
Readme
@neo4j/graphql-plugin-auth
Auth decode plugins for @neo4j/graphql
Installation
$ npm install @neo4j/graphql-plugin-auth
Usage
Neo4jGraphQLAuthJWTPlugin
import { Neo4jGraphQL } from "@neo4j/graphql";
import { Neo4jGraphQLAuthJWTPlugin } from "@neo4j/graphql-plugin-auth";
const neoSchema = new Neo4jGraphQL({
typeDefs,
plugins: {
auth: new Neo4jGraphQLAuthJWTPlugin({
secret: "super-secret",
}),
},
});
// Or you can initiate the secret with a function which will run to retrieve the secret when the request comes in
const neoSchema = new Neo4jGraphQL({
typeDefs,
plugins: {
auth: new Neo4jGraphQLAuthJWTPlugin({
secret: (req) => {
return "super-secret";
},
}),
},
});
Neo4jGraphQLAuthJWKSPlugin
import { Neo4jGraphQL } from "@neo4j/graphql";
import { Neo4jGraphQLAuthJWKSPlugin } from "@neo4j/graphql-plugin-auth";
const neoSchema = new Neo4jGraphQL({
typeDefs,
plugins: {
auth: new Neo4jGraphQLAuthJWKSPlugin({
jwksEndpoint: "https://YOUR_DOMAIN/well-known/jwks.json",
}),
},
});
//Or you can pass a function as jskwsEndpoint to compute the endpoint when the request comes in.
const neoSchema = new Neo4jGraphQL({
typeDefs,
plugins: {
auth: new Neo4jGraphQLAuthJWKSPlugin({
jwksEndpoint: (req) => {
let url = "https://YOUR_DOMAIN/well-known/{file}.json";
const fileHeader = req.headers["file"];
url = url.replace("{file}", fileHeader);
return url;
},
}),
},
});