Skip to content

Commit

Permalink
JWT migration added and grant type bug fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bertugfahriozer committed Nov 14, 2023
1 parent 31c2b05 commit 79acc8b
Show file tree
Hide file tree
Showing 7 changed files with 581 additions and 13 deletions.
33 changes: 33 additions & 0 deletions app/Database/Migrations/2023-11-14-014725_OauthJwt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace ci4oauth2\Database\Migrations;

use CodeIgniter\Database\Migration;

class OauthJwt extends Migration
{
public function up()
{
$this->forge->addField([
'client_id' =>[
'type'=>'VARCHAR',
'constraint'=>80
],
'subject' =>[
'type'=>'VARCHAR',
'constraint'=>80,
'null'=>true
],
'public_key' =>[
'type'=>'VARCHAR',
'constraint'=>2000
],
]);
$this->forge->createTable('oauth_jwt');
}

public function down()
{
$this->forge->dropTable('oauth_jwt');
}
}
2 changes: 1 addition & 1 deletion app/Libraries/Oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Oauth
*/
public function __construct(string $grantType='password', array $config=[])
{
$this->storage=new \OAuth2\Storage\Pdo(['dsn'=>'mysql:dbname='.getenv('database.default.database').';host='.getenv('database.default.hostname'),'username'=>getenv('database.default.username'),'password'=>getenv('database.default.password')]);
$this->storage=new \ci4oauth2\Libraries\OauthPdoStorage();
$this->server=new \OAuth2\Server($this->storage,$config);
if(strpos($grantType, "grant-type:jwt-bearer")) $grantType='jwt_bearer';
call_user_func_array([$this,$grantType],func_get_args());
Expand Down
Loading

0 comments on commit 79acc8b

Please sign in to comment.