@@ -8,136 +8,144 @@ class OAuthAdmin {
88
99 private static $ config ;
1010
11+ private const OAUTH1 = 'OAuth1 ' ;
12+
13+ private const OAUTH2 = 'OAuth2 ' ;
14+
15+ private const OPENID = 'OpenID ' ;
16+
17+ private const HYBRID = 'Hybrid ' ;
18+
1119 public const CONFIG_FILE_NAME = 'oauth.php ' ;
1220
1321 public const PROVIDERS = [
1422 'Amazon ' => [
15- 'type ' => ' OAuth2 ' ,
23+ 'type ' => self :: OAUTH2 ,
1624 'dev ' => 'https://developer.amazon.com '
1725 ],
1826 'AOLOpenID ' => [
19- 'type ' => ' OpenID '
27+ 'type ' => self :: OPENID
2028 ],
2129 'Authentiq ' => [
22- 'type ' => ' OAuth2 '
30+ 'type ' => self :: OAUTH2
2331 ],
2432 'BitBucket ' => [
25- 'type ' => ' OAuth2 '
33+ 'type ' => self :: OAUTH2
2634 ],
2735 'Blizzard ' => [
28- 'type ' => ' OAuth2 '
36+ 'type ' => self :: OAUTH2
2937 ],
3038 'Discord ' => [
31- 'type ' => ' OAuth2 '
39+ 'type ' => self :: OAUTH2
3240 ],
3341 'Disqus ' => [
34- 'type ' => ' OAuth2 '
42+ 'type ' => self :: OAUTH2
3543 ],
3644 'Dribbble ' => [
37- 'type ' => ' OAuth2 '
45+ 'type ' => self :: OAUTH2
3846 ],
3947 'Facebook ' => [
40- 'type ' => ' OAuth2 '
48+ 'type ' => self :: OAUTH2
4149 ],
4250 'Foursquare ' => [
43- 'type ' => ' OAuth2 '
51+ 'type ' => self :: OAUTH2
4452 ],
4553 'GitHub ' => [
46- 'type ' => ' OAuth2 '
54+ 'type ' => self :: OAUTH2
4755 ],
4856 'GitLab ' => [
49- 'type ' => ' OAuth2 '
57+ 'type ' => self :: OAUTH2
5058 ],
5159 'Google ' => [
52- 'type ' => ' OAuth2 ' ,
60+ 'type ' => self :: OAUTH2 ,
5361 'dev ' => 'https://console.developers.google.com/ '
5462 ],
5563 'Instagram ' => [
56- 'type ' => ' OAuth2 '
64+ 'type ' => self :: OAUTH2
5765 ],
5866 'LinkedIn ' => [
59- 'type ' => ' OAuth2 '
67+ 'type ' => self :: OAUTH2
6068 ],
6169 'Mailru ' => [
62- 'type ' => ' OAuth2 '
70+ 'type ' => self :: OAUTH2
6371 ],
6472 'MicrosoftGraph ' => [
65- 'type ' => ' OAuth2 '
73+ 'type ' => self :: OAUTH2
6674 ],
6775 'Odnoklassniki ' => [
68- 'type ' => ' OAuth2 '
76+ 'type ' => self :: OAUTH2
6977 ],
7078 'OpenID ' => [
71- 'type ' => ' OpenID '
79+ 'type ' => self :: OPENID
7280 ],
7381 'ORCID ' => [
74- 'type ' => ' OAuth2 '
82+ 'type ' => self :: OAUTH2
7583 ],
7684 'Paypal ' => [
77- 'type ' => ' OpenID '
85+ 'type ' => self :: OPENID
7886 ],
7987 'PaypalOpenID ' => [
80- 'type ' => ' OpenID '
88+ 'type ' => self :: OPENID
8189 ],
8290 'QQ ' => [
83- 'type ' => ' OAuth2 '
91+ 'type ' => self :: OAUTH2
8492 ],
8593 'Reddit ' => [
86- 'type ' => ' OAuth2 '
94+ 'type ' => self :: OAUTH2
8795 ],
8896 'Slack ' => [
89- 'type ' => ' OAuth2 '
97+ 'type ' => self :: OAUTH2
9098 ],
9199 'Spotify ' => [
92- 'type ' => ' OAuth2 '
100+ 'type ' => self :: OAUTH2
93101 ],
94102 'StackExchange ' => [
95- 'type ' => ' OAuth2 '
103+ 'type ' => self :: OAUTH2
96104 ],
97105 'StackExchangeOpenID ' => [
98- 'type ' => ' OpenID '
106+ 'type ' => self :: OPENID
99107 ],
100108 'Steam ' => [
101- 'type ' => ' Hybrid '
109+ 'type ' => self :: HYBRID
102110 ],
103111 'Strava ' => [
104- 'type ' => ' OAuth2 '
112+ 'type ' => self :: OAUTH2
105113 ],
106114 'SteemConnect ' => [
107- 'type ' => ' OAuth2 '
115+ 'type ' => self :: OAUTH2
108116 ],
109117 'Telegram ' => [
110- 'type ' => ' Hybrid '
118+ 'type ' => self :: HYBRID
111119 ],
112120 'Tumblr ' => [
113- 'type ' => ' OAuth1 '
121+ 'type ' => self :: OAUTH1
114122 ],
115123 'TwitchTV ' => [
116- 'type ' => ' OAuth2 '
124+ 'type ' => self :: OAUTH2
117125 ],
118126 'Twitter ' => [
119- 'type ' => ' OAuth1 '
127+ 'type ' => self :: OAUTH1
120128 ],
121129 'Vkontakte ' => [
122- 'type ' => ' OAuth2 '
130+ 'type ' => self :: OAUTH2
123131 ],
124132 'WeChat ' => [
125- 'type ' => ' OAuth2 '
133+ 'type ' => self :: OAUTH2
126134 ],
127135 'WindowsLive ' => [
128- 'type ' => ' OAuth2 '
136+ 'type ' => self :: OAUTH2
129137 ],
130138 'WordPress ' => [
131- 'type ' => ' OAuth2 '
139+ 'type ' => self :: OAUTH2
132140 ],
133141 'Yandex ' => [
134- 'type ' => ' OAuth2 '
142+ 'type ' => self :: OAUTH2
135143 ],
136144 'Yahoo ' => [
137- 'type ' => ' OAuth2 '
145+ 'type ' => self :: OAUTH2
138146 ],
139147 'YahooOpenID ' => [
140- 'type ' => ' OpenID '
148+ 'type ' => self :: OPENID
141149 ]
142150 ];
143151
@@ -214,7 +222,7 @@ public static function loadProvidersConfig(): array {
214222 public static function getProviderConfig (string $ name ): array {
215223 $ default = self ::DEFAULT_PROVIDER_CONFIG ;
216224 $ providerType = self ::PROVIDERS [$ name ]['type ' ] ?? '' ;
217- if ($ providerType !== ' OAuth2 ' && $ providerType !== ' OAuth1 ' ) {
225+ if ($ providerType !== self :: OAUTH1 && $ providerType !== self :: OAUTH2 ) {
218226 $ default = [
219227 'enabled ' => false ,
220228 'force ' => false
@@ -320,7 +328,7 @@ public static function getRedirectRoute(?string $siteUrl = null): string {
320328 * @return string
321329 */
322330 public static function getProviderType (string $ name ) {
323- return self ::PROVIDERS [$ name ]['type ' ] ?? ' OAuth2 ' ;
331+ return self ::PROVIDERS [$ name ]['type ' ] ?? self :: OAUTH2 ;
324332 }
325333}
326334
0 commit comments