verify well known auth headers in nodejs prototype
This way during local development we have an easy way of veriying that
auth actually works.
@@ -2064,8 +2064,18 @@ fs.readFile(demo_schema_things, 'utf8', function(err, ontologyThings) { // read
app.use(cors());
app.use(express.static(__dirname));
const graphQLHandler = graphqlHTTP(() => ({ schema, graphiql: true }))
+ const dummyAuthChecker = (req, res, next) => {
+ const key = '657a48b9-e000-4d9a-b51d-69a0b621c1b9'
+ const token = '57ac8392-1ecc-4e17-9350-c9c866ac832b'
+ if (req.get('x-api-key') == key && req.get('x-api-token') == token) {
+ next()
+ return
+ }
+
+ res.status(401).send("unauthorized")
+ }
app.use('/graphql', graphQLHandler);
- app.use('/weaviate/v1/graphql', graphQLHandler)
+ app.use('/weaviate/v1/graphql', dummyAuthChecker, graphQLHandler)
app.listen(8081, function() {
const port = this.address().port;
console.log(`Started on http://localhost:${port}/graphql`);
