Giter VIP home page Giter VIP logo

Comments (2)

IronSinew avatar IronSinew commented on July 20, 2024 4

I was able to solve this, by the way.

config/lighthouse.php

change 'gate' => null to 'gate' => 'sanctum'

Add EnsureFrontendRequestsAreStateful::class to the route.middleware config

config/graphql-playground.php

route.middleware I added the auth middleware to this, just so that I wouldn't have to get a CSRF cookie / manage login on the playground view. Obviously this could be adjusted to your needs.

Make sure you add this code to GraphQLPlayground.init as documented in the other CSRF protection docs:

settings: {
    'request.credentials': 'same-origin',
},
headers: {
    'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
}

from laravel-graphql-playground.

junioro12 avatar junioro12 commented on July 20, 2024

Interested in this as well...it seems that the graphql requests don't send the "Referer" header, which Sanctum relies on to authenticate. If we inject the header in middleware, then it does authenticate, but that isn't secure. Wondering if there is a way to get the playground graphql calls to send the "Referer" which would seem to solve this.

from laravel-graphql-playground.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.