1 | <?php namespace nyx\auth\id; |
||
12 | abstract class Provider implements interfaces\Provider |
||
13 | { |
||
14 | /** |
||
15 | * @var credentials\Client The credentials used to identify this consumer with the provider. |
||
16 | */ |
||
17 | protected $consumer; |
||
18 | |||
19 | /** |
||
20 | * @var bool Whether the Provider should attempt to retrieve the email address of an entity when performing |
||
21 | * identify calls. |
||
22 | * |
||
23 | * This is kept as a separate, publicly settable behavioural flag because many Providers make |
||
24 | * the entity's email address(es) available only with special permission scopes and/or at different |
||
25 | * endpoints, meaning simple identify() calls which do not rely on the email being available |
||
26 | * can in those cases be simplified by setting this flag to false. |
||
27 | * |
||
28 | * Some Identity Providers do not provide the entity's email address(es) under any circumstances, |
||
29 | * in which case this flag will have no effect. |
||
30 | */ |
||
31 | protected $shouldProvideEmailAddress = true; |
||
32 | |||
33 | /** |
||
34 | * @var \GuzzleHttp\ClientInterface The underlying HTTP Client used for communicating with the provider. |
||
35 | */ |
||
36 | protected $httpClient; |
||
37 | |||
38 | /** |
||
39 | * Constructs a new Identity Provider instance tied to the given client/consumer/application Credentials. |
||
40 | * |
||
41 | * @param credentials\Client $consumer |
||
42 | */ |
||
43 | public function __construct(credentials\Client $consumer) |
||
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | public function getAuthorizeUrl(array $parameters = []) : string |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | public function getExchangeUrl() : string |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | public function getIdentifyUrl() : string |
||
71 | |||
72 | /** |
||
73 | * Checks whether the Provider should attempt to retrieve the email address of an entity when performing |
||
74 | * identify calls. |
||
75 | * |
||
76 | * @see $shouldProvideEmailAddress |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function shouldProvideEmailAddress() : bool |
||
83 | |||
84 | /** |
||
85 | * Sets whether the Provider should attempt to retrieve the email address of an entity when performing |
||
86 | * identify calls. |
||
87 | * |
||
88 | * @param bool $bool |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function setShouldProvideEmailAddress(bool $bool) : Provider |
||
97 | |||
98 | /** |
||
99 | * Builds an URL string from the given base URL and optional additional query parameters. |
||
100 | * |
||
101 | * @param string $base The base URL. |
||
102 | * @param array $query Additional query parameters. |
||
103 | * @return string |
||
104 | */ |
||
105 | protected function buildUrl(string $base, array $query = []) : string |
||
109 | |||
110 | /** |
||
111 | * Returns the underlying HTTP Client used for communicating with the provider. |
||
112 | * |
||
113 | * @return \GuzzleHttp\ClientInterface |
||
114 | */ |
||
115 | protected function getHttpClient() : \GuzzleHttp\ClientInterface |
||
119 | |||
120 | /** |
||
121 | * Sets the underlying HTTP Client used for communicating with the provider. |
||
122 | * |
||
123 | * @param \GuzzleHttp\ClientInterface $client |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function setHttpClient(\GuzzleHttp\ClientInterface $client) : Provider |
||
132 | } |
||
133 |