229 | | 230 | 231 | 232 | 233 | |
---|---|
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 | user_login : '0' ); ?>
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 | |
256 | 257 | |
)
209 | */
210 | $fields = array(
211 | 'login_type' => array(
212 | 'title' => __( 'Login Type', 'daggerhart-openid-connect-generic' ),
213 | 'description' => __( 'Select how the client (login form) should provide login options.', 'daggerhart-openid-connect-generic' ),
214 | 'type' => 'select',
215 | 'options' => array(
216 | 'button' => __( 'OpenID Connect button on login form', 'daggerhart-openid-connect-generic' ),
217 | 'auto' => __( 'Auto Login - SSO', 'daggerhart-openid-connect-generic' ),
218 | ),
219 | 'disabled' => defined( 'OIDC_LOGIN_TYPE' ),
220 | 'section' => 'client_settings',
221 | ),
222 | 'client_id' => array(
223 | 'title' => __( 'Client ID', 'daggerhart-openid-connect-generic' ),
224 | 'description' => __( 'The ID this client will be recognized as when connecting the to Identity provider server.', 'daggerhart-openid-connect-generic' ),
225 | 'example' => 'my-wordpress-client-id',
226 | 'type' => 'text',
227 | 'disabled' => defined( 'OIDC_CLIENT_ID' ),
228 | 'section' => 'client_settings',
229 | ),
230 | 'client_secret' => array(
231 | 'title' => __( 'Client Secret Key', 'daggerhart-openid-connect-generic' ),
232 | 'description' => __( 'Arbitrary secret key the server expects from this client. Can be anything, but should be very unique.', 'daggerhart-openid-connect-generic' ),
233 | 'type' => 'text',
234 | 'disabled' => defined( 'OIDC_CLIENT_SECRET' ),
235 | 'section' => 'client_settings',
236 | ),
237 | 'scope' => array(
238 | 'title' => __( 'OpenID Scope', 'daggerhart-openid-connect-generic' ),
239 | 'description' => __( 'Space separated list of scopes this client should access.', 'daggerhart-openid-connect-generic' ),
240 | 'example' => 'email profile openid offline_access',
241 | 'type' => 'text',
242 | 'disabled' => defined( 'OIDC_CLIENT_SCOPE' ),
243 | 'section' => 'client_settings',
244 | ),
245 | 'endpoint_login' => array(
246 | 'title' => __( 'Login Endpoint URL', 'daggerhart-openid-connect-generic' ),
247 | 'description' => __( 'Identify provider authorization endpoint.', 'daggerhart-openid-connect-generic' ),
248 | 'example' => 'https://example.com/oauth2/authorize',
249 | 'type' => 'text',
250 | 'disabled' => defined( 'OIDC_ENDPOINT_LOGIN_URL' ),
251 | 'section' => 'client_settings',
252 | ),
253 | 'endpoint_userinfo' => array(
254 | 'title' => __( 'Userinfo Endpoint URL', 'daggerhart-openid-connect-generic' ),
255 | 'description' => __( 'Identify provider User information endpoint.', 'daggerhart-openid-connect-generic' ),
256 | 'example' => 'https://example.com/oauth2/UserInfo',
257 | 'type' => 'text',
258 | 'disabled' => defined( 'OIDC_ENDPOINT_USERINFO_URL' ),
259 | 'section' => 'client_settings',
260 | ),
261 | 'endpoint_token' => array(
262 | 'title' => __( 'Token Validation Endpoint URL', 'daggerhart-openid-connect-generic' ),
263 | 'description' => __( 'Identify provider token endpoint.', 'daggerhart-openid-connect-generic' ),
264 | 'example' => 'https://example.com/oauth2/token',
265 | 'type' => 'text',
266 | 'disabled' => defined( 'OIDC_ENDPOINT_TOKEN_URL' ),
267 | 'section' => 'client_settings',
268 | ),
269 | 'endpoint_end_session' => array(
270 | 'title' => __( 'End Session Endpoint URL', 'daggerhart-openid-connect-generic' ),
271 | 'description' => __( 'Identify provider logout endpoint.', 'daggerhart-openid-connect-generic' ),
272 | 'example' => 'https://example.com/oauth2/logout',
273 | 'type' => 'text',
274 | 'disabled' => defined( 'OIDC_ENDPOINT_LOGOUT_URL' ),
275 | 'section' => 'client_settings',
276 | ),
277 | 'acr_values' => array(
278 | 'title' => __( 'ACR values', 'daggerhart-openid-connect-generic' ),
279 | 'description' => __( 'Use a specific defined authentication contract from the IDP - optional.', 'daggerhart-openid-connect-generic' ),
280 | 'type' => 'text',
281 | 'disabled' => defined( 'OIDC_ACR_VALUES' ),
282 | 'section' => 'client_settings',
283 | ),
284 | 'identity_key' => array(
285 | 'title' => __( 'Identity Key', 'daggerhart-openid-connect-generic' ),
286 | 'description' => __( 'Where in the user claim array to find the user\'s identification data. Possible standard values: preferred_username, name, or sub. If you\'re having trouble, use "sub".', 'daggerhart-openid-connect-generic' ),
287 | 'example' => 'preferred_username',
288 | 'type' => 'text',
289 | 'section' => 'client_settings',
290 | ),
291 | 'no_sslverify' => array(
292 | 'title' => __( 'Disable SSL Verify', 'daggerhart-openid-connect-generic' ),
293 | // translators: %1$s HTML tags for layout/styles, %2$s closing HTML tag for styles.
294 | 'description' => sprintf( __( 'Do not require SSL verification during authorization. The OAuth extension uses curl to make the request. By default CURL will generally verify the SSL certificate to see if its valid an issued by an accepted CA. This setting disabled that verification.%1$sNot recommended for production sites.%2$s', 'daggerhart-openid-connect-generic' ), '
', '' ),
295 | 'type' => 'checkbox',
296 | 'section' => 'client_settings',
297 | ),
298 | 'http_request_timeout' => array(
299 | 'title' => __( 'HTTP Request Timeout', 'daggerhart-openid-connect-generic' ),
300 | 'description' => __( 'Set the timeout for requests made to the IDP. Default value is 5.', 'daggerhart-openid-connect-generic' ),
301 | 'example' => 30,
302 | 'type' => 'text',
303 | 'section' => 'client_settings',
304 | ),
305 | 'enforce_privacy' => array(
306 | 'title' => __( 'Enforce Privacy', 'daggerhart-openid-connect-generic' ),
307 | 'description' => __( 'Require users be logged in to see the site.', 'daggerhart-openid-connect-generic' ),
308 | 'type' => 'checkbox',
309 | 'disabled' => defined( 'OIDC_ENFORCE_PRIVACY' ),
310 | 'section' => 'authorization_settings',
311 | ),
312 | 'alternate_redirect_uri' => array(
313 | 'title' => __( 'Alternate Redirect URI', 'daggerhart-openid-connect-generic' ),
314 | 'description' => __( 'Provide an alternative redirect route. Useful if your server is causing issues with the default admin-ajax method. You must flush rewrite rules after changing this setting. This can be done by saving the Permalinks settings page.', 'daggerhart-openid-connect-generic' ),
315 | 'type' => 'checkbox',
316 | 'section' => 'authorization_settings',
317 | ),
318 | 'nickname_key' => array(
319 | 'title' => __( 'Nickname Key', 'daggerhart-openid-connect-generic' ),
320 | 'description' => __( 'Where in the user claim array to find the user\'s nickname. Possible standard values: preferred_username, name, or sub.', 'daggerhart-openid-connect-generic' ),
321 | 'example' => 'preferred_username',
322 | 'type' => 'text',
323 | 'section' => 'client_settings',
324 | ),
325 | 'email_format' => array(
326 | 'title' => __( 'Email Formatting', 'daggerhart-openid-connect-generic' ),
327 | 'description' => __( 'String from which the user\'s email address is built. Specify "{email}" as long as the user claim contains an email claim.', 'daggerhart-openid-connect-generic' ),
328 | 'example' => '{email}',
329 | 'type' => 'text',
330 | 'section' => 'client_settings',
331 | ),
332 | 'displayname_format' => array(
333 | 'title' => __( 'Display Name Formatting', 'daggerhart-openid-connect-generic' ),
334 | 'description' => __( 'String from which the user\'s display name is built.', 'daggerhart-openid-connect-generic' ),
335 | 'example' => '{given_name} {family_name}',
336 | 'type' => 'text',
337 | 'section' => 'client_settings',
338 | ),
339 | 'identify_with_username' => array(
340 | 'title' => __( 'Identify with User Name', 'daggerhart-openid-connect-generic' ),
341 | 'description' => __( 'If checked, the user\'s identity will be determined by the user name instead of the email address.', 'daggerhart-openid-connect-generic' ),
342 | 'type' => 'checkbox',
343 | 'section' => 'client_settings',
344 | ),
345 | 'state_time_limit' => array(
346 | 'title' => __( 'State time limit', 'daggerhart-openid-connect-generic' ),
347 | 'description' => __( 'State valid time in seconds. Defaults to 180', 'daggerhart-openid-connect-generic' ),
348 | 'type' => 'number',
349 | 'section' => 'client_settings',
350 | ),
351 | 'token_refresh_enable' => array(
352 | 'title' => __( 'Enable Refresh Token', 'daggerhart-openid-connect-generic' ),
353 | 'description' => __( 'If checked, support refresh tokens used to obtain access tokens from supported IDPs.', 'daggerhart-openid-connect-generic' ),
354 | 'type' => 'checkbox',
355 | 'section' => 'client_settings',
356 | ),
357 | 'link_existing_users' => array(
358 | 'title' => __( 'Link Existing Users', 'daggerhart-openid-connect-generic' ),
359 | 'description' => __( 'If a WordPress account already exists with the same identity as a newly-authenticated user over OpenID Connect, login as that user instead of generating an error.', 'daggerhart-openid-connect-generic' ),
360 | 'type' => 'checkbox',
361 | 'disabled' => defined( 'OIDC_LINK_EXISTING_USERS' ),
362 | 'section' => 'user_settings',
363 | ),
364 | 'create_if_does_not_exist' => array(
365 | 'title' => __( 'Create user if does not exist', 'daggerhart-openid-connect-generic' ),
366 | 'description' => __( 'If the user identity is not linked to an existing WordPress user, it is created. If this setting is not enabled, and if the user authenticates with an account which is not linked to an existing WordPress user, then the authentication will fail.', 'daggerhart-openid-connect-generic' ),
367 | 'type' => 'checkbox',
368 | 'disabled' => defined( 'OIDC_CREATE_IF_DOES_NOT_EXIST' ),
369 | 'section' => 'user_settings',
370 | ),
371 | 'redirect_user_back' => array(
372 | 'title' => __( 'Redirect Back to Origin Page', 'daggerhart-openid-connect-generic' ),
373 | 'description' => __( 'After a successful OpenID Connect authentication, this will redirect the user back to the page on which they clicked the OpenID Connect login button. This will cause the login process to proceed in a traditional WordPress fashion. For example, users logging in through the default wp-login.php page would end up on the WordPress Dashboard and users logging in through the WooCommerce "My Account" page would end up on their account page.', 'daggerhart-openid-connect-generic' ),
374 | 'type' => 'checkbox',
375 | 'disabled' => defined( 'OIDC_REDIRECT_USER_BACK' ),
376 | 'section' => 'user_settings',
377 | ),
378 | 'redirect_on_logout' => array(
379 | 'title' => __( 'Redirect to the login screen when session is expired', 'daggerhart-openid-connect-generic' ),
380 | 'description' => __( 'When enabled, this will automatically redirect the user back to the WordPress login page if their access token has expired.', 'daggerhart-openid-connect-generic' ),
381 | 'type' => 'checkbox',
382 | 'disabled' => defined( 'OIDC_REDIRECT_ON_LOGOUT' ),
383 | 'section' => 'user_settings',
384 | ),
385 | 'enable_logging' => array(
386 | 'title' => __( 'Enable Logging', 'daggerhart-openid-connect-generic' ),
387 | 'description' => __( 'Very simple log messages for debugging purposes.', 'daggerhart-openid-connect-generic' ),
388 | 'type' => 'checkbox',
389 | 'disabled' => defined( 'OIDC_ENABLE_LOGGING' ),
390 | 'section' => 'log_settings',
391 | ),
392 | 'log_limit' => array(
393 | 'title' => __( 'Log Limit', 'daggerhart-openid-connect-generic' ),
394 | 'description' => __( 'Number of items to keep in the log. These logs are stored as an option in the database, so space is limited.', 'daggerhart-openid-connect-generic' ),
395 | 'type' => 'number',
396 | 'disabled' => defined( 'OIDC_LOG_LIMIT' ),
397 | 'section' => 'log_settings',
398 | ),
399 | );
400 |
401 | return apply_filters( 'openid-connect-generic-settings-fields', $fields );
402 | }
403 |
404 | /**
405 | * Sanitization callback for settings/option page.
406 | *
407 | * @param array $input The submitted settings values.
408 | *
409 | * @return array
410 | */
411 | public function sanitize_settings( $input ) {
412 | $options = array();
413 |
414 | // Loop through settings fields to control what we're saving.
415 | foreach ( $this->settings_fields as $key => $field ) {
416 | if ( isset( $input[ $key ] ) ) {
417 | $options[ $key ] = sanitize_text_field( trim( $input[ $key ] ) );
418 | } else {
419 | $options[ $key ] = '';
420 | }
421 | }
422 |
423 | return $options;
424 | }
425 |
426 | /**
427 | * Output the options/settings page.
428 | *
429 | * @return void
430 | */
431 | public function settings_page() {
432 | wp_enqueue_style( 'daggerhart-openid-connect-generic-admin', plugin_dir_url( __DIR__ ) . 'css/styles-admin.css', array(), OpenID_Connect_Generic::VERSION, 'all' );
433 |
434 | $redirect_uri = admin_url( 'admin-ajax.php?action=openid-connect-authorize' );
435 |
436 | if ( $this->settings->alternate_redirect_uri ) {
437 | $redirect_uri = site_url( '/openid-connect-authorize' );
438 | }
439 | ?>
440 |
441 |
442 |
443 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 | [openid_connect_generic_login_button]
465 |
466 |
467 |
468 | [openid_connect_generic_auth_url]
469 |
470 |
471 | settings->enable_logging ) { ?>
472 |
473 |
474 | logger->get_logs_table() ); ?>
475 |
476 |
477 |
478 |
479 |
491 |
496 | value="settings->{ $field['key'] } ); ?>">
497 | do_field_description( $field );
499 | }
500 |
501 | /**
502 | * Output a checkbox for a boolean setting.
503 | * - hidden field is default value so we don't have to check isset() on save.
504 | *
505 | * @param array $field The settings field definition array.
506 | *
507 | * @return void
508 | */
509 | public function do_checkbox( $field ) {
510 | $hidden_value = 0;
511 | if ( ! empty( $field['disabled'] ) && boolval( $field['disabled'] ) === true ) {
512 | $hidden_value = intval( $this->settings->{ $field['key'] } );
513 | }
514 | ?>
515 |
516 |
520 | value="1"
521 | settings->{ $field['key'] }, 1 ); ?>>
522 | do_field_description( $field );
524 | }
525 |
526 | /**
527 | * Output a select control.
528 | *
529 | * @param array $field The settings field definition array.
530 | *
531 | * @return void
532 | */
533 | public function do_select( $field ) {
534 | $current_value = isset( $this->settings->{ $field['key'] } ) ? $this->settings->{ $field['key'] } : '';
535 | ?>
536 |
545 | do_field_description( $field );
547 | }
548 |
549 | /**
550 | * Output the field description, and example if present.
551 | *
552 | * @param array $field The settings field definition array.
553 | *
554 | * @return void
555 | */
556 | public function do_field_description( $field ) {
557 | ?>
558 |
559 |
560 |
561 |
:
562 |
563 |
564 |
565 | \n"
14 | "Language-Team: LANGUAGE \n"
15 | "Language: en\n"
16 | "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17 | "X-Poedit-Country: United States\n"
18 | "X-Poedit-SourceCharset: UTF-8\n"
19 | "X-Poedit-KeywordsList: "
20 | "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
21 | "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
22 | "X-Poedit-Basepath: ../\n"
23 | "X-Poedit-SearchPath-0: .\n"
24 | "X-Poedit-Bookmarks: \n"
25 | "X-Textdomain-Support: yes\n"
26 | "X-Generator: grunt-wp-i18n 1.0.3\n"
27 |
28 | #: includes/openid-connect-generic-client-wrapper.php:293
29 | msgid "Session expired. Please login again."
30 | msgstr ""
31 |
32 | #: includes/openid-connect-generic-client-wrapper.php:540
33 | msgid "User identity is not linked to an existing WordPress user."
34 | msgstr ""
35 |
36 | #: includes/openid-connect-generic-client-wrapper.php:598
37 | msgid "Invalid user."
38 | msgstr ""
39 |
40 | #: includes/openid-connect-generic-client-wrapper.php:816
41 | msgid "No appropriate username found."
42 | msgstr ""
43 |
44 | #: includes/openid-connect-generic-client-wrapper.php:826
45 | #. translators: %1$s is the santitized version of the username from the IDP.
46 | msgid "Username %1$s could not be sanitized."
47 | msgstr ""
48 |
49 | #: includes/openid-connect-generic-client-wrapper.php:848
50 | #. translators: %1$s is the configured User Claim nickname key.
51 | msgid "No nickname found in user claim using key: %1$s."
52 | msgstr ""
53 |
54 | #: includes/openid-connect-generic-client-wrapper.php:945
55 | msgid "User claim incomplete."
56 | msgstr ""
57 |
58 | #: includes/openid-connect-generic-client-wrapper.php:1048
59 | msgid "Bad user claim result."
60 | msgstr ""
61 |
62 | #: includes/openid-connect-generic-client-wrapper.php:1114
63 | msgid "Can not authorize."
64 | msgstr ""
65 |
66 | #: includes/openid-connect-generic-client-wrapper.php:1143
67 | msgid "Failed user creation."
68 | msgstr ""
69 |
70 | #: includes/openid-connect-generic-client.php:176
71 | msgid "Missing state."
72 | msgstr ""
73 |
74 | #: includes/openid-connect-generic-client.php:180
75 | msgid "Invalid state."
76 | msgstr ""
77 |
78 | #: includes/openid-connect-generic-client.php:195
79 | msgid "Missing authentication code."
80 | msgstr ""
81 |
82 | #: includes/openid-connect-generic-client.php:240
83 | msgid "Request for authentication token failed."
84 | msgstr ""
85 |
86 | #: includes/openid-connect-generic-client.php:273
87 | msgid "Refresh token failed."
88 | msgstr ""
89 |
90 | #: includes/openid-connect-generic-client.php:288
91 | msgid "Missing token body."
92 | msgstr ""
93 |
94 | #: includes/openid-connect-generic-client.php:296
95 | msgid "Invalid token."
96 | msgstr ""
97 |
98 | #: includes/openid-connect-generic-client.php:349
99 | msgid "Request for userinfo failed."
100 | msgstr ""
101 |
102 | #: includes/openid-connect-generic-client.php:409
103 | msgid "Missing authentication state."
104 | msgstr ""
105 |
106 | #: includes/openid-connect-generic-client.php:446
107 | msgid "No identity token."
108 | msgstr ""
109 |
110 | #: includes/openid-connect-generic-client.php:453
111 | msgid "Missing identity token."
112 | msgstr ""
113 |
114 | #: includes/openid-connect-generic-client.php:480
115 | msgid "Bad ID token claim."
116 | msgstr ""
117 |
118 | #: includes/openid-connect-generic-client.php:485
119 | msgid "No subject identity."
120 | msgstr ""
121 |
122 | #: includes/openid-connect-generic-client.php:491
123 | msgid "No matching acr values."
124 | msgstr ""
125 |
126 | #: includes/openid-connect-generic-client.php:511
127 | msgid "Bad user claim."
128 | msgstr ""
129 |
130 | #: includes/openid-connect-generic-client.php:531
131 | msgid "Invalid user claim."
132 | msgstr ""
133 |
134 | #: includes/openid-connect-generic-client.php:536
135 | msgid "Error from the IDP."
136 | msgstr ""
137 |
138 | #: includes/openid-connect-generic-client.php:545
139 | msgid "Incorrect user claim."
140 | msgstr ""
141 |
142 | #: includes/openid-connect-generic-client.php:552
143 | msgid "Unauthorized access."
144 | msgstr ""
145 |
146 | #: includes/openid-connect-generic-login-form.php:122
147 | #. translators: %1$s is the error code from the IDP.
148 | msgid "ERROR (%1$s)"
149 | msgstr ""
150 |
151 | #: includes/openid-connect-generic-login-form.php:141
152 | msgid "Login with OpenID Connect"
153 | msgstr ""
154 |
155 | #: includes/openid-connect-generic-option-logger.php:228
156 | msgid "Details"
157 | msgstr ""
158 |
159 | #: includes/openid-connect-generic-option-logger.php:229
160 | msgid "Data"
161 | msgstr ""
162 |
163 | #: includes/openid-connect-generic-option-logger.php:236
164 | msgid "Date"
165 | msgstr ""
166 |
167 | #: includes/openid-connect-generic-option-logger.php:240
168 | msgid "Type"
169 | msgstr ""
170 |
171 | #: includes/openid-connect-generic-option-logger.php:244
172 | msgid "User"
173 | msgstr ""
174 |
175 | #: includes/openid-connect-generic-option-logger.php:248
176 | msgid "URI "
177 | msgstr ""
178 |
179 | #: includes/openid-connect-generic-option-logger.php:252
180 | msgid "Response Time (sec)"
181 | msgstr ""
182 |
183 | #: includes/openid-connect-generic-settings-page.php:108
184 | msgid "OpenID Connect - Generic Client"
185 | msgstr ""
186 |
187 | #: includes/openid-connect-generic-settings-page.php:109
188 | msgid "OpenID Connect Client"
189 | msgstr ""
190 |
191 | #: includes/openid-connect-generic-settings-page.php:133
192 | msgid "Client Settings"
193 | msgstr ""
194 |
195 | #: includes/openid-connect-generic-settings-page.php:140
196 | msgid "WordPress User Settings"
197 | msgstr ""
198 |
199 | #: includes/openid-connect-generic-settings-page.php:147
200 | msgid "Authorization Settings"
201 | msgstr ""
202 |
203 | #: includes/openid-connect-generic-settings-page.php:154
204 | msgid "Log Settings"
205 | msgstr ""
206 |
207 | #: includes/openid-connect-generic-settings-page.php:212
208 | msgid "Login Type"
209 | msgstr ""
210 |
211 | #: includes/openid-connect-generic-settings-page.php:213
212 | msgid "Select how the client (login form) should provide login options."
213 | msgstr ""
214 |
215 | #: includes/openid-connect-generic-settings-page.php:216
216 | msgid "OpenID Connect button on login form"
217 | msgstr ""
218 |
219 | #: includes/openid-connect-generic-settings-page.php:217
220 | msgid "Auto Login - SSO"
221 | msgstr ""
222 |
223 | #: includes/openid-connect-generic-settings-page.php:223
224 | msgid "Client ID"
225 | msgstr ""
226 |
227 | #: includes/openid-connect-generic-settings-page.php:224
228 | msgid ""
229 | "The ID this client will be recognized as when connecting the to Identity "
230 | "provider server."
231 | msgstr ""
232 |
233 | #: includes/openid-connect-generic-settings-page.php:231
234 | msgid "Client Secret Key"
235 | msgstr ""
236 |
237 | #: includes/openid-connect-generic-settings-page.php:232
238 | msgid ""
239 | "Arbitrary secret key the server expects from this client. Can be anything, "
240 | "but should be very unique."
241 | msgstr ""
242 |
243 | #: includes/openid-connect-generic-settings-page.php:238
244 | msgid "OpenID Scope"
245 | msgstr ""
246 |
247 | #: includes/openid-connect-generic-settings-page.php:239
248 | msgid "Space separated list of scopes this client should access."
249 | msgstr ""
250 |
251 | #: includes/openid-connect-generic-settings-page.php:246
252 | msgid "Login Endpoint URL"
253 | msgstr ""
254 |
255 | #: includes/openid-connect-generic-settings-page.php:247
256 | msgid "Identify provider authorization endpoint."
257 | msgstr ""
258 |
259 | #: includes/openid-connect-generic-settings-page.php:254
260 | msgid "Userinfo Endpoint URL"
261 | msgstr ""
262 |
263 | #: includes/openid-connect-generic-settings-page.php:255
264 | msgid "Identify provider User information endpoint."
265 | msgstr ""
266 |
267 | #: includes/openid-connect-generic-settings-page.php:262
268 | msgid "Token Validation Endpoint URL"
269 | msgstr ""
270 |
271 | #: includes/openid-connect-generic-settings-page.php:263
272 | msgid "Identify provider token endpoint."
273 | msgstr ""
274 |
275 | #: includes/openid-connect-generic-settings-page.php:270
276 | msgid "End Session Endpoint URL"
277 | msgstr ""
278 |
279 | #: includes/openid-connect-generic-settings-page.php:271
280 | msgid "Identify provider logout endpoint."
281 | msgstr ""
282 |
283 | #: includes/openid-connect-generic-settings-page.php:278
284 | msgid "ACR values"
285 | msgstr ""
286 |
287 | #: includes/openid-connect-generic-settings-page.php:279
288 | msgid "Use a specific defined authentication contract from the IDP - optional."
289 | msgstr ""
290 |
291 | #: includes/openid-connect-generic-settings-page.php:285
292 | msgid "Identity Key"
293 | msgstr ""
294 |
295 | #: includes/openid-connect-generic-settings-page.php:286
296 | msgid ""
297 | "Where in the user claim array to find the user's identification data. "
298 | "Possible standard values: preferred_username, name, or sub. If you're "
299 | "having trouble, use \"sub\"."
300 | msgstr ""
301 |
302 | #: includes/openid-connect-generic-settings-page.php:292
303 | msgid "Disable SSL Verify"
304 | msgstr ""
305 |
306 | #: includes/openid-connect-generic-settings-page.php:294
307 | #. translators: %1$s HTML tags for layout/styles, %2$s closing HTML tag for
308 | #. styles.
309 | msgid ""
310 | "Do not require SSL verification during authorization. The OAuth extension "
311 | "uses curl to make the request. By default CURL will generally verify the "
312 | "SSL certificate to see if its valid an issued by an accepted CA. This "
313 | "setting disabled that verification.%1$sNot recommended for production "
314 | "sites.%2$s"
315 | msgstr ""
316 |
317 | #: includes/openid-connect-generic-settings-page.php:299
318 | msgid "HTTP Request Timeout"
319 | msgstr ""
320 |
321 | #: includes/openid-connect-generic-settings-page.php:300
322 | msgid "Set the timeout for requests made to the IDP. Default value is 5."
323 | msgstr ""
324 |
325 | #: includes/openid-connect-generic-settings-page.php:306
326 | msgid "Enforce Privacy"
327 | msgstr ""
328 |
329 | #: includes/openid-connect-generic-settings-page.php:307
330 | msgid "Require users be logged in to see the site."
331 | msgstr ""
332 |
333 | #: includes/openid-connect-generic-settings-page.php:313
334 | msgid "Alternate Redirect URI"
335 | msgstr ""
336 |
337 | #: includes/openid-connect-generic-settings-page.php:314
338 | msgid ""
339 | "Provide an alternative redirect route. Useful if your server is causing "
340 | "issues with the default admin-ajax method. You must flush rewrite rules "
341 | "after changing this setting. This can be done by saving the Permalinks "
342 | "settings page."
343 | msgstr ""
344 |
345 | #: includes/openid-connect-generic-settings-page.php:319
346 | msgid "Nickname Key"
347 | msgstr ""
348 |
349 | #: includes/openid-connect-generic-settings-page.php:320
350 | msgid ""
351 | "Where in the user claim array to find the user's nickname. Possible "
352 | "standard values: preferred_username, name, or sub."
353 | msgstr ""
354 |
355 | #: includes/openid-connect-generic-settings-page.php:326
356 | msgid "Email Formatting"
357 | msgstr ""
358 |
359 | #: includes/openid-connect-generic-settings-page.php:327
360 | msgid ""
361 | "String from which the user's email address is built. Specify \"{email}\" as "
362 | "long as the user claim contains an email claim."
363 | msgstr ""
364 |
365 | #: includes/openid-connect-generic-settings-page.php:333
366 | msgid "Display Name Formatting"
367 | msgstr ""
368 |
369 | #: includes/openid-connect-generic-settings-page.php:334
370 | msgid "String from which the user's display name is built."
371 | msgstr ""
372 |
373 | #: includes/openid-connect-generic-settings-page.php:340
374 | msgid "Identify with User Name"
375 | msgstr ""
376 |
377 | #: includes/openid-connect-generic-settings-page.php:341
378 | msgid ""
379 | "If checked, the user's identity will be determined by the user name instead "
380 | "of the email address."
381 | msgstr ""
382 |
383 | #: includes/openid-connect-generic-settings-page.php:346
384 | msgid "State time limit"
385 | msgstr ""
386 |
387 | #: includes/openid-connect-generic-settings-page.php:347
388 | msgid "State valid time in seconds. Defaults to 180"
389 | msgstr ""
390 |
391 | #: includes/openid-connect-generic-settings-page.php:352
392 | msgid "Enable Refresh Token"
393 | msgstr ""
394 |
395 | #: includes/openid-connect-generic-settings-page.php:353
396 | msgid ""
397 | "If checked, support refresh tokens used to obtain access tokens from "
398 | "supported IDPs."
399 | msgstr ""
400 |
401 | #: includes/openid-connect-generic-settings-page.php:358
402 | msgid "Link Existing Users"
403 | msgstr ""
404 |
405 | #: includes/openid-connect-generic-settings-page.php:359
406 | msgid ""
407 | "If a WordPress account already exists with the same identity as a "
408 | "newly-authenticated user over OpenID Connect, login as that user instead of "
409 | "generating an error."
410 | msgstr ""
411 |
412 | #: includes/openid-connect-generic-settings-page.php:365
413 | msgid "Create user if does not exist"
414 | msgstr ""
415 |
416 | #: includes/openid-connect-generic-settings-page.php:366
417 | msgid ""
418 | "If the user identity is not linked to an existing WordPress user, it is "
419 | "created. If this setting is not enabled, and if the user authenticates with "
420 | "an account which is not linked to an existing WordPress user, then the "
421 | "authentication will fail."
422 | msgstr ""
423 |
424 | #: includes/openid-connect-generic-settings-page.php:372
425 | msgid "Redirect Back to Origin Page"
426 | msgstr ""
427 |
428 | #: includes/openid-connect-generic-settings-page.php:373
429 | msgid ""
430 | "After a successful OpenID Connect authentication, this will redirect the "
431 | "user back to the page on which they clicked the OpenID Connect login "
432 | "button. This will cause the login process to proceed in a traditional "
433 | "WordPress fashion. For example, users logging in through the default "
434 | "wp-login.php page would end up on the WordPress Dashboard and users logging "
435 | "in through the WooCommerce \"My Account\" page would end up on their "
436 | "account page."
437 | msgstr ""
438 |
439 | #: includes/openid-connect-generic-settings-page.php:379
440 | msgid "Redirect to the login screen when session is expired"
441 | msgstr ""
442 |
443 | #: includes/openid-connect-generic-settings-page.php:380
444 | msgid ""
445 | "When enabled, this will automatically redirect the user back to the "
446 | "WordPress login page if their access token has expired."
447 | msgstr ""
448 |
449 | #: includes/openid-connect-generic-settings-page.php:386
450 | msgid "Enable Logging"
451 | msgstr ""
452 |
453 | #: includes/openid-connect-generic-settings-page.php:387
454 | msgid "Very simple log messages for debugging purposes."
455 | msgstr ""
456 |
457 | #: includes/openid-connect-generic-settings-page.php:393
458 | msgid "Log Limit"
459 | msgstr ""
460 |
461 | #: includes/openid-connect-generic-settings-page.php:394
462 | msgid ""
463 | "Number of items to keep in the log. These logs are stored as an option in "
464 | "the database, so space is limited."
465 | msgstr ""
466 |
467 | #: includes/openid-connect-generic-settings-page.php:456
468 | msgid "Notes"
469 | msgstr ""
470 |
471 | #: includes/openid-connect-generic-settings-page.php:459
472 | msgid "Redirect URI"
473 | msgstr ""
474 |
475 | #: includes/openid-connect-generic-settings-page.php:463
476 | msgid "Login Button Shortcode"
477 | msgstr ""
478 |
479 | #: includes/openid-connect-generic-settings-page.php:467
480 | msgid "Authentication URL Shortcode"
481 | msgstr ""
482 |
483 | #: includes/openid-connect-generic-settings-page.php:472
484 | msgid "Logs"
485 | msgstr ""
486 |
487 | #: includes/openid-connect-generic-settings-page.php:561
488 | msgid "Example"
489 | msgstr ""
490 |
491 | #: includes/openid-connect-generic-settings-page.php:574
492 | msgid "Enter your OpenID Connect identity provider settings."
493 | msgstr ""
494 |
495 | #: includes/openid-connect-generic-settings-page.php:583
496 | msgid "Modify the interaction between OpenID Connect and WordPress users."
497 | msgstr ""
498 |
499 | #: includes/openid-connect-generic-settings-page.php:592
500 | msgid "Control the authorization mechanics of the site."
501 | msgstr ""
502 |
503 | #: includes/openid-connect-generic-settings-page.php:601
504 | msgid "Log information about login attempts through OpenID Connect Generic."
505 | msgstr ""
506 |
507 | #: openid-connect-generic.php:242
508 | msgid "Private site"
509 | msgstr ""
510 |
511 | #. Plugin Name of the plugin/theme
512 | msgid "OpenID Connect Generic"
513 | msgstr ""
514 |
515 | #. Plugin URI of the plugin/theme
516 | msgid "https://github.com/daggerhart/openid-connect-generic"
517 | msgstr ""
518 |
519 | #. Description of the plugin/theme
520 | msgid ""
521 | "Connect to an OpenID Connect identity provider using Authorization Code "
522 | "Flow."
523 | msgstr ""
524 |
525 | #. Author of the plugin/theme
526 | msgid "daggerhart"
527 | msgstr ""
528 |
529 | #. Author URI of the plugin/theme
530 | msgid "http://www.daggerhart.com"
531 | msgstr ""
--------------------------------------------------------------------------------
/openid-connect-generic.php:
--------------------------------------------------------------------------------
1 |
11 | * @copyright 2015-2023 daggerhart
12 | * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
13 | * @link https://github.com/daggerhart
14 | *
15 | * @wordpress-plugin
16 | * Plugin Name: OpenID Connect Generic
17 | * Plugin URI: https://github.com/daggerhart/openid-connect-generic
18 | * Description: Connect to an OpenID Connect identity provider using Authorization Code Flow.
19 | * Version: 3.10.0
20 | * Requires at least: 5.0
21 | * Requires PHP: 7.4
22 | * Author: daggerhart
23 | * Author URI: http://www.daggerhart.com
24 | * Text Domain: daggerhart-openid-connect-generic
25 | * Domain Path: /languages
26 | * License: GPL-2.0+
27 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
28 | * GitHub Plugin URI: https://github.com/daggerhart/openid-connect-generic
29 | */
30 |
31 | /*
32 | Notes
33 | Spec Doc - http://openid.net/specs/openid-connect-basic-1_0-32.html
34 |
35 | Filters
36 | - openid-connect-generic-alter-request - 3 args: request array, plugin settings, specific request op
37 | - openid-connect-generic-settings-fields - modify the fields provided on the settings page
38 | - openid-connect-generic-login-button-text - modify the login button text
39 | - openid-connect-generic-cookie-redirect-url - modify the redirect url stored as a cookie
40 | - openid-connect-generic-user-login-test - (bool) should the user be logged in based on their claim
41 | - openid-connect-generic-user-creation-test - (bool) should the user be created based on their claim
42 | - openid-connect-generic-auth-url - modify the authentication url
43 | - openid-connect-generic-alter-user-claim - modify the user_claim before a new user is created
44 | - openid-connect-generic-alter-user-data - modify user data before a new user is created
45 | - openid-connect-modify-token-response-before-validation - modify the token response before validation
46 | - openid-connect-modify-id-token-claim-before-validation - modify the token claim before validation
47 |
48 | Actions
49 | - openid-connect-generic-user-create - 2 args: fires when a new user is created by this plugin
50 | - openid-connect-generic-user-update - 1 arg: user ID, fires when user is updated by this plugin
51 | - openid-connect-generic-update-user-using-current-claim - 2 args: fires every time an existing user logs in and the claims are updated.
52 | - openid-connect-generic-redirect-user-back - 2 args: $redirect_url, $user. Allows interruption of redirect during login.
53 | - openid-connect-generic-user-logged-in - 1 arg: $user, fires when user is logged in.
54 | - openid-connect-generic-cron-daily - daily cron action
55 | - openid-connect-generic-state-not-found - the given state does not exist in the database, regardless of its expiration.
56 | - openid-connect-generic-state-expired - the given state exists, but expired before this login attempt.
57 |
58 | Callable actions
59 |
60 | User Meta
61 | - openid-connect-generic-subject-identity - the identity of the user provided by the idp
62 | - openid-connect-generic-last-id-token-claim - the user's most recent id_token claim, decoded
63 | - openid-connect-generic-last-user-claim - the user's most recent user_claim
64 | - openid-connect-generic-last-token-response - the user's most recent token response
65 |
66 | Options
67 | - openid_connect_generic_settings - plugin settings
68 | - openid-connect-generic-valid-states - locally stored generated states
69 | */
70 |
71 |
72 | /**
73 | * OpenID_Connect_Generic class.
74 | *
75 | * Defines plugin initialization functionality.
76 | *
77 | * @package OpenID_Connect_Generic
78 | * @category General
79 | */
80 | class OpenID_Connect_Generic {
81 |
82 | /**
83 | * Singleton instance of self
84 | *
85 | * @var OpenID_Connect_Generic
86 | */
87 | protected static $_instance = null;
88 |
89 | /**
90 | * Plugin version.
91 | *
92 | * @var string
93 | */
94 | const VERSION = '3.10.0';
95 |
96 | /**
97 | * Plugin settings.
98 | *
99 | * @var OpenID_Connect_Generic_Option_Settings
100 | */
101 | private $settings;
102 |
103 | /**
104 | * Plugin logs.
105 | *
106 | * @var OpenID_Connect_Generic_Option_Logger
107 | */
108 | private $logger;
109 |
110 | /**
111 | * Openid Connect Generic client
112 | *
113 | * @var OpenID_Connect_Generic_Client
114 | */
115 | private $client;
116 |
117 | /**
118 | * Client wrapper.
119 | *
120 | * @var OpenID_Connect_Generic_Client_Wrapper
121 | */
122 | public $client_wrapper;
123 |
124 | /**
125 | * Setup the plugin
126 | *
127 | * @param OpenID_Connect_Generic_Option_Settings $settings The settings object.
128 | * @param OpenID_Connect_Generic_Option_Logger $logger The loggin object.
129 | *
130 | * @return void
131 | */
132 | public function __construct( OpenID_Connect_Generic_Option_Settings $settings, OpenID_Connect_Generic_Option_Logger $logger ) {
133 | $this->settings = $settings;
134 | $this->logger = $logger;
135 | self::$_instance = $this;
136 | }
137 |
138 | // @codeCoverageIgnoreStart
139 |
140 | /**
141 | * WordPress Hook 'init'.
142 | *
143 | * @return void
144 | */
145 | public function init() {
146 |
147 | $this->client = new OpenID_Connect_Generic_Client(
148 | $this->settings->client_id,
149 | $this->settings->client_secret,
150 | $this->settings->scope,
151 | $this->settings->endpoint_login,
152 | $this->settings->endpoint_userinfo,
153 | $this->settings->endpoint_token,
154 | $this->get_redirect_uri( $this->settings ),
155 | $this->settings->acr_values,
156 | $this->get_state_time_limit( $this->settings ),
157 | $this->logger
158 | );
159 |
160 | $this->client_wrapper = OpenID_Connect_Generic_Client_Wrapper::register( $this->client, $this->settings, $this->logger );
161 | if ( defined( 'WP_CLI' ) && WP_CLI ) {
162 | return;
163 | }
164 |
165 | OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper );
166 |
167 | // Add a shortcode to get the auth URL.
168 | add_shortcode( 'openid_connect_generic_auth_url', array( $this->client_wrapper, 'get_authentication_url' ) );
169 |
170 | // Add actions to our scheduled cron jobs.
171 | add_action( 'openid-connect-generic-cron-daily', array( $this, 'cron_states_garbage_collection' ) );
172 |
173 | $this->upgrade();
174 |
175 | if ( is_admin() ) {
176 | OpenID_Connect_Generic_Settings_Page::register( $this->settings, $this->logger );
177 | }
178 | }
179 |
180 | /**
181 | * Get the default redirect URI.
182 | *
183 | * @param OpenID_Connect_Generic_Option_Settings $settings The settings object.
184 | *
185 | * @return string
186 | */
187 | public function get_redirect_uri( OpenID_Connect_Generic_Option_Settings $settings ) {
188 | $redirect_uri = admin_url( 'admin-ajax.php?action=openid-connect-authorize' );
189 |
190 | if ( $settings->alternate_redirect_uri ) {
191 | $redirect_uri = site_url( '/openid-connect-authorize' );
192 | }
193 |
194 | return $redirect_uri;
195 | }
196 |
197 | /**
198 | * Get the default state time limit.
199 | *
200 | * @param OpenID_Connect_Generic_Option_Settings $settings The settings object.
201 | *
202 | * @return int
203 | */
204 | public function get_state_time_limit( OpenID_Connect_Generic_Option_Settings $settings ) {
205 | $state_time_limit = 180;
206 | // State time limit cannot be zero.
207 | if ( $settings->state_time_limit ) {
208 | $state_time_limit = intval( $settings->state_time_limit );
209 | }
210 |
211 | return $state_time_limit;
212 | }
213 |
214 | /**
215 | * Check if privacy enforcement is enabled, and redirect users that aren't
216 | * logged in.
217 | *
218 | * @return void
219 | */
220 | public function enforce_privacy_redirect() {
221 | if ( $this->settings->enforce_privacy && ! is_user_logged_in() ) {
222 | // The client endpoint relies on the wp-admin ajax endpoint.
223 | if (
224 | ! defined( 'DOING_AJAX' ) ||
225 | ! boolval( constant( 'DOING_AJAX' ) ) ||
226 | ! isset( $_GET['action'] ) ||
227 | 'openid-connect-authorize' != $_GET['action'] ) {
228 | auth_redirect();
229 | }
230 | }
231 | }
232 |
233 | /**
234 | * Enforce privacy settings for rss feeds.
235 | *
236 | * @param string $content The content.
237 | *
238 | * @return mixed
239 | */
240 | public function enforce_privacy_feeds( $content ) {
241 | if ( $this->settings->enforce_privacy && ! is_user_logged_in() ) {
242 | $content = __( 'Private site', 'daggerhart-openid-connect-generic' );
243 | }
244 | return $content;
245 | }
246 |
247 | /**
248 | * Handle plugin upgrades
249 | *
250 | * @return void
251 | */
252 | public function upgrade() {
253 | $last_version = get_option( 'openid-connect-generic-plugin-version', 0 );
254 | $settings = $this->settings;
255 |
256 | if ( version_compare( self::VERSION, $last_version, '>' ) ) {
257 | // An upgrade is required.
258 | self::setup_cron_jobs();
259 |
260 | // @todo move this to another file for upgrade scripts
261 | if ( isset( $settings->ep_login ) ) {
262 | $settings->endpoint_login = $settings->ep_login;
263 | $settings->endpoint_token = $settings->ep_token;
264 | $settings->endpoint_userinfo = $settings->ep_userinfo;
265 |
266 | unset( $settings->ep_login, $settings->ep_token, $settings->ep_userinfo );
267 | $settings->save();
268 | }
269 |
270 | // Update the stored version number.
271 | update_option( 'openid-connect-generic-plugin-version', self::VERSION );
272 | }
273 | }
274 |
275 | /**
276 | * Expire state transients by attempting to access them and allowing the
277 | * transient's own mechanisms to delete any that have expired.
278 | *
279 | * @return void
280 | */
281 | public function cron_states_garbage_collection() {
282 | global $wpdb;
283 | $states = $wpdb->get_col( "SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_openid-connect-generic-state--%'" );
284 |
285 | if ( ! empty( $states ) ) {
286 | foreach ( $states as $state ) {
287 | $transient = str_replace( '_transient_', '', $state );
288 | get_transient( $transient );
289 | }
290 | }
291 | }
292 |
293 | /**
294 | * Ensure cron jobs are added to the schedule.
295 | *
296 | * @return void
297 | */
298 | public static function setup_cron_jobs() {
299 | if ( ! wp_next_scheduled( 'openid-connect-generic-cron-daily' ) ) {
300 | wp_schedule_event( time(), 'daily', 'openid-connect-generic-cron-daily' );
301 | }
302 | }
303 |
304 | /**
305 | * Activation hook.
306 | *
307 | * @return void
308 | */
309 | public static function activation() {
310 | self::setup_cron_jobs();
311 | }
312 |
313 | /**
314 | * Deactivation hook.
315 | *
316 | * @return void
317 | */
318 | public static function deactivation() {
319 | wp_clear_scheduled_hook( 'openid-connect-generic-cron-daily' );
320 | }
321 |
322 | /**
323 | * Simple autoloader.
324 | *
325 | * @param string $class The class name.
326 | *
327 | * @return void
328 | */
329 | public static function autoload( $class ) {
330 | $prefix = 'OpenID_Connect_Generic_';
331 |
332 | if ( stripos( $class, $prefix ) !== 0 ) {
333 | return;
334 | }
335 |
336 | $filename = $class . '.php';
337 |
338 | // Internal files are all lowercase and use dashes in filenames.
339 | if ( false === strpos( $filename, '\\' ) ) {
340 | $filename = strtolower( str_replace( '_', '-', $filename ) );
341 | } else {
342 | $filename = str_replace( '\\', DIRECTORY_SEPARATOR, $filename );
343 | }
344 |
345 | $filepath = __DIR__ . '/includes/' . $filename;
346 |
347 | if ( file_exists( $filepath ) ) {
348 | require_once $filepath;
349 | }
350 | }
351 |
352 | /**
353 | * Instantiate the plugin and hook into WordPress.
354 | *
355 | * @return void
356 | */
357 | public static function bootstrap() {
358 | /**
359 | * This is a documented valid call for spl_autoload_register.
360 | *
361 | * @link https://www.php.net/manual/en/function.spl-autoload-register.php#71155
362 | */
363 | spl_autoload_register( array( 'OpenID_Connect_Generic', 'autoload' ) );
364 |
365 | $settings = new OpenID_Connect_Generic_Option_Settings(
366 | // Default settings values.
367 | array(
368 | // OAuth client settings.
369 | 'login_type' => defined( 'OIDC_LOGIN_TYPE' ) ? OIDC_LOGIN_TYPE : 'button',
370 | 'client_id' => defined( 'OIDC_CLIENT_ID' ) ? OIDC_CLIENT_ID : '',
371 | 'client_secret' => defined( 'OIDC_CLIENT_SECRET' ) ? OIDC_CLIENT_SECRET : '',
372 | 'scope' => defined( 'OIDC_CLIENT_SCOPE' ) ? OIDC_CLIENT_SCOPE : '',
373 | 'endpoint_login' => defined( 'OIDC_ENDPOINT_LOGIN_URL' ) ? OIDC_ENDPOINT_LOGIN_URL : '',
374 | 'endpoint_userinfo' => defined( 'OIDC_ENDPOINT_USERINFO_URL' ) ? OIDC_ENDPOINT_USERINFO_URL : '',
375 | 'endpoint_token' => defined( 'OIDC_ENDPOINT_TOKEN_URL' ) ? OIDC_ENDPOINT_TOKEN_URL : '',
376 | 'endpoint_end_session' => defined( 'OIDC_ENDPOINT_LOGOUT_URL' ) ? OIDC_ENDPOINT_LOGOUT_URL : '',
377 | 'acr_values' => defined( 'OIDC_ACR_VALUES' ) ? OIDC_ACR_VALUES : '',
378 |
379 | // Non-standard settings.
380 | 'no_sslverify' => 0,
381 | 'http_request_timeout' => 5,
382 | 'identity_key' => 'preferred_username',
383 | 'nickname_key' => 'preferred_username',
384 | 'email_format' => '{email}',
385 | 'displayname_format' => '',
386 | 'identify_with_username' => false,
387 | 'state_time_limit' => 180,
388 |
389 | // Plugin settings.
390 | 'enforce_privacy' => defined( 'OIDC_ENFORCE_PRIVACY' ) ? intval( OIDC_ENFORCE_PRIVACY ) : 0,
391 | 'alternate_redirect_uri' => 0,
392 | 'token_refresh_enable' => 1,
393 | 'link_existing_users' => defined( 'OIDC_LINK_EXISTING_USERS' ) ? intval( OIDC_LINK_EXISTING_USERS ) : 0,
394 | 'create_if_does_not_exist' => defined( 'OIDC_CREATE_IF_DOES_NOT_EXIST' ) ? intval( OIDC_CREATE_IF_DOES_NOT_EXIST ) : 1,
395 | 'redirect_user_back' => defined( 'OIDC_REDIRECT_USER_BACK' ) ? intval( OIDC_REDIRECT_USER_BACK ) : 0,
396 | 'redirect_on_logout' => defined( 'OIDC_REDIRECT_ON_LOGOUT' ) ? intval( OIDC_REDIRECT_ON_LOGOUT ) : 1,
397 | 'enable_logging' => defined( 'OIDC_ENABLE_LOGGING' ) ? intval( OIDC_ENABLE_LOGGING ) : 0,
398 | 'log_limit' => defined( 'OIDC_LOG_LIMIT' ) ? intval( OIDC_LOG_LIMIT ) : 1000,
399 | )
400 | );
401 |
402 | $logger = new OpenID_Connect_Generic_Option_Logger( 'error', $settings->enable_logging, $settings->log_limit );
403 |
404 | $plugin = new self( $settings, $logger );
405 |
406 | add_action( 'init', array( $plugin, 'init' ) );
407 |
408 | // Privacy hooks.
409 | add_action( 'template_redirect', array( $plugin, 'enforce_privacy_redirect' ), 0 );
410 | add_filter( 'the_content_feed', array( $plugin, 'enforce_privacy_feeds' ), 999 );
411 | add_filter( 'the_excerpt_rss', array( $plugin, 'enforce_privacy_feeds' ), 999 );
412 | add_filter( 'comment_text_rss', array( $plugin, 'enforce_privacy_feeds' ), 999 );
413 | }
414 |
415 | /**
416 | * Create (if needed) and return a singleton of self.
417 | *
418 | * @return OpenID_Connect_Generic
419 | */
420 | public static function instance() {
421 | if ( null === self::$_instance ) {
422 | self::bootstrap();
423 | }
424 | return self::$_instance;
425 | }
426 | }
427 |
428 | OpenID_Connect_Generic::instance();
429 |
430 | register_activation_hook( __FILE__, array( 'OpenID_Connect_Generic', 'activation' ) );
431 | register_deactivation_hook( __FILE__, array( 'OpenID_Connect_Generic', 'deactivation' ) );
432 |
433 | // Provide publicly accessible plugin helper functions.
434 | require_once 'includes/functions.php';
435 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === OpenID Connect Generic Client ===
2 | Contributors: daggerhart, tnolte
3 | Donate link: http://www.daggerhart.com/
4 | Tags: security, login, oauth2, openidconnect, apps, authentication, autologin, sso
5 | Requires at least: 5.0
6 | Tested up to: 6.4.3
7 | Stable tag: 3.10.0
8 | Requires PHP: 7.4
9 | License: GPLv2 or later
10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html
11 |
12 | A simple client that provides SSO or opt-in authentication against a generic OAuth2 Server implementation.
13 |
14 | == Description ==
15 |
16 | This plugin allows to authenticate users against OpenID Connect OAuth2 API with Authorization Code Flow.
17 | Once installed, it can be configured to automatically authenticate users (SSO), or provide a "Login with OpenID Connect"
18 | button on the login form. After consent has been obtained, an existing user is automatically logged into WordPress, while
19 | new users are created in WordPress database.
20 |
21 | Much of the documentation can be found on the Settings > OpenID Connect Generic dashboard page.
22 |
23 | Please submit issues to the Github repo: https://github.com/daggerhart/openid-connect-generic
24 |
25 | == Installation ==
26 |
27 | 1. Upload to the `/wp-content/plugins/` directory
28 | 1. Activate the plugin
29 | 1. Visit Settings > OpenID Connect and configure to meet your needs
30 |
31 | == Frequently Asked Questions ==
32 |
33 | = What is the client's Redirect URI? =
34 |
35 | Most OAuth2 servers will require whitelisting a set of redirect URIs for security purposes. The Redirect URI provided
36 | by this client is like so: https://example.com/wp-admin/admin-ajax.php?action=openid-connect-authorize
37 |
38 | Replace `example.com` with your domain name and path to WordPress.
39 |
40 | = Can I change the client's Redirect URI? =
41 |
42 | Some OAuth2 servers do not allow for a client redirect URI to contain a query string. The default URI provided by
43 | this module leverages WordPress's `admin-ajax.php` endpoint as an easy way to provide a route that does not include
44 | HTML, but this will naturally involve a query string. Fortunately, this plugin provides a setting that will make use of
45 | an alternate redirect URI that does not include a query string.
46 |
47 | On the settings page for this plugin (Dashboard > Settings > OpenID Connect Generic) there is a checkbox for
48 | **Alternate Redirect URI**. When checked, the plugin will use the Redirect URI
49 | `https://example.com/openid-connect-authorize`.
50 |
51 |
52 | == Changelog ==
53 |
54 | = 3.10.0 =
55 |
56 | * Chore: @timnolte - Dependency updates.
57 | * Fix: @drzraf - Prevents running the auth url filter twice.
58 | * Fix: @timnolte - Updates the log cleanup handling to properly retain the configured number of log entries.
59 | * Fix: @timnolte - Updates the log display output to reflect the log retention policy.
60 | * Chore: @timnolte - Adds Unit Testing & New Local Development Environment.
61 | * Feature: @timnolte - Updates logging to allow for tracking processing time.
62 | * Feature: @menno-ll - Adds a remember me feature via a new filter.
63 | * Improvement: @menno-ll - Updates WP Cookie Expiration to Same as Session Length.
64 |
65 | = 3.9.1 =
66 |
67 | * Improvement: @timnolte - Refactors Composer setup and GitHub Actions.
68 | * Improvement: @timnolte - Bumps WordPress tested version compatibility.
69 |
70 | = 3.9.0 =
71 |
72 | * Feature: @matchaxnb - Added support for additional configuration constants.
73 | * Feature: @schanzen - Added support for agregated claims.
74 | * Fix: @rkcreation - Fixed access token not updating user metadata after login.
75 | * Fix: @danc1248 - Fixed user creation issue on Multisite Networks.
76 | * Feature: @RobjS - Added plugin singleton to support for more developer customization.
77 | * Feature: @jkouris - Added action hook to allow custom handling of session expiration.
78 | * Fix: @tommcc - Fixed admin CSS loading only on the plugin settings screen.
79 | * Feature: @rkcreation - Added method to refresh the user claim.
80 | * Feature: @Glowsome - Added acr_values support & verification checks that it when defined in options is honored.
81 | * Fix: @timnolte - Fixed regression which caused improper fallback on missing claims.
82 | * Fix: @slykar - Fixed missing query string handling in redirect URL.
83 | * Fix: @timnolte - Fixed issue with some user linking and user creation handling.
84 | * Improvement: @timnolte - Fixed plugin settings typos and screen formatting.
85 | * Security: @timnolte - Updated build tooling security vulnerabilities.
86 | * Improvement: @timnolte - Changed build tooling scripts.
87 |
88 | = 3.8.5 =
89 |
90 | * Fix: @timnolte - Fixed missing URL request validation before use & ensure proper current page URL is setup for Redirect Back.
91 | * Fix: @timnolte - Fixed Redirect URL Logic to Handle Sub-directory Installs.
92 | * Fix: @timnolte - Fixed issue with redirecting user back when the openid_connect_generic_auth_url shortcode is used.
93 |
94 | = 3.8.4 =
95 |
96 | * Fix: @timnolte - Fixed invalid State object access for redirection handling.
97 | * Improvement: @timnolte - Fixed local wp-env Docker development environment.
98 | * Improvement: @timnolte - Fixed Composer scripts for linting and static analysis.
99 |
100 | = 3.8.3 =
101 |
102 | * Fix: @timnolte - Fixed problems with proper redirect handling.
103 | * Improvement: @timnolte - Changes redirect handling to use State instead of cookies.
104 | * Improvement: @timnolte - Refactored additional code to meet coding standards.
105 |
106 | = 3.8.2 =
107 |
108 | * Fix: @timnolte - Fixed reported XSS vulnerability on WordPress login screen.
109 |
110 | = 3.8.1 =
111 |
112 | * Fix: @timnolte - Prevent SSO redirect on password protected posts.
113 | * Fix: @timnolte - CI/CD build issues.
114 | * Fix: @timnolte - Invalid redirect handling on logout for Auto Login setting.
115 |
116 | = 3.8.0 =
117 |
118 | * Feature: @timnolte - Ability to use 6 new constants for setting client configuration instead of storing in the DB.
119 | * Improvement: @timnolte - Plugin development & contribution updates.
120 | * Improvement: @timnolte - Refactored to meet WordPress coding standards.
121 | * Improvement: @timnolte - Refactored to provide localization.
122 |
123 | --------
124 |
125 | [See the previous changelogs here](https://github.com/oidc-wp/openid-connect-generic/blob/main/CHANGELOG.md#changelog)
126 |
--------------------------------------------------------------------------------
/wp-cli.yml:
--------------------------------------------------------------------------------
1 | path: /app/wp
2 |
--------------------------------------------------------------------------------