CodeIgniter Forums
Create JWT Auth in CodeIgniter 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Create JWT Auth in CodeIgniter 4 (/showthread.php?tid=75308)

Pages: 1 2


Create JWT Auth in CodeIgniter 4 - Hyd3r1 - 01-24-2020

Is there a library or a way to create JWT authorization in CodeIgniter 4?


RE: Create JWT Auth in CodeIgniter 4 - mintwint - 01-30-2020

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

Sure!

https://github.com/firebase/php-jwt

This works great in my project CI4.


RE: Create JWT Auth in CodeIgniter 4 - tonynamy - 02-07-2020

(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.


RE: Create JWT Auth in CodeIgniter 4 - kenjis - 06-01-2022

We are developing JWT Authenticator for CodeIgniter Shield.
https://github.com/codeigniter4/shield/pull/195


RE: Create JWT Auth in CodeIgniter 4 - seunex - 06-02-2022

This guy did a good job.
https://github.com/agungsugiarto/codeigniter4-authentication-jwt


RE: Create JWT Auth in CodeIgniter 4 - kenjis - 04-18-2023

We are developing JWT Authenticator for Shield.
See https://github.com/codeigniter4/shield/pull/195

I believe that is very close to completion.


RE: Create JWT Auth in CodeIgniter 4 - InsiteFX - 04-18-2023

@kenjis, Thank you very much.


RE: Create JWT Auth in CodeIgniter 4 - luckmoshy - 04-18-2023

I use JWT with firebase alot https://github.com/firebase/php-jwt in ps4 and it works fine but if you do a module for that ok that looks great news


RE: Create JWT Auth in CodeIgniter 4 - gosocial2 - 04-19-2023

(04-18-2023, 10:17 PM)kenjis Wrote: We are developing JWT Authenticator for Shield.
See https://github.com/codeigniter4/shield/pull/195

I believe that is very close to completion.

Good news! Does the latest version of CodeIgniter Shield finally have a 'groups' table that is joinable via a group_id from the 'users' table?


RE: Create JWT Auth in CodeIgniter 4 - kenjis - 04-19-2023

What's the groups table? I've never heard such a request.

Shield has groups_users table from the beginning.
https://github.com/codeigniter4/shield/blob/779bb12aac715460abde88d84e02bab9776b96ad/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php#L129