Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
ClientConfig | |
0.00% |
0 / 12 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
setRedirUrl | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
setConsumer | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
setUserAgent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setAuthenticateOnly | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * @section LICENSE |
4 | * This file is part of the MediaWiki OAuth Client library |
5 | * |
6 | * The MediaWiki OAuth Client library is free software: you can |
7 | * redistribute it and/or modify it under the terms of the GNU General Public |
8 | * License as published by the Free Software Foundation, either version 3 of |
9 | * the License, or (at your option) any later version. |
10 | * |
11 | * MediaWiki OAuth Client library is distributed in the hope that it |
12 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
13 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with the MediaWiki OAuth Client library. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
20 | * @file |
21 | * @copyright © 2015 Chris Steipp, Wikimedia Foundation and contributors. |
22 | */ |
23 | |
24 | namespace MediaWiki\OAuthClient; |
25 | |
26 | /** |
27 | * MediaWiki OAuth client configuration |
28 | */ |
29 | class ClientConfig { |
30 | /** |
31 | * Url to the OAuth special page |
32 | * @var string |
33 | */ |
34 | public $endpointURL; |
35 | |
36 | /** |
37 | * Canonical server url, used to check /identify's iss. |
38 | * A default value will be created based on the provided $endpointURL. |
39 | * @var string |
40 | */ |
41 | public $canonicalServerUrl; |
42 | |
43 | /** |
44 | * Url that the user is sent to. Can be different from $endpointURL to |
45 | * play nice with MobileFrontend, etc. |
46 | * @var string|null |
47 | */ |
48 | public $redirURL = null; |
49 | |
50 | /** |
51 | * Use https when calling the server. |
52 | * @var bool |
53 | */ |
54 | public $useSSL; |
55 | |
56 | /** |
57 | * If you're testing against a server with self-signed certificates, you |
58 | * can turn this off but don't do this in production. |
59 | * @var bool |
60 | */ |
61 | public $verifySSL; |
62 | |
63 | /** |
64 | * @var Consumer|null |
65 | */ |
66 | public $consumer = null; |
67 | |
68 | /** |
69 | * User agent to use with requests |
70 | * |
71 | * @var string|null |
72 | */ |
73 | public $userAgent = null; |
74 | |
75 | /** |
76 | * @var bool If only authentication is requested, and the existing |
77 | * authorization matches, and the only grants are 'mwoauth-authonly' or |
78 | * 'mwoauth-authonlyprivate', proceed without prompting the user. If a |
79 | * custom redirURL is set this has no effect. |
80 | */ |
81 | public $authenticateOnly = false; |
82 | |
83 | /** |
84 | * @param string $url OAuth endpoint URL |
85 | * @param bool $verifySSL |
86 | */ |
87 | public function __construct( $url, $verifySSL = true ) { |
88 | $this->endpointURL = $url; |
89 | $this->verifySSL = $verifySSL; |
90 | |
91 | $parts = parse_url( $url ); |
92 | $this->useSSL = $parts['scheme'] === 'https'; |
93 | $this->canonicalServerUrl = "{$parts['scheme']}://{$parts['host']}" . |
94 | ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ); |
95 | } |
96 | |
97 | /** |
98 | * @param string $redirURL |
99 | * @return ClientConfig Self, for method chaining |
100 | */ |
101 | public function setRedirUrl( $redirURL ) { |
102 | $this->redirURL = $redirURL; |
103 | return $this; |
104 | } |
105 | |
106 | /** |
107 | * @param Consumer $consumer |
108 | * @return ClientConfig Self, for method chaining |
109 | */ |
110 | public function setConsumer( Consumer $consumer ) { |
111 | $this->consumer = $consumer; |
112 | return $this; |
113 | } |
114 | |
115 | /** |
116 | * |
117 | * @param string|null $userAgent |
118 | * @return void |
119 | */ |
120 | public function setUserAgent( ?string $userAgent ) { |
121 | $this->userAgent = $userAgent; |
122 | } |
123 | |
124 | /** |
125 | * @param bool $authenticateOnly |
126 | * @return void |
127 | */ |
128 | public function setAuthenticateOnly( bool $authenticateOnly ) { |
129 | $this->authenticateOnly = $authenticateOnly; |
130 | } |
131 | } |