|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Bluz Framework Component |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Bluz PHP Team |
|
6
|
|
|
* @link https://github.com/bluzphp/framework |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace Bluz\Auth\Model; |
|
12
|
|
|
|
|
13
|
|
|
use Bluz\Db\RowInterface; |
|
14
|
|
|
use Bluz\Db\Table; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Abstract class for Auth\Table |
|
18
|
|
|
* |
|
19
|
|
|
* @package Bluz\Auth |
|
20
|
|
|
* @author Anton Shevchuk |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractTable extends Table |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Types |
|
26
|
|
|
*/ |
|
27
|
|
|
public const TYPE_ACCESS = 'access'; |
|
28
|
|
|
public const TYPE_REQUEST = 'request'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Providers |
|
32
|
|
|
* - equals - login + password |
|
33
|
|
|
* - token - token with ttl |
|
34
|
|
|
* - cookie - cookie token with ttl |
|
35
|
|
|
*/ |
|
36
|
|
|
public const PROVIDER_COOKIE = 'cookie'; |
|
37
|
|
|
public const PROVIDER_EQUALS = 'equals'; |
|
38
|
|
|
public const PROVIDER_FACEBOOK = 'facebook'; |
|
39
|
|
|
public const PROVIDER_GOOGLE = 'google'; |
|
40
|
|
|
public const PROVIDER_LDAP = 'ldap'; |
|
41
|
|
|
public const PROVIDER_TOKEN = 'token'; |
|
42
|
|
|
public const PROVIDER_TWITTER = 'twitter'; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string Table |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $name = 'auth'; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var array Primary key(s) |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $primary = ['provider', 'foreignKey']; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get AuthRow |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $provider |
|
58
|
|
|
* @param string $foreignKey |
|
59
|
|
|
* |
|
60
|
|
|
* @return RowInterface |
|
61
|
|
|
* @throws \InvalidArgumentException |
|
62
|
|
|
* @throws \Bluz\Db\Exception\DbException |
|
63
|
|
|
* @throws \Bluz\Db\Exception\InvalidPrimaryKeyException |
|
64
|
|
|
*/ |
|
65
|
1 |
|
public static function getAuthRow($provider, $foreignKey) : ?RowInterface |
|
66
|
|
|
{ |
|
67
|
1 |
|
return static::findRow(['provider' => $provider, 'foreignKey' => $foreignKey]); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|