Integration of league\OAuth2 for CakePHP ^3.5
.
Inspired by uafrica/oauth-server and laravel/Passaport.
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require cauancabral/oauth-server2
You should generate a secure encryptation key and a public/private key pair.
First, we'll generate encryptation key running the command:
vendor/bin/generate-defuse-key
Copy printed string to use later. That string will be referenced as GENERATED ENCRYPTATION KEY
Now you need a pair of public/private keys. Just run the command:
bin/cake OauthServer2.generate_keypair config/
This generate two new files, with the names private.key
and public.key
on config
path.
Now you need to setup the follow configurations:
return [
...
'OAuth' => [
'public_key' => env('OAUTH_PUBLIC_KEY', '/your/path/to/public.key'),
'private_key' => env('OAUTH_PRIVATE_KEY', '/your/path/to/private.key'),
'encryptation_key' => env('OAUTH_ENCRYPTATION_KEY', 'GENERATED ENCRYPTATION KEY'),
]
]
As you can see, its possible to use ENV variables to override above values. So, if you want to setup your configurations on
.env
, its OK, but don't forget to put that snippet on yourapp.php
Run migrations to setup default database schema:
bin/cake migrations migrate -p OauthServer2
That will create 9 new tables, with oauth_
prefix name.
If you want to customize the structure, you can copy migrations source, edit and run your local migration instead.