Giter Site home page Giter Site logo

Crossdomain broken about jwt-auth HOT 3 CLOSED

tymondesigns avatar tymondesigns commented on May 7, 2024
Crossdomain broken

from jwt-auth.

Comments (3)

jossemarGT avatar jossemarGT commented on May 7, 2024

Hello!

It sounds pretty weird that passing the query param token triggers CORS preflight. But implementing the bearer token is easy as:

  • Register jwt auth middlewares in Kernel.php
    'jwt.auth' => 'Tymon\JWTAuth\Middleware\GetUserFromToken',
    'jwt.refresh' => 'Tymon\JWTAuth\Middleware\RefreshToken',
  • Add jwt.auth middleware to the privileged controllers or routes.
  • Add Event::listen('tymon.jwt.valid') hook in the boot function of the EventServiceProvider.php, like this.
    public function boot(DispatcherContract $events)
    {
        parent::boot($events);

        Event::listen('tymon.jwt.valid', function($event)
        {
            Auth::setUser($event);
        });
    }
  • Use Auth::getUser() to check user's model instance.

Hope that helps. :octocat:

PS: This is just for Laravel 5

from jwt-auth.

tymondesigns avatar tymondesigns commented on May 7, 2024

@kthnxbye did you resolve this ?

from jwt-auth.

andresr19 avatar andresr19 commented on May 7, 2024

Yes sr i did, i'll post the answer in github just in case someone else is
having the same problem, actually it was a 'conflict' i dont know where
with another library, I was using a third-party lib to handle the cors but
i switched back the app/filter.php $request approach and it's been working
like a charm since then.

On Thu, Mar 19, 2015 at 2:20 PM, Sean Tymon [email protected]
wrote:

@kthnxbye https://github.com/kthnxbye did you resolve this ?


Reply to this email directly or view it on GitHub
#61 (comment)
.

from jwt-auth.

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.