Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit c4b1b1a

Browse files
committed
✨ removed DBStorage as this is not OAuth business
1 parent 5568a8c commit c4b1b1a

13 files changed

+27
-527
lines changed

.travis.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11
language: php
22

3-
env:
4-
global:
5-
- setup=no_encryption
6-
73
matrix:
84
include:
95
- php: 7.2
10-
env: setup=no_encryption
11-
- php: nightly
12-
env: setup=no_encryption
13-
- php: 7.2
14-
env: setup=sodium_ext
156
- php: nightly
16-
env: setup=sodium_ext
177
allow_failures:
188
- php: nightly
199

20-
mysql:
21-
database: dbtest
22-
username: root
23-
encoding: utf8
24-
25-
before_install:
26-
# Manually compile the libsodium library. This sucks, Travis. https://github.com/travis-ci/travis-ci/issues/8863
27-
- |
28-
if [[ $setup = 'sodium_ext' ]]; then
29-
git clone -b stable https://github.com/jedisct1/libsodium.git;
30-
cd libsodium && sudo ./configure && sudo make check && sudo make install && cd ..;
31-
fi
32-
3310
install:
34-
- |
35-
if [[ $setup = 'sodium_ext' ]]; then
36-
pecl install libsodium;
37-
fi
3811
- curl -o config/cacert.pem https://curl.haxx.se/ca/cacert.pem
3912
- travis_retry composer install --no-interaction --prefer-source
40-
- mysql -e 'create database dbtest;'
4113

4214
script: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
4315

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- PHP 7.2+
2929
- the [Sodium](http://php.net/manual/book.sodium.php) extension for token encryption
3030
- cURL, PHP's stream wrapper or a HTTP client library of your choice
31-
- see [`chillerlan/php-oauth`](https://github.com/chillerlan/php-oauth)
31+
- see [`chillerlan/php-oauth`](https://github.com/chillerlan/php-oauth) for already implemented providers
3232

3333
## Getting Started
3434
In order to instance an [`OAuthInterface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuthInterface.php) you you'll need to invoke a [`HTTPClientInterface`](https://github.com/chillerlan/php-httpinterface/blob/master/src/HTTPClientInterface.php), [`OAuthStorageInterface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Storage/OAuthStorageInterface.php) and `OAuthOptions` (a [`ContainerInterface`](https://github.com/chillerlan/php-traits/blob/master/src/ContainerInterface.php)) objects first:
@@ -182,10 +182,9 @@ class MyOauth2Provider extends Oauth2Provider implements ClientCredentials, CSRF
182182
```
183183

184184
### [`OAuthStorageInterface`](https://github.com/chillerlan/php-oauth-core/tree/master/src/Storage/OAuthStorageInterface.php)
185-
There are currently 3 different `OAuthStorageInterface`, refer to these for implementation details (extend `OAuthStorageAbstract`):
185+
There are 2 different `OAuthStorageInterface`, refer to these for implementation details (extend `OAuthStorageAbstract`):
186186
- [`MemoryStorage`](https://github.com/chillerlan/php-oauth-core/tree/master/src/Storage/MemoryStorage.php): non-persistent, to store an existing token during script runtime and then discard it.
187-
- [`SessionStorage`](https://github.com/chillerlan/php-oauth-core/tree/master/src/Storage/SessionStorage.php): half-persistent, stores a token for as long a user's session is alive, e.g. while authenticating.
188-
- [`DBStorage`](https://github.com/chillerlan/php-oauth-core/tree/master/src/Storage/DBStorage.php): persistent, multi purpose database driven storage with encryption support (via ext-sodium)
187+
- [`SessionStorage`](https://github.com/chillerlan/php-oauth-core/tree/master/src/Storage/SessionStorage.php): (half-)persistent, stores a token for as long a user's session is alive, e.g. while authenticating.
189188

190189
## API
191190
### [`OAuthInterface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuthProvider.php)

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
"chillerlan/php-traits": "^2.0",
2525
"chillerlan/php-httpinterface": "^2.0",
2626
"chillerlan/php-magic-apiclient": "^1.1",
27-
"psr/log": "^1.0",
28-
"psr/simple-cache": "^1.0"
27+
"psr/log": "^1.0"
2928
},
3029
"require-dev": {
31-
"chillerlan/php-database": "^2.1",
3230
"chillerlan/php-log": "^2.0",
3331
"phpunit/phpunit": "^7.3"
3432
},

examples/oauth-example-common.php

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,9 @@
77
* @license MIT
88
*/
99

10-
use chillerlan\Database\{
11-
Database, DatabaseOptionsTrait, Drivers\MySQLiDrv
12-
};
13-
use chillerlan\HTTP\{
14-
HTTPClientAbstract, HTTPResponseInterface, CurlClient
15-
};
16-
use chillerlan\Logger\{
17-
Log, LogOptionsTrait, Output\ConsoleLog
18-
};
19-
use chillerlan\OAuth\{
20-
OAuthOptions, Storage\SessionStorage
21-
};
10+
use chillerlan\HTTP\{CurlClient, HTTPClientAbstract, HTTPResponseInterface};
11+
use chillerlan\Logger\{Log, LogOptionsTrait, Output\ConsoleLog};
12+
use chillerlan\OAuth\{OAuthOptions, Storage\SessionStorage};
2213
use chillerlan\Traits\{DotEnv, ImmutableSettingsInterface};
2314

2415
ini_set('date.timezone', 'Europe/Amsterdam');
@@ -33,20 +24,8 @@
3324
'key' => $env->get($ENVVAR.'_KEY'),
3425
'secret' => $env->get($ENVVAR.'_SECRET'),
3526
'callbackURL' => $env->get($ENVVAR.'_CALLBACK_URL'),
36-
'dbUserID' => 1,
37-
'dbTokenTable' => 'storagetest',
38-
'dbProviderTable' => 'storagetest_providers',
39-
'storageCryptoKey' => '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
4027
'tokenAutoRefresh' => true,
4128

42-
// DatabaseOptions
43-
'driver' => MySQLiDrv::class,
44-
'host' => $env->MYSQL_HOST,
45-
'port' => $env->MYSQL_PORT,
46-
'database' => $env->MYSQL_DATABASE,
47-
'username' => $env->MYSQL_USERNAME,
48-
'password' => $env->MYSQL_PASSWORD,
49-
5029
// HTTPOptions
5130
'ca_info' => $CFGDIR.'/cacert.pem',
5231
'userAgent' => 'chillerlanPhpOAuth/3.0.0 +https://github.com/codemasher/php-oauth',
@@ -60,7 +39,7 @@
6039

6140
/** @var \chillerlan\Traits\ImmutableSettingsInterface $options */
6241
$options = new class($options_arr) extends OAuthOptions{
63-
use DatabaseOptionsTrait, LogOptionsTrait;
42+
use LogOptionsTrait;
6443

6544
protected $sleep;
6645
};
@@ -101,10 +80,6 @@ protected function getResponse():HTTPResponseInterface{
10180

10281
#$http->setLogger($logger);
10382

104-
/** @var \chillerlan\Database\Database $db */
105-
$db = new Database($options);
106-
#$db->setLogger($logger);
107-
10883
/** @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage */
109-
$storage = new SessionStorage($options); //new DBStorage($options, $db);
84+
$storage = new SessionStorage($options);
11085
#$storage->setLogger($logger);

src/OAuthOptions.php

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
namespace chillerlan\OAuth;
1414

1515
use chillerlan\HTTP\HTTPOptionsTrait;
16-
use chillerlan\Traits\{
17-
ImmutableSettingsContainer, ImmutableSettingsInterface, Crypto\MemzeroDestructorTrait
18-
};
16+
use chillerlan\Traits\ImmutableSettingsAbstract;
1917

2018
/**
2119
* OAuthOptionsTrait
@@ -27,25 +25,8 @@
2725
* @property bool $sessionStart
2826
* @property string $sessionTokenVar
2927
* @property string $sessionStateVar
30-
* @property bool $useEncryption
31-
* @property string $storageCryptoKey
3228
* @property bool $tokenAutoRefresh
3329
*
34-
* @property string $dbLabelHashAlgo
35-
* @property string $dbLabelFormat
36-
* @property string|int $dbUserID
37-
*
38-
* @property string $dbTokenTable
39-
* @property string $dbTokenTableExpires
40-
* @property string $dbTokenTableLabel
41-
* @property string $dbTokenTableProviderID
42-
* @property string $dbTokenTableState
43-
* @property string $dbTokenTableToken
44-
* @property string $dbTokenTableUser
45-
*
46-
* @property string $dbProviderTable
47-
* @property string $dbProviderTableID
48-
* @property string $dbProviderTableName
4930
*
5031
* HTTPOptionsTrait
5132
*
@@ -55,22 +36,6 @@
5536
* @property string $ca_info
5637
* @property int $max_redirects
5738
*/
58-
class OAuthOptions implements ImmutableSettingsInterface{
59-
use OAuthOptionsTrait, HTTPOptionsTrait, MemzeroDestructorTrait, ImmutableSettingsContainer{
60-
__construct as protected containerConstruct;
61-
}
62-
63-
/**
64-
* OAuthOptions constructor.
65-
*
66-
* @param iterable|null $properties
67-
*/
68-
public function __construct(iterable $properties = null){
69-
// enable encryption by default if possible...
70-
$this->useEncryption = extension_loaded('sodium');
71-
72-
// ... then load and override the settings
73-
$this->containerConstruct($properties);
74-
}
75-
39+
class OAuthOptions extends ImmutableSettingsAbstract{
40+
use OAuthOptionsTrait, HTTPOptionsTrait;
7641
}

src/OAuthOptionsTrait.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,50 +49,9 @@ trait OAuthOptionsTrait{
4949
*/
5050
protected $sessionStateVar = 'chillerlan-oauth-state';
5151

52-
/**
53-
* @var bool
54-
*/
55-
protected $useEncryption;
56-
57-
/**
58-
* a 32 byte string, hex encoded
59-
*
60-
* @see sodium_crypto_box_secretkey()
61-
*
62-
* @var string
63-
*/
64-
protected $storageCryptoKey;
65-
6652
/**
6753
* @var bool
6854
*/
6955
protected $tokenAutoRefresh = false;
7056

71-
/**
72-
* @var string
73-
*/
74-
protected $dbLabelHashAlgo = 'md5';
75-
76-
/**
77-
* @var string
78-
*/
79-
protected $dbLabelFormat = '%1$s@%2$s'; // user@service
80-
81-
/**
82-
* @var int|string
83-
*/
84-
protected $dbUserID;
85-
86-
protected $dbTokenTable;
87-
protected $dbTokenTableExpires = 'expires';
88-
protected $dbTokenTableLabel = 'label';
89-
protected $dbTokenTableProviderID = 'provider_id';
90-
protected $dbTokenTableState = 'state';
91-
protected $dbTokenTableToken = 'token';
92-
protected $dbTokenTableUser = 'user_id';
93-
94-
protected $dbProviderTable;
95-
protected $dbProviderTableID = 'provider_id';
96-
protected $dbProviderTableName = 'servicename';
97-
9857
}

0 commit comments

Comments
 (0)