Welcome Guest, Not a member yet? Register   Sign In
Create JWT Auth in CodeIgniter 4
#3

(01-24-2020, 12:27 PM)Hyd3r1 Wrote: Is there a library or a way to create JWT authorization in CodeIgniter 4?

Yes, I'm also using jwt authorization.

First, download php files from php-jwt.

Second, place BeforeValidException.php, ExpiredException.php, JWT.php, SignatureInvalidException.php under /app/ThirdParty/Firebase/JWT

Third, add 'Firebase'   => APPPATH . 'ThirdParty/Firebase', to psr4 variable inside of /app/Config/Autoload.php

Now you can load JWT library with : use Firebase\JWT\JWT;

Additionally, I wanted to make something like JwtMiddleWare in Node.js, so I made custom filter and add the following code in before function.

Code:
$decoded = JWT::decode(...);
$request->user = new \stdClass();
$request->user = $decoded;
return $request;

Maybe I'm doing something wrong, but so far, it works correctly.
Reply


Messages In This Thread
Create JWT Auth in CodeIgniter 4 - by Hyd3r1 - 01-24-2020, 12:27 PM
RE: Create JWT Auth in CodeIgniter 4 - by tonynamy - 02-07-2020, 07:40 AM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 06-01-2022, 09:55 PM
RE: Create JWT Auth in CodeIgniter 4 - by seunex - 06-02-2022, 05:48 AM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 04-18-2023, 10:17 PM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 04-19-2023, 02:31 AM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 04-19-2023, 10:07 PM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 04-19-2023, 05:37 AM
RE: Create JWT Auth in CodeIgniter 4 - by kenjis - 04-21-2023, 07:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB