PluginProbe
Authorizer / 3.13.0
Authorizer v3.13.0
3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 2.9.6 All 126 releases
authorizer / src / authorizer / class-admin-page.php

class-admin-page.php in Authorizer 3.13.0, at src/authorizer/class-admin-page.php

2,110 lines 91.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Authorizer
4 *
5 * @license GPL-2.0+
6 * @link https://github.com/uhm-coe/authorizer
7 * @package authorizer
8 */
9
10 namespace Authorizer;
11
12 use Authorizer\Helper;
13 use Authorizer\Options;
14 use Authorizer\Options\Access_Lists;
15 use Authorizer\Options\Login_Access;
16 use Authorizer\Options\Public_Access;
17 use Authorizer\Options\External;
18 use Authorizer\Options\External\OAuth2;
19 use Authorizer\Options\External\Oidc;
20 use Authorizer\Options\External\Google;
21 use Authorizer\Options\External\Cas;
22 use Authorizer\Options\External\Ldap;
23 use Authorizer\Options\Advanced;
24
25 /**
26 * Contains functions for creating the Authorizer Settings page and adding it to
27 * the WordPress Dashboard menu.
28 */
29 class Admin_Page extends Singleton {
30
31 /**
32 * Add help documentation to the options page.
33 *
34 * Action: load-settings_page_authorizer > admin_head
35 */
36 public function admin_head() {
37 $screen = get_current_screen();
38
39 // Don't print any help items if not on the Authorizer Settings page.
40 if ( empty( $screen->id ) || ! in_array( $screen->id, array( 'toplevel_page_authorizer-network', 'toplevel_page_authorizer', 'settings_page_authorizer' ), true ) ) {
41 return;
42 }
43
44 // Add help tab for Access Lists Settings.
45 $help_auth_settings_access_lists_content = '
46 <p>' . __( "<strong>Pending Users</strong>: Pending users are users who have successfully logged in to the site, but who haven't yet been approved (or blocked) by you.", 'authorizer' ) . '</p>
47 <p>' . __( '<strong>Approved Users</strong>: Approved users have access to the site once they successfully log in.', 'authorizer' ) . '</p>
48 <p>' . __( '<strong>Blocked Users</strong>: Blocked users will receive an error message when they try to visit the site after authenticating.', 'authorizer' ) . '</p>
49 <p>' . __( 'Users in the <strong>Pending</strong> list appear automatically after a new user tries to log in from the configured external authentication service. You can add users to the <strong>Approved</strong> or <strong>Blocked</strong> lists by typing them in manually, or by clicking the <em>Approve</em> or <em>Block</em> buttons next to a user in the <strong>Pending</strong> list.', 'authorizer' ) . '</p>
50 ';
51 $screen->add_help_tab(
52 array(
53 'id' => 'help_auth_settings_access_lists_content',
54 'title' => __( 'Access Lists', 'authorizer' ),
55 'content' => wp_kses_post( $help_auth_settings_access_lists_content ),
56 )
57 );
58
59 // Add help tab for Login Access Settings.
60 $help_auth_settings_access_login_content = '
61 <p>' . __( "<strong>Who can log in to the site?</strong>: Choose the level of access restriction you'd like to use on your site here. You can leave the site open to anyone with a WordPress account or an account on an external service like Google, CAS, OIDC, or LDAP, or restrict it to WordPress users and only the external users that you specify via the <em>Access Lists</em>.", 'authorizer' ) . '</p>
62 <p>' . __( "<strong>Which role should receive email notifications about pending users?</strong>: If you've restricted access to <strong>approved users</strong>, you can determine which WordPress users will receive a notification email everytime a new external user successfully logs in and is added to the pending list. All users of the specified role will receive an email, and the external user will get a message (specified below) telling them their access is pending approval.", 'authorizer' ) . '</p>
63 <p>' . __( '<strong>What message should pending users see after attempting to log in?</strong>: Here you can specify the exact message a new external user will see once they try to log in to the site for the first time.', 'authorizer' ) . '</p>
64 ';
65 $screen->add_help_tab(
66 array(
67 'id' => 'help_auth_settings_access_login_content',
68 'title' => __( 'Login Access', 'authorizer' ),
69 'content' => wp_kses_post( $help_auth_settings_access_login_content ),
70 )
71 );
72
73 // Add help tab for Public Access Settings.
74 $help_auth_settings_access_public_content = '
75 <p>' . __( "<strong>Who can view the site?</strong>: You can restrict the site's visibility by only allowing logged in users to see pages. If you do so, you can customize the specifics about the site's privacy using the settings below.", 'authorizer' ) . '</p>
76 <p>' . __( "<strong>What pages (if any) should be available to everyone?</strong>: If you'd like to declare certain pages on your site as always public (such as the course syllabus, introduction, or calendar), specify those pages here. These pages will always be available no matter what access restrictions exist.", 'authorizer' ) . '</p>
77 <p>' . __( '<strong>What happens to people without access when they visit a <em>private</em> page?</strong>: Choose the response anonymous users receive when visiting the site. You can choose between immediately taking them to the <strong>login screen</strong>, or simply showing them a <strong>message</strong>.', 'authorizer' ) . '</p>
78 <p>' . __( '<strong>What happens to people without access when they visit a <em>public</em> page?</strong>: Choose the response anonymous users receive when visiting a page on the site marked as public. You can choose between showing them the page without any message, or showing them a the page with a message above the content.', 'authorizer' ) . '</p>
79 <p>' . __( '<strong>What message should people without access see?</strong>: If you chose to show new users a <strong>message</strong> above, type that message here.', 'authorizer' ) . '</p>
80 ';
81 $screen->add_help_tab(
82 array(
83 'id' => 'help_auth_settings_access_public_content',
84 'title' => __( 'Public Access', 'authorizer' ),
85 'content' => wp_kses_post( $help_auth_settings_access_public_content ),
86 )
87 );
88
89 // Add help tab for External Service (OAuth2, OIDC, Google, CAS, LDAP) Settings.
90 $help_auth_settings_external_content = '
91 <p>' . __( '<strong>Default role for new users</strong>: Specify which role new external users will get by default. Be sure to choose a role with limited permissions!', 'authorizer' ) . '</p>
92 <p>' . __( "<strong>Type of external service to authenticate against</strong>: Choose which authentication service type you will be using. You'll have to fill out different fields below depending on which service you choose.", 'authorizer' ) . '</p>
93 <p>' . __( '<strong>Enable OAuth2 Logins</strong>: Choose if you want to allow users to log in with one of the supported OAuth2 providers. You will need to enter your API Client ID and Secret to enable these logins.', 'authorizer' ) . '</p>
94 <p>' . __( '<strong>Enable OIDC Logins</strong>: Choose if you want to allow users to log in with an OIDC (OpenID Connect) provider. You will need to enter your API Client ID and Secret to enable these logins.', 'authorizer' ) . '</p>
95 <p>' . __( '<strong>Enable Google Logins</strong>: Choose if you want to allow users to log in with their Google Account credentials. You will need to enter your API Client ID and Secret to enable Google Logins.', 'authorizer' ) . '</p>
96 <p>' . __( '<strong>Enable CAS Logins</strong>: Choose if you want to allow users to log in with via CAS (Central Authentication Service). You will need to enter details about your CAS server (host, port, and path) to enable CAS Logins.', 'authorizer' ) . '</p>
97 <p>' . __( '<strong>Enable LDAP Logins</strong>: Choose if you want to allow users to log in with their LDAP (Lightweight Directory Access Protocol) credentials. You will need to enter details about your LDAP server (host, port, search base, uid attribute, directory user, directory user password, and whether to use STARTTLS) to enable LDAP Logins.', 'authorizer' ) . '</p>
98 ';
99 $screen->add_help_tab(
100 array(
101 'id' => 'help_auth_settings_external_content',
102 'title' => __( 'External Service', 'authorizer' ),
103 'content' => wp_kses_post( $help_auth_settings_external_content ),
104 )
105 );
106
107 // Add (indented) help tab for OAuth2 Settings.
108 $help_auth_settings_external_oauth2_content = '
109 <p><strong><em>' . __( 'If you enable OAuth2 logins:', 'authorizer' ) . '</em></strong></p>
110 <ul>
111 <li>' . __( '<strong>Client ID</strong>: You can generate this ID following the instructions for your specific provider.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_OAUTH2_CLIENT_ID', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_oauth2_client_id</code> filter. This will prevent it from being stored in plaintext in the WordPress database.", 'authorizer' ) . '</li>
112 <li>' . __( '<strong>Client Secret</strong>: You can generate this secret by following the instructions for your specific provider.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_OAUTH2_CLIENT_SECRET', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_oauth2_client_secret</code> filter. This will prevent it from being stored in plaintext in the WordPress database.", 'authorizer' ) . '</li>
113 <li>' . __( '<strong>Authorization URL</strong>: For the generic OAuth2 provider, you will need to specify the 3 endpoints required for the oauth2 authentication flow. This is the first: the endpoint first contacted to initiate the authentication.', 'authorizer' ) . '</li>
114 <li>' . __( '<strong>Access Token URL</strong>: For the generic OAuth2 provider, you will need to specify the 3 endpoints required for the oauth2 authentication flow. This is the second: the endpoint that is contacted after initiation to retrieve an access token for the user that just authenticated.', 'authorizer' ) . '</li>
115 <li>' . __( '<strong>Resource Owner URL</strong>: For the generic OAuth2 provider, you will need to specify the 3 endpoints required for the oauth2 authentication flow. This is the third: the endpoint that is contacted after successfully receiving an authentication token to retrieve details on the user that just authenticated.', 'authorizer' ) . '</li>
116 </ul>
117 ';
118 $screen->add_help_tab(
119 array(
120 'id' => 'help_auth_settings_external_oauth2_content',
121 'title' => '&nbsp; - ' . __( 'OAuth2', 'authorizer' ),
122 'content' => wp_kses_post( $help_auth_settings_external_oauth2_content ),
123 )
124 );
125
126 // Add (indented) help tab for OIDC Settings.
127 $help_auth_settings_external_oidc_content = '
128 <p><strong><em>' . __( 'If you enable OIDC logins:', 'authorizer' ) . '</em></strong></p>
129 <ul>
130 <li>' . __( '<strong>Issuer URL</strong>: Enter the base URL of your OIDC provider (e.g., https://login.microsoftonline.com/{tenant}/v2.0 or https://keycloak.example.com/realms/{realm}). The plugin will use discovery to find the authorization and token endpoints.', 'authorizer' ) . '</li>
131 <li>' . __( '<strong>Client ID</strong>: Enter the Client ID provided by your OIDC provider.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_OIDC_CLIENT_ID', '...' );</code>, or you may fetch it from an external service by hooking into the <code>authorizer_oidc_client_id</code> filter.", 'authorizer' ) . '</li>
132 <li>' . __( '<strong>Client Secret</strong>: Enter the Client Secret provided by your OIDC provider.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_OIDC_CLIENT_SECRET', '...' );</code>, or you may fetch it from an external service by hooking into the <code>authorizer_oidc_client_secret</code> filter.", 'authorizer' ) . '</li>
133 <li>' . __( '<strong>Scopes</strong>: Enter space-separated scopes to request (default: openid email profile).', 'authorizer' ) . '</li>
134 <li>' . __( '<strong>Prompt parameter</strong>: Optional parameter to control authentication prompt behavior (e.g., login, consent, select_account).', 'authorizer' ) . '</li>
135 <li>' . __( '<strong>Login hint parameter</strong>: Optional parameter to pre-fill the username (e.g., user@example.com).', 'authorizer' ) . '</li>
136 <li>' . __( '<strong>Max age parameter</strong>: Optional parameter specifying maximum authentication age in seconds.', 'authorizer' ) . '</li>
137 <li>' . __( '<strong>Attribute containing username</strong>: Enter the claim name that contains the username (default: preferred_username). If not found, the plugin will fallback to the sub claim.', 'authorizer' ) . '</li>
138 <li>' . __( '<strong>Attribute containing email</strong>: Enter the claim name that contains the email address (default: email).', 'authorizer' ) . '</li>
139 <li>' . __( "<strong>Attribute containing first name</strong>: Enter the claim name that has the user's first name (default: given_name).", 'authorizer' ) . '</li>
140 <li>' . __( "<strong>Attribute containing last name</strong>: Enter the claim name that has the user's last name (default: family_name).", 'authorizer' ) . '</li>
141 <li>' . __( '<strong>Name attribute update</strong>: Select whether the first and last names retrieved from OIDC should overwrite any value the user has entered in the first and last name fields in their WordPress profile.', 'authorizer' ) . '</li>
142 <li>' . __( '<strong>Require verified email</strong>: If checked, users must have a verified email address (email_verified claim) to log in.', 'authorizer' ) . '</li>
143 <li>' . __( '<strong>OIDC Hosted Domain</strong>: Restrict OIDC logins to specific email domains (one per line). Leave blank to allow all valid sign-ins.', 'authorizer' ) . '</li>
144 </ul>
145 ';
146 $screen->add_help_tab(
147 array(
148 'id' => 'help_auth_settings_external_oidc_content',
149 'title' => '&nbsp; - ' . __( 'OIDC', 'authorizer' ),
150 'content' => wp_kses_post( $help_auth_settings_external_oidc_content ),
151 )
152 );
153
154 // Add (indented) help tab for Google Settings.
155 $help_auth_settings_external_google_content = '
156 <p><strong><em>' . __( 'If you enable Google logins:', 'authorizer' ) . '</em></strong></p>
157 <ul>
158 <li>' . __( "<strong>Google Client ID</strong>: You can generate this ID by creating a new Project in the <a href='https://cloud.google.com/console'>Google Developers Console</a>. A Client ID typically looks something like this: 1234567890123-kdjr85yt6vjr6d8g7dhr8g7d6durjf7g.apps.googleusercontent.com", 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_GOOGLE_CLIENT_ID', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_google_client_id</code> filter. This will prevent it from being stored in plaintext in the WordPress database.", 'authorizer' ) . '</li>
159 <li>' . __( "<strong>Google Client Secret</strong>: You can generate this secret by creating a new Project in the <a href='https://cloud.google.com/console'>Google Developers Console</a>. A Client Secret typically looks something like this: sDNgX5_pr_5bly-frKmvp8jT", 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_GOOGLE_CLIENT_SECRET', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_google_client_secret</code> filter. This will prevent it from being stored in plaintext in the WordPress database.", 'authorizer' ) . '</li>
160 </ul>
161 ';
162 $screen->add_help_tab(
163 array(
164 'id' => 'help_auth_settings_external_google_content',
165 'title' => '&nbsp; - ' . __( 'Google', 'authorizer' ),
166 'content' => wp_kses_post( $help_auth_settings_external_google_content ),
167 )
168 );
169
170 // Add (indented) help tab for CAS Settings.
171 $help_auth_settings_external_cas_content = '
172 <p><strong><em>' . __( 'If you enable CAS logins:', 'authorizer' ) . '</em></strong></p>
173 <ul>
174 <li>' . __( '<strong>CAS server hostname</strong>: Enter the hostname of the CAS server you authenticate against (e.g., authn.example.edu).', 'authorizer' ) . '</li>
175 <li>' . __( '<strong>CAS server port</strong>: Enter the port on the CAS server to connect to (e.g., 443).', 'authorizer' ) . '</li>
176 <li>' . __( '<strong>CAS server path/context</strong>: Enter the path to the login endpoint on the CAS server (e.g., /cas).', 'authorizer' ) . '</li>
177 <li>' . __( '<strong>CAS server method</strong>: Select the method to use when setting the CAS config (e.g.,"client" or "proxy")', 'authorizer' ) . '</li>
178 <li>' . __( "<strong>CAS attribute containing first name</strong>: Enter the CAS attribute that has the user's first name. When this user first logs in, their WordPress account will have their first name retrieved from CAS and added to their WordPress profile.", 'authorizer' ) . '</li>
179 <li>' . __( "<strong>CAS attribute containing last name</strong>: Enter the CAS attribute that has the user's last name. When this user first logs in, their WordPress account will have their last name retrieved from CAS and added to their WordPress profile.", 'authorizer' ) . '</li>
180 <li>' . __( '<strong>CAS attribute update</strong>: Select whether the first and last names retrieved from CAS should overwrite any value the user has entered in the first and last name fields in their WordPress profile. If this is not set, this only happens the first time they log in.', 'authorizer' ) . '</li>
181 </ul>
182 ';
183 $screen->add_help_tab(
184 array(
185 'id' => 'help_auth_settings_external_cas_content',
186 'title' => '&nbsp; - ' . __( 'CAS', 'authorizer' ),
187 'content' => wp_kses_post( $help_auth_settings_external_cas_content ),
188 )
189 );
190
191 // Add (indented) help tab for LDAP Settings.
192 $help_auth_settings_external_ldap_content = '
193 <p><strong><em>' . __( 'If you enable LDAP logins:', 'authorizer' ) . '</em></strong></p>
194 <ul>
195 <li>' . __( '<strong>LDAP Host</strong>: Enter the URL of the LDAP server you authenticate against.', 'authorizer' ) . '</li>
196 <li>' . __( '<strong>LDAP Port</strong>: Enter the port number that the LDAP server listens on.', 'authorizer' ) . '</li>
197 <li>' . __( '<strong>LDAP Search Base</strong>: Enter the LDAP string that represents the search base, e.g., ou=people,dc=example,dc=edu', 'authorizer' ) . '</li>
198 <li>' . __( '<strong>LDAP Search Filter</strong>: Enter the optional LDAP string that represents the search filter, e.g., (memberOf=cn=wp_users,ou=people,dc=example,dc=edu)', 'authorizer' ) . '</li>
199 <li>' . __( '<strong>LDAP attribute containing username</strong>: Enter the name of the LDAP attribute that contains the usernames used by those attempting to log in. The plugin will search on this attribute to find the cn to bind against for login attempts.', 'authorizer' ) . '</li>
200 <li>' . __( '<strong>LDAP Directory User</strong>: Enter the name of the LDAP user that has permissions to browse the directory.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_LDAP_USER', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_ldap_user</code> filter. This will prevent it from being stored in plaintext in the WordPress database.", 'authorizer' ) . '</li>
201 <li>' . __( '<strong>LDAP Directory User Password</strong>: Enter the password for the LDAP user that has permission to browse the directory.', 'authorizer' ) . '<br>' . __( "Note: for increased security, you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_LDAP_PASSWORD', '...' );</code>, or you may fetch it from an external service like AWS Secrets Manager by hooking into the <code>authorizer_ldap_password</code> filter. This will prevent it from being stored in the WordPress database.", 'authorizer' ) . '</li>
202 <li>' . __( '<strong>Use STARTTLS</strong>: Select whether unencrypted communication with the LDAP server should be upgraded to a TLS-secured connection using STARTTLS.', 'authorizer' ) . '</li>
203 <li>' . __( "<strong>Custom lost password URL</strong>: The WordPress login page contains a link to recover a lost password. If you have external users who shouldn't change the password on their WordPress account, point them to the appropriate location to change the password on their external authentication service here.", 'authorizer' ) . '</li>
204 <li>' . __( "<strong>LDAP attribute containing first name</strong>: Enter the LDAP attribute that has the user's first name. When this user first logs in, their WordPress account will have their first name retrieved from LDAP and added to their WordPress profile.", 'authorizer' ) . '</li>
205 <li>' . __( "<strong>LDAP attribute containing last name</strong>: Enter the LDAP attribute that has the user's last name. When this user first logs in, their WordPress account will have their last name retrieved from LDAP and added to their WordPress profile.", 'authorizer' ) . '</li>
206 <li>' . __( '<strong>LDAP attribute update</strong>: Select whether the first and last names retrieved from LDAP should overwrite any value the user has entered in the first and last name fields in their WordPress profile. If this is not set, this only happens the first time they log in.', 'authorizer' ) . '</li>
207 </ul>
208 ';
209 $screen->add_help_tab(
210 array(
211 'id' => 'help_auth_settings_external_ldap_content',
212 'title' => '&nbsp; - ' . __( 'LDAP', 'authorizer' ),
213 'content' => wp_kses_post( $help_auth_settings_external_ldap_content ),
214 )
215 );
216
217 // Add help tab for Advanced Settings.
218 $help_auth_settings_advanced_content = '
219 <p>' . __( '<strong>Limit invalid login attempts</strong>: Choose how soon (and for how long) to restrict access to individuals (or bots) making repeated invalid login attempts. You may set a shorter delay first, and then a longer delay after repeated invalid attempts; you may also set how much time must pass before the delays will be reset to normal.', 'authorizer' ) . '</p>
220 <p>' . __( '<strong>Hide WordPress Logins</strong>: If you want to hide the WordPress username and password fields and the Log In button on the wp-login screen, enable this option. Note: You can always access the WordPress logins by adding external=wordpress to the wp-login URL, like so:', 'authorizer' ) . ' <a href="' . wp_login_url() . '?external=wordpress" target="_blank">' . wp_login_url() . '?external=wordpress</a>.</p>
221 <p>' . __( '<strong>Disable WordPress Logins</strong>: If you want to prevent users from logging in with their WordPress passwords and instead only allow logins from external services, enable this option. Note: enabling this will also hide WordPress logins unless the LDAP external service is enabled.', 'authorizer' ) . '</p>
222 <p>' . __( "<strong>Custom WordPress login branding</strong>: If you'd like to use custom branding on the WordPress login page, select that here. You will need to use the <code>authorizer_add_branding_option</code> filter in your theme to add it. You can see an example theme that implements this filter in the plugin directory under sample-theme-add-branding.", 'authorizer' ) . ' ' . __( "Note: you can leave this field blank and instead define this value either in wp-config.php via <code>define( 'AUTHORIZER_ADVANCED_BRANDING', '...' );</code>, or you may set it in the <code>authorizer_advanced_branding</code> filter.", 'authorizer' ) . '</p>
223 ';
224 $screen->add_help_tab(
225 array(
226 'id' => 'help_auth_settings_advanced_content',
227 'title' => __( 'Advanced', 'authorizer' ),
228 'content' => wp_kses_post( $help_auth_settings_advanced_content ),
229 )
230 );
231 }
232
233
234 /**
235 * Add notices to the top of the options page.
236 *
237 * Action: load-settings_page_authorizer > admin_notices
238 *
239 * Description: Check for invalid settings combinations and show a warning message, e.g.:
240 * if ( cas url inaccessible ) : ?>
241 * <div class='updated settings-error'><p>Can't reach CAS server.</p></div>
242 * <?php endif;
243 */
244 public function admin_notices() {
245 // Grab plugin settings.
246 $options = Options::get_instance();
247 $auth_settings = $options->get_all( Helper::SINGLE_CONTEXT, 'allow override' );
248
249 if ( '1' === $auth_settings['cas'] ) :
250 // Check if provided CAS URL is accessible.
251 $protocol = in_array( strval( $auth_settings['cas_port'] ), array( '80', '8080' ), true ) ? 'http' : 'https';
252 $cas_url = $protocol . '://' . $auth_settings['cas_host'] . ':' . $auth_settings['cas_port'] . $auth_settings['cas_path'];
253 $legacy_cas_url = trailingslashit( $cas_url ) . 'login'; // Check the specific CAS login endpoint (old; some servers don't register a ./login endpoint, use serviceValidate instead).
254 $cas_url = trailingslashit( $cas_url ) . 'serviceValidate'; // Check the specific CAS login endpoint.
255 if ( ! Helper::url_is_accessible( $cas_url ) && ! Helper::url_is_accessible( $legacy_cas_url ) ) :
256 $authorizer_options_url = 'settings' === $auth_settings['advanced_admin_menu'] ? admin_url( 'options-general.php?page=authorizer' ) : admin_url( '?page=authorizer' );
257 ?>
258 <div class='notice notice-warning is-dismissible'>
259 <p><?php esc_html_e( "Can't reach CAS server. Please provide", 'authorizer' ); ?> <a href='<?php echo esc_attr( $authorizer_options_url ); ?>&tab=external'><?php esc_html_e( 'accurate CAS settings', 'authorizer' ); ?></a> <?php esc_html_e( 'if you intend to use it.', 'authorizer' ); ?></p>
260 </div>
261 <?php
262 endif;
263 endif;
264 }
265
266
267 /**
268 * Show custom admin notice.
269 *
270 * Note: currently unused, but if anywhere we:
271 * add_option( 'auth_settings_advanced_admin_notice, 'Your message.' );
272 * It will display and then delete that message on the admin dashboard.
273 *
274 * Filter: admin_notices
275 * filter: network_admin_notices
276 */
277 public function show_advanced_admin_notice() {
278 $notice = get_option( 'auth_settings_advanced_admin_notice' );
279 delete_option( 'auth_settings_advanced_admin_notice' );
280
281 if ( $notice && strlen( $notice ) > 0 ) {
282 ?>
283 <div class="error">
284 <p><?php echo wp_kses( $notice, Helper::$allowed_html ); ?></p>
285 </div>
286 <?php
287 }
288 }
289
290
291 /**
292 * Add a link to this plugin's settings page from the WordPress Plugins page.
293 * Called from "plugin_action_links" filter in __construct() above.
294 *
295 * Filter: plugin_action_links_authorizer.php
296 *
297 * @param array $links Admin sidebar links.
298 * @return array Admin sidebar links with Authorizer added.
299 */
300 public function plugin_settings_link( $links ) {
301 $options = Options::get_instance();
302 $admin_menu = $options->get( 'advanced_admin_menu' );
303 $settings_url = 'settings' === $admin_menu ? admin_url( 'options-general.php?page=authorizer' ) : admin_url( 'admin.php?page=authorizer' );
304 array_unshift( $links, '<a href="' . $settings_url . '">' . __( 'Settings', 'authorizer' ) . '</a>' );
305 return $links;
306 }
307
308
309 /**
310 * Add a link to this plugin's network settings page from the WordPress Plugins page.
311 * Called from "network_admin_plugin_action_links" filter in __construct() above.
312 *
313 * Filter: network_admin_plugin_action_links_authorizer.php
314 *
315 * @param array $links Network admin sidebar links.
316 * @return array Network admin sidebar links with Authorizer added.
317 */
318 public function network_admin_plugin_settings_link( $links ) {
319 $settings_link = '<a href="admin.php?page=authorizer">' . __( 'Network Settings', 'authorizer' ) . '</a>';
320 array_unshift( $links, $settings_link );
321 return $links;
322 }
323
324
325 /**
326 * Create sections and options.
327 *
328 * Action: admin_init
329 */
330 public function page_init() {
331 /**
332 * Create one setting that holds all the options (array).
333 *
334 * @see http://codex.wordpress.org/Function_Reference/register_setting
335 * @see http://codex.wordpress.org/Function_Reference/add_settings_section
336 * @see http://codex.wordpress.org/Function_Reference/add_settings_field
337 */
338 register_setting(
339 'auth_settings_group',
340 'auth_settings',
341 array( Options::get_instance(), 'sanitize_options' )
342 );
343
344 add_settings_section(
345 'auth_settings_tabs',
346 '',
347 array( Options::get_instance(), 'print_section_info_tabs' ),
348 'authorizer'
349 );
350
351 // Create Access Lists section.
352 add_settings_section(
353 'auth_settings_lists',
354 '',
355 array( Access_Lists::get_instance(), 'print_section_info_access_lists' ),
356 'authorizer'
357 );
358
359 // Create Login Access section.
360 add_settings_section(
361 'auth_settings_access_login',
362 '',
363 array( Login_Access::get_instance(), 'print_section_info_access_login' ),
364 'authorizer'
365 );
366 add_settings_field(
367 'auth_settings_access_who_can_login',
368 __( 'Who can log into the site?', 'authorizer' ),
369 array( Login_Access::get_instance(), 'print_radio_auth_access_who_can_login' ),
370 'authorizer',
371 'auth_settings_access_login'
372 );
373 add_settings_field(
374 'auth_settings_access_users_receive_pending_emails',
375 __( 'Which users should receive email notifications about pending users?', 'authorizer' ),
376 array( Login_Access::get_instance(), 'print_select_auth_access_users_receive_pending_emails' ),
377 'authorizer',
378 'auth_settings_access_login'
379 );
380 add_settings_field(
381 'auth_settings_access_role_receive_pending_emails',
382 __( 'Which role should receive email notifications about pending users?', 'authorizer' ),
383 array( Login_Access::get_instance(), 'print_select_auth_access_role_receive_pending_emails' ),
384 'authorizer',
385 'auth_settings_access_login'
386 );
387 add_settings_field(
388 'auth_settings_access_pending_redirect_to_message',
389 __( 'What message should pending users see after attempting to log in?', 'authorizer' ),
390 array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_pending_redirect_to_message' ),
391 'authorizer',
392 'auth_settings_access_login'
393 );
394 add_settings_field(
395 'auth_settings_access_blocked_redirect_to_message',
396 __( 'What message should blocked users see after attempting to log in?', 'authorizer' ),
397 array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_blocked_redirect_to_message' ),
398 'authorizer',
399 'auth_settings_access_login'
400 );
401 add_settings_field(
402 'auth_settings_access_should_email_approved_users',
403 __( 'Send welcome email to new approved users?', 'authorizer' ),
404 array( Login_Access::get_instance(), 'print_checkbox_auth_access_should_email_approved_users' ),
405 'authorizer',
406 'auth_settings_access_login'
407 );
408 add_settings_field(
409 'auth_settings_access_email_approved_users_subject',
410 __( 'Welcome email subject', 'authorizer' ),
411 array( Login_Access::get_instance(), 'print_text_auth_access_email_approved_users_subject' ),
412 'authorizer',
413 'auth_settings_access_login'
414 );
415 add_settings_field(
416 'auth_settings_access_email_approved_users_body',
417 __( 'Welcome email body', 'authorizer' ),
418 array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_email_approved_users_body' ),
419 'authorizer',
420 'auth_settings_access_login'
421 );
422
423 // Create Public Access section.
424 add_settings_section(
425 'auth_settings_access_public',
426 '',
427 array( Public_Access::get_instance(), 'print_section_info_access_public' ),
428 'authorizer'
429 );
430 add_settings_field(
431 'auth_settings_access_who_can_view',
432 __( 'Who can view the site?', 'authorizer' ),
433 array( Public_Access::get_instance(), 'print_radio_auth_access_who_can_view' ),
434 'authorizer',
435 'auth_settings_access_public'
436 );
437 add_settings_field(
438 'auth_settings_access_public_pages',
439 __( 'What pages (if any) should be available to everyone?', 'authorizer' ),
440 array( Public_Access::get_instance(), 'print_multiselect_auth_access_public_pages' ),
441 'authorizer',
442 'auth_settings_access_public'
443 );
444 add_settings_field(
445 'auth_settings_access_redirect',
446 __( 'What happens to people without access when they visit a private page?', 'authorizer' ),
447 array( Public_Access::get_instance(), 'print_radio_auth_access_redirect' ),
448 'authorizer',
449 'auth_settings_access_public'
450 );
451 add_settings_field(
452 'auth_settings_access_public_warning',
453 __( 'What happens to people without access when they visit a public page?', 'authorizer' ),
454 array( Public_Access::get_instance(), 'print_radio_auth_access_public_warning' ),
455 'authorizer',
456 'auth_settings_access_public'
457 );
458 add_settings_field(
459 'auth_settings_access_redirect_to_message',
460 __( 'What message should people without access see?', 'authorizer' ),
461 array( Public_Access::get_instance(), 'print_wysiwyg_auth_access_redirect_to_message' ),
462 'authorizer',
463 'auth_settings_access_public'
464 );
465
466 // Create External Service Settings section.
467 add_settings_section(
468 'auth_settings_external',
469 '',
470 array( External::get_instance(), 'print_section_info_external' ),
471 'authorizer'
472 );
473 add_settings_field(
474 'auth_settings_access_default_role',
475 __( 'Default role for new users', 'authorizer' ),
476 array( External::get_instance(), 'print_select_auth_access_default_role' ),
477 'authorizer',
478 'auth_settings_external'
479 );
480 add_settings_field(
481 'auth_settings_external_oauth2',
482 __( 'OAuth2 Logins', 'authorizer' ),
483 array( OAuth2::get_instance(), 'print_checkbox_auth_external_oauth2' ),
484 'authorizer',
485 'auth_settings_external'
486 );
487 add_settings_field(
488 'auth_settings_external_oidc',
489 __( 'OIDC Logins', 'authorizer' ),
490 array( Oidc::get_instance(), 'print_checkbox_auth_external_oidc' ),
491 'authorizer',
492 'auth_settings_external'
493 );
494 add_settings_field(
495 'auth_settings_external_google',
496 __( 'Google Logins', 'authorizer' ),
497 array( Google::get_instance(), 'print_checkbox_auth_external_google' ),
498 'authorizer',
499 'auth_settings_external'
500 );
501 add_settings_field(
502 'auth_settings_external_cas',
503 __( 'CAS Logins', 'authorizer' ),
504 array( Cas::get_instance(), 'print_checkbox_auth_external_cas' ),
505 'authorizer',
506 'auth_settings_external'
507 );
508 add_settings_field(
509 'auth_settings_external_ldap',
510 __( 'LDAP Logins', 'authorizer' ),
511 array( Ldap::get_instance(), 'print_checkbox_auth_external_ldap' ),
512 'authorizer',
513 'auth_settings_external'
514 );
515
516 // Create External Service (OAuth2) Settings section.
517 add_settings_section(
518 'auth_settings_external_oauth2',
519 '',
520 array( External::get_instance(), 'print_section_info_external_oauth2' ),
521 'authorizer'
522 );
523 add_settings_field(
524 'auth_settings_oauth2_num_servers',
525 __( 'OAuth2 server(s)', 'authorizer' ),
526 array( OAuth2::get_instance(), 'print_number_oauth2_num_servers' ),
527 'authorizer',
528 'auth_settings_external_oauth2'
529 );
530 $oauth2_num_servers = max( 1, min( 20, intval( Options::get_instance()->get( 'oauth2_num_servers', Helper::SINGLE_CONTEXT, 'allow override' ) ) ) );
531 add_settings_field(
532 'auth_settings_oauth2_auto_login',
533 __( 'OAuth2 automatic login', 'authorizer' ),
534 array( OAuth2::get_instance(), 'print_select_oauth2_auto_login' ),
535 'authorizer',
536 'auth_settings_external_oauth2',
537 array(
538 'oauth2_num_servers' => $oauth2_num_servers,
539 )
540 );
541 foreach ( range( 1, $oauth2_num_servers ) as $oauth2_num_server ) {
542 $suffix = 1 === $oauth2_num_server ? '' : '_' . $oauth2_num_server;
543 $prefix = $oauth2_num_server . '. ';
544
545 add_settings_field(
546 'auth_settings_oauth2_provider' . $suffix,
547 $prefix . __( 'Provider', 'authorizer' ),
548 array( OAuth2::get_instance(), 'print_select_oauth2_provider' ),
549 'authorizer',
550 'auth_settings_external_oauth2',
551 array(
552 'class' => 'border-top',
553 'oauth2_num_server' => $oauth2_num_server,
554 )
555 );
556
557 add_settings_field(
558 'auth_settings_oauth2_custom_label' . $suffix,
559 $prefix . __( 'Custom label', 'authorizer' ),
560 array( OAuth2::get_instance(), 'print_text_oauth2_custom_label' ),
561 'authorizer',
562 'auth_settings_external_oauth2',
563 array(
564 'oauth2_num_server' => $oauth2_num_server,
565 )
566 );
567 add_settings_field(
568 'auth_settings_oauth2_clientid' . $suffix,
569 $prefix . __( 'Client ID', 'authorizer' ),
570 array( OAuth2::get_instance(), 'print_text_oauth2_clientid' ),
571 'authorizer',
572 'auth_settings_external_oauth2',
573 array(
574 'oauth2_num_server' => $oauth2_num_server,
575 )
576 );
577 add_settings_field(
578 'auth_settings_oauth2_clientsecret' . $suffix,
579 $prefix . __( 'Client Secret', 'authorizer' ),
580 array( OAuth2::get_instance(), 'print_text_oauth2_clientsecret' ),
581 'authorizer',
582 'auth_settings_external_oauth2',
583 array(
584 'oauth2_num_server' => $oauth2_num_server,
585 )
586 );
587 add_settings_field(
588 'auth_settings_oauth2_hosteddomain' . $suffix,
589 $prefix . __( 'OAuth2 Hosted Domain', 'authorizer' ),
590 array( OAuth2::get_instance(), 'print_text_oauth2_hosteddomain' ),
591 'authorizer',
592 'auth_settings_external_oauth2',
593 array(
594 'oauth2_num_server' => $oauth2_num_server,
595 )
596 );
597 add_settings_field(
598 'auth_settings_oauth2_tenant_id' . $suffix,
599 $prefix . __( 'Tenant ID', 'authorizer' ),
600 array( OAuth2::get_instance(), 'print_text_oauth2_tenant_id' ),
601 'authorizer',
602 'auth_settings_external_oauth2',
603 array(
604 'oauth2_num_server' => $oauth2_num_server,
605 )
606 );
607 add_settings_field(
608 'auth_settings_oauth2_url_authorize' . $suffix,
609 $prefix . __( 'Authorization URL', 'authorizer' ),
610 array( OAuth2::get_instance(), 'print_text_oauth2_url_authorize' ),
611 'authorizer',
612 'auth_settings_external_oauth2',
613 array(
614 'oauth2_num_server' => $oauth2_num_server,
615 )
616 );
617 add_settings_field(
618 'auth_settings_oauth2_url_token' . $suffix,
619 $prefix . __( 'Access Token URL', 'authorizer' ),
620 array( OAuth2::get_instance(), 'print_text_oauth2_url_token' ),
621 'authorizer',
622 'auth_settings_external_oauth2',
623 array(
624 'oauth2_num_server' => $oauth2_num_server,
625 )
626 );
627 add_settings_field(
628 'auth_settings_oauth2_url_resource' . $suffix,
629 $prefix . __( 'Resource Owner URL', 'authorizer' ),
630 array( OAuth2::get_instance(), 'print_text_oauth2_url_resource' ),
631 'authorizer',
632 'auth_settings_external_oauth2',
633 array(
634 'oauth2_num_server' => $oauth2_num_server,
635 )
636 );
637 add_settings_field(
638 'auth_settings_oauth2_attr_username' . $suffix,
639 $prefix . __( 'Attribute containing username', 'authorizer' ),
640 array( OAuth2::get_instance(), 'print_text_oauth2_attr_username' ),
641 'authorizer',
642 'auth_settings_external_oauth2',
643 array(
644 'oauth2_num_server' => $oauth2_num_server,
645 )
646 );
647 add_settings_field(
648 'auth_settings_oauth2_attr_email' . $suffix,
649 $prefix . __( 'Attribute containing email', 'authorizer' ),
650 array( OAuth2::get_instance(), 'print_text_oauth2_attr_email' ),
651 'authorizer',
652 'auth_settings_external_oauth2',
653 array(
654 'oauth2_num_server' => $oauth2_num_server,
655 )
656 );
657 add_settings_field(
658 'auth_settings_oauth2_attr_first_name' . $suffix,
659 $prefix . __( 'Attribute containing first name', 'authorizer' ),
660 array( OAuth2::get_instance(), 'print_text_oauth2_attr_first_name' ),
661 'authorizer',
662 'auth_settings_external_oauth2',
663 array(
664 'oauth2_num_server' => $oauth2_num_server,
665 )
666 );
667 add_settings_field(
668 'auth_settings_oauth2_attr_last_name' . $suffix,
669 $prefix . __( 'Attribute containing last name', 'authorizer' ),
670 array( OAuth2::get_instance(), 'print_text_oauth2_attr_last_name' ),
671 'authorizer',
672 'auth_settings_external_oauth2',
673 array(
674 'oauth2_num_server' => $oauth2_num_server,
675 )
676 );
677 add_settings_field(
678 'auth_settings_oauth2_attr_update_on_login' . $suffix,
679 $prefix . __( 'Name attribute update', 'authorizer' ),
680 array( Oauth2::get_instance(), 'print_select_oauth2_attr_update_on_login' ),
681 'authorizer',
682 'auth_settings_external_oauth2',
683 array(
684 'oauth2_num_server' => $oauth2_num_server,
685 )
686 );
687 }
688
689 // Create External Service (OIDC) Settings section.
690 add_settings_section(
691 'auth_settings_external_oidc',
692 '',
693 array( External::get_instance(), 'print_section_info_external_oidc' ),
694 'authorizer'
695 );
696 add_settings_field(
697 'auth_settings_oidc_num_servers',
698 __( 'OIDC server(s)', 'authorizer' ),
699 array( Oidc::get_instance(), 'print_number_oidc_num_servers' ),
700 'authorizer',
701 'auth_settings_external_oidc'
702 );
703 $oidc_num_servers = max( 1, min( 20, intval( Options::get_instance()->get( 'oidc_num_servers', Helper::SINGLE_CONTEXT, 'allow override' ) ) ) );
704 add_settings_field(
705 'auth_settings_oidc_auto_login',
706 __( 'OIDC automatic login', 'authorizer' ),
707 array( Oidc::get_instance(), 'print_select_oidc_auto_login' ),
708 'authorizer',
709 'auth_settings_external_oidc',
710 array(
711 'oidc_num_servers' => $oidc_num_servers,
712 )
713 );
714 foreach ( range( 1, $oidc_num_servers ) as $oidc_num_server ) {
715 $suffix = 1 === $oidc_num_server ? '' : '_' . $oidc_num_server;
716 $prefix = $oidc_num_server . '. ';
717
718 add_settings_field(
719 'auth_settings_oidc_custom_label' . $suffix,
720 $prefix . __( 'Custom label', 'authorizer' ),
721 array( Oidc::get_instance(), 'print_text_oidc_custom_label' ),
722 'authorizer',
723 'auth_settings_external_oidc',
724 array(
725 'class' => 'border-top',
726 'oidc_num_server' => $oidc_num_server,
727 )
728 );
729 add_settings_field(
730 'auth_settings_oidc_issuer' . $suffix,
731 $prefix . __( 'Issuer URL', 'authorizer' ),
732 array( Oidc::get_instance(), 'print_text_oidc_issuer' ),
733 'authorizer',
734 'auth_settings_external_oidc',
735 array(
736 'oidc_num_server' => $oidc_num_server,
737 )
738 );
739 add_settings_field(
740 'auth_settings_oidc_client_id' . $suffix,
741 $prefix . __( 'Client ID', 'authorizer' ),
742 array( Oidc::get_instance(), 'print_text_oidc_client_id' ),
743 'authorizer',
744 'auth_settings_external_oidc',
745 array(
746 'oidc_num_server' => $oidc_num_server,
747 )
748 );
749 add_settings_field(
750 'auth_settings_oidc_client_secret' . $suffix,
751 $prefix . __( 'Client Secret', 'authorizer' ),
752 array( Oidc::get_instance(), 'print_text_oidc_client_secret' ),
753 'authorizer',
754 'auth_settings_external_oidc',
755 array(
756 'oidc_num_server' => $oidc_num_server,
757 )
758 );
759 add_settings_field(
760 'auth_settings_oidc_scopes' . $suffix,
761 $prefix . __( 'Scopes', 'authorizer' ),
762 array( Oidc::get_instance(), 'print_text_oidc_scopes' ),
763 'authorizer',
764 'auth_settings_external_oidc',
765 array(
766 'oidc_num_server' => $oidc_num_server,
767 )
768 );
769 add_settings_field(
770 'auth_settings_oidc_prompt' . $suffix,
771 $prefix . __( 'Prompt parameter', 'authorizer' ),
772 array( Oidc::get_instance(), 'print_text_oidc_prompt' ),
773 'authorizer',
774 'auth_settings_external_oidc',
775 array(
776 'oidc_num_server' => $oidc_num_server,
777 )
778 );
779 add_settings_field(
780 'auth_settings_oidc_login_hint' . $suffix,
781 $prefix . __( 'Login hint parameter', 'authorizer' ),
782 array( Oidc::get_instance(), 'print_text_oidc_login_hint' ),
783 'authorizer',
784 'auth_settings_external_oidc',
785 array(
786 'oidc_num_server' => $oidc_num_server,
787 )
788 );
789 add_settings_field(
790 'auth_settings_oidc_max_age' . $suffix,
791 $prefix . __( 'Max age parameter', 'authorizer' ),
792 array( Oidc::get_instance(), 'print_text_oidc_max_age' ),
793 'authorizer',
794 'auth_settings_external_oidc',
795 array(
796 'oidc_num_server' => $oidc_num_server,
797 )
798 );
799 add_settings_field(
800 'auth_settings_oidc_attr_username' . $suffix,
801 $prefix . __( 'Attribute containing username', 'authorizer' ),
802 array( Oidc::get_instance(), 'print_text_oidc_attr_username' ),
803 'authorizer',
804 'auth_settings_external_oidc',
805 array(
806 'oidc_num_server' => $oidc_num_server,
807 )
808 );
809 add_settings_field(
810 'auth_settings_oidc_attr_email' . $suffix,
811 $prefix . __( 'Attribute containing email', 'authorizer' ),
812 array( Oidc::get_instance(), 'print_text_oidc_attr_email' ),
813 'authorizer',
814 'auth_settings_external_oidc',
815 array(
816 'oidc_num_server' => $oidc_num_server,
817 )
818 );
819 add_settings_field(
820 'auth_settings_oidc_attr_first_name' . $suffix,
821 $prefix . __( 'Attribute containing first name', 'authorizer' ),
822 array( Oidc::get_instance(), 'print_text_oidc_attr_first_name' ),
823 'authorizer',
824 'auth_settings_external_oidc',
825 array(
826 'oidc_num_server' => $oidc_num_server,
827 )
828 );
829 add_settings_field(
830 'auth_settings_oidc_attr_last_name' . $suffix,
831 $prefix . __( 'Attribute containing last name', 'authorizer' ),
832 array( Oidc::get_instance(), 'print_text_oidc_attr_last_name' ),
833 'authorizer',
834 'auth_settings_external_oidc',
835 array(
836 'oidc_num_server' => $oidc_num_server,
837 )
838 );
839 add_settings_field(
840 'auth_settings_oidc_attr_update_on_login' . $suffix,
841 $prefix . __( 'Name attribute update', 'authorizer' ),
842 array( Oidc::get_instance(), 'print_select_oidc_attr_update_on_login' ),
843 'authorizer',
844 'auth_settings_external_oidc',
845 array(
846 'oidc_num_server' => $oidc_num_server,
847 )
848 );
849 add_settings_field(
850 'auth_settings_oidc_require_verified_email' . $suffix,
851 $prefix . __( 'Require verified email', 'authorizer' ),
852 array( Oidc::get_instance(), 'print_checkbox_oidc_require_verified_email' ),
853 'authorizer',
854 'auth_settings_external_oidc',
855 array(
856 'oidc_num_server' => $oidc_num_server,
857 )
858 );
859 add_settings_field(
860 'auth_settings_oidc_link_on_username' . $suffix,
861 $prefix . __( 'OIDC users linked by username', 'authorizer' ),
862 array( Oidc::get_instance(), 'print_checkbox_oidc_link_on_username' ),
863 'authorizer',
864 'auth_settings_external_oidc',
865 array(
866 'oidc_num_server' => $oidc_num_server,
867 )
868 );
869 add_settings_field(
870 'auth_settings_oidc_hosteddomain' . $suffix,
871 $prefix . __( 'OIDC Hosted Domain', 'authorizer' ),
872 array( Oidc::get_instance(), 'print_text_oidc_hosteddomain' ),
873 'authorizer',
874 'auth_settings_external_oidc',
875 array(
876 'oidc_num_server' => $oidc_num_server,
877 )
878 );
879 }
880
881 // Create External Service (Google) Settings section.
882 add_settings_section(
883 'auth_settings_external_google',
884 '',
885 array( External::get_instance(), 'print_section_info_external_google' ),
886 'authorizer'
887 );
888 add_settings_field(
889 'auth_settings_google_clientid',
890 __( 'Google Client ID', 'authorizer' ),
891 array( Google::get_instance(), 'print_text_google_clientid' ),
892 'authorizer',
893 'auth_settings_external_google'
894 );
895 add_settings_field(
896 'auth_settings_google_clientsecret',
897 __( 'Google Client Secret', 'authorizer' ),
898 array( Google::get_instance(), 'print_text_google_clientsecret' ),
899 'authorizer',
900 'auth_settings_external_google'
901 );
902 add_settings_field(
903 'auth_settings_google_hosteddomain',
904 __( 'Google Hosted Domain', 'authorizer' ),
905 array( Google::get_instance(), 'print_text_google_hosteddomain' ),
906 'authorizer',
907 'auth_settings_external_google'
908 );
909
910 // Create External Service (CAS) Settings section.
911 add_settings_section(
912 'auth_settings_external_cas',
913 '',
914 array( External::get_instance(), 'print_section_info_external_cas' ),
915 'authorizer'
916 );
917 add_settings_field(
918 'auth_settings_cas_num_servers',
919 __( 'CAS server(s)', 'authorizer' ),
920 array( Cas::get_instance(), 'print_number_cas_num_servers' ),
921 'authorizer',
922 'auth_settings_external_cas'
923 );
924 $cas_num_servers = max( 1, min( 10, intval( Options::get_instance()->get( 'cas_num_servers', Helper::SINGLE_CONTEXT, 'allow override' ) ) ) );
925 add_settings_field(
926 'auth_settings_cas_auto_login',
927 __( 'CAS automatic login', 'authorizer' ),
928 array( Cas::get_instance(), 'print_select_cas_auto_login' ),
929 'authorizer',
930 'auth_settings_external_cas',
931 array(
932 'cas_num_servers' => $cas_num_servers,
933 )
934 );
935 foreach ( range( 1, $cas_num_servers ) as $cas_num_server ) {
936 $suffix = 1 === $cas_num_server ? '' : '_' . $cas_num_server;
937 $prefix = $cas_num_server . '. ';
938
939 add_settings_field(
940 'auth_settings_cas_custom_label' . $suffix,
941 $prefix . __( 'CAS custom label', 'authorizer' ),
942 array( Cas::get_instance(), 'print_text_cas_custom_label' ),
943 'authorizer',
944 'auth_settings_external_cas',
945 array(
946 'class' => 'border-top',
947 'cas_num_server' => $cas_num_server,
948 )
949 );
950 add_settings_field(
951 'auth_settings_cas_host' . $suffix,
952 $prefix . __( 'CAS server hostname', 'authorizer' ),
953 array( Cas::get_instance(), 'print_text_cas_host' ),
954 'authorizer',
955 'auth_settings_external_cas',
956 array(
957 'cas_num_server' => $cas_num_server,
958 )
959 );
960 add_settings_field(
961 'auth_settings_cas_port' . $suffix,
962 $prefix . __( 'CAS server port', 'authorizer' ),
963 array( Cas::get_instance(), 'print_text_cas_port' ),
964 'authorizer',
965 'auth_settings_external_cas',
966 array(
967 'cas_num_server' => $cas_num_server,
968 )
969 );
970 add_settings_field(
971 'auth_settings_cas_path' . $suffix,
972 $prefix . __( 'CAS server path/context', 'authorizer' ),
973 array( Cas::get_instance(), 'print_text_cas_path' ),
974 'authorizer',
975 'auth_settings_external_cas',
976 array(
977 'cas_num_server' => $cas_num_server,
978 )
979 );
980 add_settings_field(
981 'auth_settings_cas_method' . $suffix,
982 $prefix . __( 'CAS server method', 'authorizer' ),
983 array( Cas::get_instance(), 'print_select_cas_method' ),
984 'authorizer',
985 'auth_settings_external_cas',
986 array(
987 'cas_num_server' => $cas_num_server,
988 )
989 );
990 add_settings_field(
991 'auth_settings_cas_version' . $suffix,
992 $prefix . __( 'CAS server protocol', 'authorizer' ),
993 array( Cas::get_instance(), 'print_select_cas_version' ),
994 'authorizer',
995 'auth_settings_external_cas',
996 array(
997 'cas_num_server' => $cas_num_server,
998 )
999 );
1000 add_settings_field(
1001 'auth_settings_cas_attr_email' . $suffix,
1002 $prefix . __( 'CAS attribute containing email address', 'authorizer' ),
1003 array( Cas::get_instance(), 'print_text_cas_attr_email' ),
1004 'authorizer',
1005 'auth_settings_external_cas',
1006 array(
1007 'cas_num_server' => $cas_num_server,
1008 )
1009 );
1010 add_settings_field(
1011 'auth_settings_cas_attr_first_name' . $suffix,
1012 $prefix . __( 'CAS attribute containing first name', 'authorizer' ),
1013 array( Cas::get_instance(), 'print_text_cas_attr_first_name' ),
1014 'authorizer',
1015 'auth_settings_external_cas',
1016 array(
1017 'cas_num_server' => $cas_num_server,
1018 )
1019 );
1020 add_settings_field(
1021 'auth_settings_cas_attr_last_name' . $suffix,
1022 $prefix . __( 'CAS attribute containing last name', 'authorizer' ),
1023 array( Cas::get_instance(), 'print_text_cas_attr_last_name' ),
1024 'authorizer',
1025 'auth_settings_external_cas',
1026 array(
1027 'cas_num_server' => $cas_num_server,
1028 )
1029 );
1030 add_settings_field(
1031 'auth_settings_cas_attr_update_on_login' . $suffix,
1032 $prefix . __( 'CAS attribute update', 'authorizer' ),
1033 array( Cas::get_instance(), 'print_select_cas_attr_update_on_login' ),
1034 'authorizer',
1035 'auth_settings_external_cas',
1036 array(
1037 'cas_num_server' => $cas_num_server,
1038 )
1039 );
1040 add_settings_field(
1041 'auth_settings_cas_link_on_username' . $suffix,
1042 $prefix . __( 'CAS users linked by username', 'authorizer' ),
1043 array( Cas::get_instance(), 'print_checkbox_cas_link_on_username' ),
1044 'authorizer',
1045 'auth_settings_external_cas',
1046 array(
1047 'cas_num_server' => $cas_num_server,
1048 )
1049 );
1050 }
1051
1052 // Create External Service (LDAP) Settings section.
1053 add_settings_section(
1054 'auth_settings_external_ldap',
1055 '',
1056 array( External::get_instance(), 'print_section_info_external_ldap' ),
1057 'authorizer'
1058 );
1059 add_settings_field(
1060 'auth_settings_ldap_host',
1061 __( 'LDAP Host', 'authorizer' ),
1062 array( Ldap::get_instance(), 'print_text_ldap_host' ),
1063 'authorizer',
1064 'auth_settings_external_ldap'
1065 );
1066 add_settings_field(
1067 'auth_settings_ldap_port',
1068 __( 'LDAP Port', 'authorizer' ),
1069 array( Ldap::get_instance(), 'print_text_ldap_port' ),
1070 'authorizer',
1071 'auth_settings_external_ldap'
1072 );
1073 add_settings_field(
1074 'auth_settings_ldap_tls',
1075 __( 'Use STARTTLS', 'authorizer' ),
1076 array( Ldap::get_instance(), 'print_checkbox_ldap_tls' ),
1077 'authorizer',
1078 'auth_settings_external_ldap'
1079 );
1080 add_settings_field(
1081 'auth_settings_ldap_search_base',
1082 __( 'LDAP Search Base', 'authorizer' ),
1083 array( Ldap::get_instance(), 'print_text_ldap_search_base' ),
1084 'authorizer',
1085 'auth_settings_external_ldap'
1086 );
1087 add_settings_field(
1088 'auth_settings_ldap_search_filter',
1089 __( 'LDAP Search Filter', 'authorizer' ),
1090 array( Ldap::get_instance(), 'print_text_ldap_search_filter' ),
1091 'authorizer',
1092 'auth_settings_external_ldap'
1093 );
1094 add_settings_field(
1095 'auth_settings_ldap_uid',
1096 __( 'LDAP attribute containing username', 'authorizer' ),
1097 array( Ldap::get_instance(), 'print_text_ldap_uid' ),
1098 'authorizer',
1099 'auth_settings_external_ldap'
1100 );
1101 add_settings_field(
1102 'auth_settings_ldap_attr_email',
1103 __( 'LDAP attribute containing email address', 'authorizer' ),
1104 array( Ldap::get_instance(), 'print_text_ldap_attr_email' ),
1105 'authorizer',
1106 'auth_settings_external_ldap'
1107 );
1108 add_settings_field(
1109 'auth_settings_ldap_user',
1110 __( 'LDAP Directory User', 'authorizer' ),
1111 array( Ldap::get_instance(), 'print_text_ldap_user' ),
1112 'authorizer',
1113 'auth_settings_external_ldap'
1114 );
1115 add_settings_field(
1116 'auth_settings_ldap_password',
1117 __( 'LDAP Directory User Password', 'authorizer' ),
1118 array( Ldap::get_instance(), 'print_password_ldap_password' ),
1119 'authorizer',
1120 'auth_settings_external_ldap'
1121 );
1122 add_settings_field(
1123 'auth_settings_ldap_lostpassword_url',
1124 __( 'Custom lost password URL', 'authorizer' ),
1125 array( Ldap::get_instance(), 'print_text_ldap_lostpassword_url' ),
1126 'authorizer',
1127 'auth_settings_external_ldap'
1128 );
1129 add_settings_field(
1130 'auth_settings_ldap_attr_first_name',
1131 __( 'LDAP attribute containing first name', 'authorizer' ),
1132 array( Ldap::get_instance(), 'print_text_ldap_attr_first_name' ),
1133 'authorizer',
1134 'auth_settings_external_ldap'
1135 );
1136 add_settings_field(
1137 'auth_settings_ldap_attr_last_name',
1138 __( 'LDAP attribute containing last name', 'authorizer' ),
1139 array( Ldap::get_instance(), 'print_text_ldap_attr_last_name' ),
1140 'authorizer',
1141 'auth_settings_external_ldap'
1142 );
1143 add_settings_field(
1144 'auth_settings_ldap_attr_update_on_login',
1145 __( 'LDAP attribute update', 'authorizer' ),
1146 array( Ldap::get_instance(), 'print_select_ldap_attr_update_on_login' ),
1147 'authorizer',
1148 'auth_settings_external_ldap'
1149 );
1150 add_settings_field(
1151 'auth_settings_ldap_test_user',
1152 __( 'LDAP test connection', 'authorizer' ),
1153 array( Ldap::get_instance(), 'print_text_button_ldap_test_user' ),
1154 'authorizer',
1155 'auth_settings_external_ldap'
1156 );
1157
1158 // Create Advanced Settings section.
1159 add_settings_section(
1160 'auth_settings_advanced',
1161 '',
1162 array( Advanced::get_instance(), 'print_section_info_advanced' ),
1163 'authorizer'
1164 );
1165 add_settings_field(
1166 'auth_settings_advanced_lockouts',
1167 __( 'Limit invalid login attempts', 'authorizer' ),
1168 array( Advanced::get_instance(), 'print_text_auth_advanced_lockouts' ),
1169 'authorizer',
1170 'auth_settings_advanced'
1171 );
1172 add_settings_field(
1173 'auth_settings_advanced_hide_wp_login',
1174 __( 'Hide WordPress Login', 'authorizer' ),
1175 array( Advanced::get_instance(), 'print_checkbox_auth_advanced_hide_wp_login' ),
1176 'authorizer',
1177 'auth_settings_advanced'
1178 );
1179 add_settings_field(
1180 'auth_settings_advanced_disable_wp_login',
1181 __( 'Disable WordPress Logins', 'authorizer' ),
1182 array( Advanced::get_instance(), 'print_checkbox_auth_advanced_disable_wp_login' ),
1183 'authorizer',
1184 'auth_settings_advanced'
1185 );
1186 add_settings_field(
1187 'auth_settings_advanced_disable_wp_login_bypass_usernames',
1188 __( 'Bypass Usernames', 'authorizer' ),
1189 array( Advanced::get_instance(), 'print_text_advanced_disable_wp_login_bypass_usernames' ),
1190 'authorizer',
1191 'auth_settings_advanced'
1192 );
1193 add_settings_field(
1194 'auth_settings_advanced_branding',
1195 __( 'Custom WordPress login branding', 'authorizer' ),
1196 array( Advanced::get_instance(), 'print_radio_auth_advanced_branding' ),
1197 'authorizer',
1198 'auth_settings_advanced'
1199 );
1200 add_settings_field(
1201 'auth_settings_advanced_admin_menu',
1202 __( 'Authorizer admin menu item location', 'authorizer' ),
1203 array( Advanced::get_instance(), 'print_radio_auth_advanced_admin_menu' ),
1204 'authorizer',
1205 'auth_settings_advanced'
1206 );
1207 add_settings_field(
1208 'auth_settings_advanced_usermeta',
1209 __( 'Show custom usermeta in user list', 'authorizer' ),
1210 array( Advanced::get_instance(), 'print_select_auth_advanced_usermeta' ),
1211 'authorizer',
1212 'auth_settings_advanced'
1213 );
1214 add_settings_field(
1215 'auth_settings_advanced_users_per_page',
1216 __( 'Number of users per page', 'authorizer' ),
1217 array( Advanced::get_instance(), 'print_text_auth_advanced_users_per_page' ),
1218 'authorizer',
1219 'auth_settings_advanced'
1220 );
1221 add_settings_field(
1222 'auth_settings_advanced_users_sort_by',
1223 __( 'Approved users sort method', 'authorizer' ),
1224 array( Advanced::get_instance(), 'print_select_auth_advanced_users_sort_by' ),
1225 'authorizer',
1226 'auth_settings_advanced'
1227 );
1228 add_settings_field(
1229 'auth_settings_advanced_users_sort_order',
1230 __( 'Approved users sort order', 'authorizer' ),
1231 array( Advanced::get_instance(), 'print_select_auth_advanced_users_sort_order' ),
1232 'authorizer',
1233 'auth_settings_advanced'
1234 );
1235 add_settings_field(
1236 'auth_settings_advanced_widget_enabled',
1237 __( 'Show dashboard widget to admin users', 'authorizer' ),
1238 array( Advanced::get_instance(), 'print_checkbox_auth_advanced_widget_enabled' ),
1239 'authorizer',
1240 'auth_settings_advanced'
1241 );
1242 // On multisite installs, add an option to override all multisite settings on individual sites.
1243 if ( is_multisite() ) {
1244 add_settings_field(
1245 'auth_settings_advanced_override_multisite',
1246 __( 'Override multisite options', 'authorizer' ),
1247 array( Advanced::get_instance(), 'print_checkbox_auth_advanced_override_multisite' ),
1248 'authorizer',
1249 'auth_settings_advanced'
1250 );
1251 }
1252 }
1253
1254
1255 /**
1256 * Output the HTML for the options page.
1257 */
1258 public function create_admin_page() {
1259 ?>
1260 <div class="wrap">
1261 <h2><?php esc_html_e( 'Authorizer Settings', 'authorizer' ); ?></h2>
1262 <form method="post" action="options.php" autocomplete="off">
1263 <?php
1264 // This prints out all hidden settings fields.
1265 settings_fields( 'auth_settings_group' );
1266 // This prints out all the sections.
1267 do_settings_sections( 'authorizer' );
1268 submit_button();
1269 ?>
1270 </form>
1271 </div>
1272 <?php
1273 }
1274
1275
1276 /**
1277 * Output the HTML for the options page.
1278 */
1279 public function create_network_admin_page() {
1280 if ( ! current_user_can( 'manage_network_options' ) ) {
1281 wp_die( wp_kses( __( 'You do not have sufficient permissions to access this page.', 'authorizer' ), Helper::$allowed_html ) );
1282 }
1283 $options = Options::get_instance();
1284 $access_lists = Access_Lists::get_instance();
1285 $login_access = Login_Access::get_instance();
1286 $public_access = Public_Access::get_instance();
1287 $external = External::get_instance();
1288 $oauth2 = OAuth2::get_instance();
1289 $oidc = Oidc::get_instance();
1290 $google = Google::get_instance();
1291 $cas = Cas::get_instance();
1292 $ldap = Ldap::get_instance();
1293 $advanced = Advanced::get_instance();
1294 $auth_settings = get_blog_option( get_main_site_id( get_main_network_id() ), 'auth_multisite_settings', array() );
1295 ?>
1296 <div class="wrap">
1297 <form method="post" action="" autocomplete="off">
1298 <h2><?php esc_html_e( 'Authorizer Settings', 'authorizer' ); ?></h2>
1299 <p><?php echo wp_kses( __( 'Most <strong>Authorizer</strong> settings are set in the individual sites, but you can specify a few options here that apply to <strong>all sites in the network</strong>. These settings will override settings in the individual sites.', 'authorizer' ), Helper::$allowed_html ); ?></p>
1300
1301 <p><input type="checkbox" id="auth_settings_multisite_override" name="auth_settings[multisite_override]" value="1"<?php checked( 1 === intval( $auth_settings['multisite_override'] ) ); ?> /><label for="auth_settings_multisite_override"><?php esc_html_e( 'Override individual site settings with the settings below', 'authorizer' ); ?></label></p>
1302 <p><input type="checkbox" id="auth_settings_prevent_override_multisite" name="auth_settings[prevent_override_multisite]" value="1"<?php checked( 1 === intval( $auth_settings['prevent_override_multisite'] ) ); ?> /><label for="auth_settings_prevent_override_multisite"><?php esc_html_e( 'Prevent site administrators from overriding any multisite settings defined here (via Authorizer > Advanced > Override multisite options)', 'authorizer' ); ?></label></p>
1303
1304 <div id="auth_multisite_settings_disabled_overlay" style="display: none;"></div>
1305
1306 <div class="wrap" id="auth_multisite_settings">
1307 <?php $options->print_section_info_tabs( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?>
1308
1309 <?php wp_nonce_field( 'save_auth_settings', 'nonce_save_auth_settings' ); ?>
1310
1311 <?php // Custom access lists (for network, we only really want approved list, not pending or blocked). ?>
1312 <div id="section_info_access_lists" class="section_info">
1313 <p><?php esc_html_e( 'Manage who has access to all sites in the network.', 'authorizer' ); ?></p>
1314 </div>
1315 <table class="form-table"><tbody>
1316 <tr>
1317 <th scope="row"><?php esc_html_e( 'Who can log in to sites in this network?', 'authorizer' ); ?></th>
1318 <td><?php $login_access->print_radio_auth_access_who_can_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1319 </tr>
1320 <tr>
1321 <th scope="row"><?php esc_html_e( 'Who can view sites in this network?', 'authorizer' ); ?></th>
1322 <td><?php $public_access->print_radio_auth_access_who_can_view( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1323 </tr>
1324 <tr>
1325 <th scope="row"><?php esc_html_e( 'Approved Users (All Sites)', 'authorizer' ); ?><br /><small><em><?php echo wp_kses( __( 'Note: these users will <strong>not</strong> receive welcome emails when approved. Only users approved from individual sites can receive these messages.', 'authorizer' ), Helper::$allowed_html ); ?></em></small></th>
1326 <td><?php $access_lists->print_combo_auth_access_users_approved( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1327 </tr>
1328 </tbody></table>
1329
1330 <?php $external->print_section_info_external(); ?>
1331 <table class="form-table"><tbody>
1332 <tr>
1333 <th scope="row"><?php esc_html_e( 'Default role for new users', 'authorizer' ); ?></th>
1334 <td><?php $external->print_select_auth_access_default_role( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1335 </tr>
1336 <tr>
1337 <th scope="row"><?php esc_html_e( 'OAuth2 Logins', 'authorizer' ); ?></th>
1338 <td><?php $oauth2->print_checkbox_auth_external_oauth2( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1339 </tr>
1340 <tr>
1341 <th scope="row"><?php esc_html_e( 'OIDC Logins', 'authorizer' ); ?></th>
1342 <td><?php $oidc->print_checkbox_auth_external_oidc( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1343 </tr>
1344 <tr>
1345 <th scope="row"><?php esc_html_e( 'Google Logins', 'authorizer' ); ?></th>
1346 <td><?php $google->print_checkbox_auth_external_google( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1347 </tr>
1348 <tr>
1349 <th scope="row"><?php esc_html_e( 'CAS Logins', 'authorizer' ); ?></th>
1350 <td><?php $cas->print_checkbox_auth_external_cas( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1351 </tr>
1352 <tr>
1353 <th scope="row"><?php esc_html_e( 'LDAP Logins', 'authorizer' ); ?></th>
1354 <td><?php $ldap->print_checkbox_auth_external_ldap( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1355 </tr>
1356 </tbody></table>
1357
1358 <?php $external->print_section_info_external_oauth2(); ?>
1359 <table class="form-table"><tbody>
1360 <tr>
1361 <th scope="row"><?php esc_html_e( 'OAuth2 server(s)', 'authorizer' ); ?></th>
1362 <td><?php $oauth2->print_number_oauth2_num_servers( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1363 </tr>
1364 <?php $oauth2_num_servers = max( 1, min( 20, intval( $auth_settings['oauth2_num_servers'] ?? 1 ) ) ); ?>
1365 <tr>
1366 <th scope="row"><?php esc_html_e( 'OAuth2 automatic login', 'authorizer' ); ?></th>
1367 <td>
1368 <?php
1369 $oauth2->print_select_oauth2_auto_login( array(
1370 'context' => Helper::NETWORK_CONTEXT,
1371 'oauth2_num_servers' => $oauth2_num_servers,
1372 ) );
1373 ?>
1374 </td>
1375 </tr>
1376 <?php
1377 foreach ( range( 1, $oauth2_num_servers ) as $oauth2_num_server ) :
1378 $prefix = $oauth2_num_server . '. ';
1379 ?>
1380 <tr class="border-top">
1381 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'OAuth2 Provider', 'authorizer' ); ?></th>
1382 <td>
1383 <?php
1384 $oauth2->print_select_oauth2_provider( array(
1385 'context' => Helper::NETWORK_CONTEXT,
1386 'oauth2_num_server' => $oauth2_num_server,
1387 ) );
1388 ?>
1389 </td>
1390 </tr>
1391 <tr>
1392 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Custom Label', 'authorizer' ); ?></th>
1393 <td>
1394 <?php
1395 $oauth2->print_text_oauth2_custom_label( array(
1396 'context' => Helper::NETWORK_CONTEXT,
1397 'oauth2_num_server' => $oauth2_num_server,
1398 ) );
1399 ?>
1400 </td>
1401 </tr>
1402 <tr>
1403 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Client ID', 'authorizer' ); ?></th>
1404 <td>
1405 <?php
1406 $oauth2->print_text_oauth2_clientid( array(
1407 'context' => Helper::NETWORK_CONTEXT,
1408 'oauth2_num_server' => $oauth2_num_server,
1409 ) );
1410 ?>
1411 </td>
1412 </tr>
1413 <tr>
1414 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Client Secret', 'authorizer' ); ?></th>
1415 <td>
1416 <?php
1417 $oauth2->print_text_oauth2_clientsecret( array(
1418 'context' => Helper::NETWORK_CONTEXT,
1419 'oauth2_num_server' => $oauth2_num_server,
1420 ) );
1421 ?>
1422 </td>
1423 </tr>
1424 <tr>
1425 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'OAuth2 Hosted Domain', 'authorizer' ); ?></th>
1426 <td>
1427 <?php
1428 $oauth2->print_text_oauth2_hosteddomain( array(
1429 'context' => Helper::NETWORK_CONTEXT,
1430 'oauth2_num_server' => $oauth2_num_server,
1431 ) );
1432 ?>
1433 </td>
1434 </tr>
1435 <tr>
1436 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Tenant ID', 'authorizer' ); ?></th>
1437 <td>
1438 <?php
1439 $oauth2->print_text_oauth2_tenant_id( array(
1440 'context' => Helper::NETWORK_CONTEXT,
1441 'oauth2_num_server' => $oauth2_num_server,
1442 ) );
1443 ?>
1444 </td>
1445 </tr>
1446 <tr>
1447 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Authorization URL', 'authorizer' ); ?></th>
1448 <td>
1449 <?php
1450 $oauth2->print_text_oauth2_url_authorize( array(
1451 'context' => Helper::NETWORK_CONTEXT,
1452 'oauth2_num_server' => $oauth2_num_server,
1453 ) );
1454 ?>
1455 </td>
1456 </tr>
1457 <tr>
1458 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Access Token URL', 'authorizer' ); ?></th>
1459 <td>
1460 <?php
1461 $oauth2->print_text_oauth2_url_token( array(
1462 'context' => Helper::NETWORK_CONTEXT,
1463 'oauth2_num_server' => $oauth2_num_server,
1464 ) );
1465 ?>
1466 </td>
1467 </tr>
1468 <tr>
1469 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Resource Owner URL', 'authorizer' ); ?></th>
1470 <td>
1471 <?php
1472 $oauth2->print_text_oauth2_url_resource( array(
1473 'context' => Helper::NETWORK_CONTEXT,
1474 'oauth2_num_server' => $oauth2_num_server,
1475 ) );
1476 ?>
1477 </td>
1478 </tr>
1479 <tr>
1480 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing username', 'authorizer' ); ?></th>
1481 <td>
1482 <?php
1483 $oauth2->print_text_oauth2_attr_username( array(
1484 'context' => Helper::NETWORK_CONTEXT,
1485 'oauth2_num_server' => $oauth2_num_server,
1486 ) );
1487 ?>
1488 </td>
1489 </tr>
1490 <tr>
1491 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing email', 'authorizer' ); ?></th>
1492 <td>
1493 <?php
1494 $oauth2->print_text_oauth2_attr_email( array(
1495 'context' => Helper::NETWORK_CONTEXT,
1496 'oauth2_num_server' => $oauth2_num_server,
1497 ) );
1498 ?>
1499 </td>
1500 </tr>
1501 <tr>
1502 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing first name', 'authorizer' ); ?></th>
1503 <td>
1504 <?php
1505 $oauth2->print_text_oauth2_attr_first_name( array(
1506 'context' => Helper::NETWORK_CONTEXT,
1507 'oauth2_num_server' => $oauth2_num_server,
1508 ) );
1509 ?>
1510 </td>
1511 </tr>
1512 <tr>
1513 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing last name', 'authorizer' ); ?></th>
1514 <td>
1515 <?php
1516 $oauth2->print_text_oauth2_attr_last_name( array(
1517 'context' => Helper::NETWORK_CONTEXT,
1518 'oauth2_num_server' => $oauth2_num_server,
1519 ) );
1520 ?>
1521 </td>
1522 </tr>
1523 <tr>
1524 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Name attribute update', 'authorizer' ); ?></th>
1525 <td>
1526 <?php
1527 $oauth2->print_select_oauth2_attr_update_on_login( array(
1528 'context' => Helper::NETWORK_CONTEXT,
1529 'oauth2_num_server' => $oauth2_num_server,
1530 ) );
1531 ?>
1532 </td>
1533 </tr>
1534 <?php endforeach; ?>
1535 </tbody></table>
1536
1537 <?php $external->print_section_info_external_oidc(); ?>
1538 <table class="form-table"><tbody>
1539 <tr>
1540 <th scope="row"><?php esc_html_e( 'OIDC server(s)', 'authorizer' ); ?></th>
1541 <td><?php $oidc->print_number_oidc_num_servers( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1542 </tr>
1543 <?php $oidc_num_servers = max( 1, min( 20, intval( $auth_settings['oidc_num_servers'] ?? 1 ) ) ); ?>
1544 <tr>
1545 <th scope="row"><?php esc_html_e( 'OIDC automatic login', 'authorizer' ); ?></th>
1546 <td>
1547 <?php
1548 $oidc->print_select_oidc_auto_login( array(
1549 'context' => Helper::NETWORK_CONTEXT,
1550 'oidc_num_servers' => $oidc_num_servers,
1551 ) );
1552 ?>
1553 </td>
1554 </tr>
1555 <?php
1556 foreach ( range( 1, $oidc_num_servers ) as $oidc_num_server ) :
1557 $prefix = $oidc_num_server . '. ';
1558 ?>
1559 <tr class="border-top">
1560 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Custom label', 'authorizer' ); ?></th>
1561 <td>
1562 <?php
1563 $oidc->print_text_oidc_custom_label( array(
1564 'context' => Helper::NETWORK_CONTEXT,
1565 'oidc_num_server' => $oidc_num_server,
1566 ) );
1567 ?>
1568 </td>
1569 </tr>
1570 <tr>
1571 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Issuer URL', 'authorizer' ); ?></th>
1572 <td>
1573 <?php
1574 $oidc->print_text_oidc_issuer( array(
1575 'context' => Helper::NETWORK_CONTEXT,
1576 'oidc_num_server' => $oidc_num_server,
1577 ) );
1578 ?>
1579 </td>
1580 </tr>
1581 <tr>
1582 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Client ID', 'authorizer' ); ?></th>
1583 <td>
1584 <?php
1585 $oidc->print_text_oidc_client_id( array(
1586 'context' => Helper::NETWORK_CONTEXT,
1587 'oidc_num_server' => $oidc_num_server,
1588 ) );
1589 ?>
1590 </td>
1591 </tr>
1592 <tr>
1593 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Client Secret', 'authorizer' ); ?></th>
1594 <td>
1595 <?php
1596 $oidc->print_text_oidc_client_secret( array(
1597 'context' => Helper::NETWORK_CONTEXT,
1598 'oidc_num_server' => $oidc_num_server,
1599 ) );
1600 ?>
1601 </td>
1602 </tr>
1603 <tr>
1604 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Scopes', 'authorizer' ); ?></th>
1605 <td>
1606 <?php
1607 $oidc->print_text_oidc_scopes( array(
1608 'context' => Helper::NETWORK_CONTEXT,
1609 'oidc_num_server' => $oidc_num_server,
1610 ) );
1611 ?>
1612 </td>
1613 </tr>
1614 <tr>
1615 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Prompt parameter', 'authorizer' ); ?></th>
1616 <td>
1617 <?php
1618 $oidc->print_text_oidc_prompt( array(
1619 'context' => Helper::NETWORK_CONTEXT,
1620 'oidc_num_server' => $oidc_num_server,
1621 ) );
1622 ?>
1623 </td>
1624 </tr>
1625 <tr>
1626 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Login hint parameter', 'authorizer' ); ?></th>
1627 <td>
1628 <?php
1629 $oidc->print_text_oidc_login_hint( array(
1630 'context' => Helper::NETWORK_CONTEXT,
1631 'oidc_num_server' => $oidc_num_server,
1632 ) );
1633 ?>
1634 </td>
1635 </tr>
1636 <tr>
1637 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Max age parameter', 'authorizer' ); ?></th>
1638 <td>
1639 <?php
1640 $oidc->print_text_oidc_max_age( array(
1641 'context' => Helper::NETWORK_CONTEXT,
1642 'oidc_num_server' => $oidc_num_server,
1643 ) );
1644 ?>
1645 </td>
1646 </tr>
1647 <tr>
1648 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing username', 'authorizer' ); ?></th>
1649 <td>
1650 <?php
1651 $oidc->print_text_oidc_attr_username( array(
1652 'context' => Helper::NETWORK_CONTEXT,
1653 'oidc_num_server' => $oidc_num_server,
1654 ) );
1655 ?>
1656 </td>
1657 </tr>
1658 <tr>
1659 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing email', 'authorizer' ); ?></th>
1660 <td>
1661 <?php
1662 $oidc->print_text_oidc_attr_email( array(
1663 'context' => Helper::NETWORK_CONTEXT,
1664 'oidc_num_server' => $oidc_num_server,
1665 ) );
1666 ?>
1667 </td>
1668 </tr>
1669 <tr>
1670 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing first name', 'authorizer' ); ?></th>
1671 <td>
1672 <?php
1673 $oidc->print_text_oidc_attr_first_name( array(
1674 'context' => Helper::NETWORK_CONTEXT,
1675 'oidc_num_server' => $oidc_num_server,
1676 ) );
1677 ?>
1678 </td>
1679 </tr>
1680 <tr>
1681 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Attribute containing last name', 'authorizer' ); ?></th>
1682 <td>
1683 <?php
1684 $oidc->print_text_oidc_attr_last_name( array(
1685 'context' => Helper::NETWORK_CONTEXT,
1686 'oidc_num_server' => $oidc_num_server,
1687 ) );
1688 ?>
1689 </td>
1690 </tr>
1691 <tr>
1692 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Name attribute update', 'authorizer' ); ?></th>
1693 <td>
1694 <?php
1695 $oidc->print_select_oidc_attr_update_on_login( array(
1696 'context' => Helper::NETWORK_CONTEXT,
1697 'oidc_num_server' => $oidc_num_server,
1698 ) );
1699 ?>
1700 </td>
1701 </tr>
1702 <tr>
1703 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'Require verified email', 'authorizer' ); ?></th>
1704 <td>
1705 <?php
1706 $oidc->print_checkbox_oidc_require_verified_email( array(
1707 'context' => Helper::NETWORK_CONTEXT,
1708 'oidc_num_server' => $oidc_num_server,
1709 ) );
1710 ?>
1711 </td>
1712 </tr>
1713 <tr>
1714 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'OIDC users linked by username', 'authorizer' ); ?></th>
1715 <td>
1716 <?php
1717 $oidc->print_checkbox_oidc_link_on_username( array(
1718 'context' => Helper::NETWORK_CONTEXT,
1719 'oidc_num_server' => $oidc_num_server,
1720 ) );
1721 ?>
1722 </td>
1723 </tr>
1724 <tr>
1725 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'OIDC Hosted Domain', 'authorizer' ); ?></th>
1726 <td>
1727 <?php
1728 $oidc->print_text_oidc_hosteddomain( array(
1729 'context' => Helper::NETWORK_CONTEXT,
1730 'oidc_num_server' => $oidc_num_server,
1731 ) );
1732 ?>
1733 </td>
1734 </tr>
1735 <?php endforeach; ?>
1736 </tbody></table>
1737
1738 <?php $external->print_section_info_external_google(); ?>
1739 <table class="form-table"><tbody>
1740 <tr>
1741 <th scope="row"><?php esc_html_e( 'Google Client ID', 'authorizer' ); ?></th>
1742 <td><?php $google->print_text_google_clientid( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1743 </tr>
1744 <tr>
1745 <th scope="row"><?php esc_html_e( 'Google Client Secret', 'authorizer' ); ?></th>
1746 <td><?php $google->print_text_google_clientsecret( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1747 </tr>
1748 <tr>
1749 <th scope="row"><?php esc_html_e( 'Google Hosted Domain', 'authorizer' ); ?></th>
1750 <td><?php $google->print_text_google_hosteddomain( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1751 </tr>
1752 </tbody></table>
1753
1754 <?php $external->print_section_info_external_cas(); ?>
1755 <table class="form-table"><tbody>
1756 <tr>
1757 <th scope="row"><?php esc_html_e( 'CAS server(s)', 'authorizer' ); ?></th>
1758 <td><?php $cas->print_number_cas_num_servers( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1759 </tr>
1760 <?php $cas_num_servers = max( 1, min( 10, intval( $auth_settings['cas_num_servers'] ?? 1 ) ) ); ?>
1761 <tr>
1762 <th scope="row"><?php esc_html_e( 'CAS automatic login', 'authorizer' ); ?></th>
1763 <td>
1764 <?php
1765 $cas->print_select_cas_auto_login( array(
1766 'context' => Helper::NETWORK_CONTEXT,
1767 'cas_num_servers' => $cas_num_servers,
1768 ) );
1769 ?>
1770 </td>
1771 </tr>
1772 <?php
1773 foreach ( range( 1, $cas_num_servers ) as $cas_num_server ) :
1774 $prefix = $cas_num_server . '. ';
1775 ?>
1776 <tr class="border-top">
1777 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS Custom Label', 'authorizer' ); ?></th>
1778 <td>
1779 <?php
1780 $cas->print_text_cas_custom_label( array(
1781 'context' => Helper::NETWORK_CONTEXT,
1782 'cas_num_server' => $cas_num_server,
1783 ) );
1784 ?>
1785 </td>
1786 </tr>
1787 <tr>
1788 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS server hostname', 'authorizer' ); ?></th>
1789 <td>
1790 <?php
1791 $cas->print_text_cas_host( array(
1792 'context' => Helper::NETWORK_CONTEXT,
1793 'cas_num_server' => $cas_num_server,
1794 ) );
1795 ?>
1796 </td>
1797 </tr>
1798 <tr>
1799 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS server port', 'authorizer' ); ?></th>
1800 <td>
1801 <?php
1802 $cas->print_text_cas_port( array(
1803 'context' => Helper::NETWORK_CONTEXT,
1804 'cas_num_server' => $cas_num_server,
1805 ) );
1806 ?>
1807 </td>
1808 </tr>
1809 <tr>
1810 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS server path/context', 'authorizer' ); ?></th>
1811 <td>
1812 <?php
1813 $cas->print_text_cas_path( array(
1814 'context' => Helper::NETWORK_CONTEXT,
1815 'cas_num_server' => $cas_num_server,
1816 ) );
1817 ?>
1818 </td>
1819 </tr>
1820 <tr>
1821 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS server method', 'authorizer' ); ?></th>
1822 <td>
1823 <?php
1824 $cas->print_select_cas_method( array(
1825 'context' => Helper::NETWORK_CONTEXT,
1826 'cas_num_server' => $cas_num_server,
1827 ) );
1828 ?>
1829 </td>
1830 </tr>
1831 <tr>
1832 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS server protocol', 'authorizer' ); ?></th>
1833 <td>
1834 <?php
1835 $cas->print_select_cas_version( array(
1836 'context' => Helper::NETWORK_CONTEXT,
1837 'cas_num_server' => $cas_num_server,
1838 ) );
1839 ?>
1840 </td>
1841 </tr>
1842 <tr>
1843 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS attribute containing email', 'authorizer' ); ?></th>
1844 <td>
1845 <?php
1846 $cas->print_text_cas_attr_email( array(
1847 'context' => Helper::NETWORK_CONTEXT,
1848 'cas_num_server' => $cas_num_server,
1849 ) );
1850 ?>
1851 </td>
1852 </tr>
1853 <tr>
1854 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS attribute containing first name', 'authorizer' ); ?></th>
1855 <td>
1856 <?php
1857 $cas->print_text_cas_attr_first_name( array(
1858 'context' => Helper::NETWORK_CONTEXT,
1859 'cas_num_server' => $cas_num_server,
1860 ) );
1861 ?>
1862 </td>
1863 </tr>
1864 <tr>
1865 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS attribute containing last name', 'authorizer' ); ?></th>
1866 <td>
1867 <?php
1868 $cas->print_text_cas_attr_last_name( array(
1869 'context' => Helper::NETWORK_CONTEXT,
1870 'cas_num_server' => $cas_num_server,
1871 ) );
1872 ?>
1873 </td>
1874 </tr>
1875 <tr>
1876 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS attribute update', 'authorizer' ); ?></th>
1877 <td>
1878 <?php
1879 $cas->print_select_cas_attr_update_on_login( array(
1880 'context' => Helper::NETWORK_CONTEXT,
1881 'cas_num_server' => $cas_num_server,
1882 ) );
1883 ?>
1884 </td>
1885 </tr>
1886 <tr>
1887 <th scope="row"><?php echo esc_html( $prefix ); ?><?php esc_html_e( 'CAS users linked by username', 'authorizer' ); ?></th>
1888 <td>
1889 <?php
1890 $cas->print_checkbox_cas_link_on_username( array(
1891 'context' => Helper::NETWORK_CONTEXT,
1892 'cas_num_server' => $cas_num_server,
1893 ) );
1894 ?>
1895 </td>
1896 </tr>
1897 <?php endforeach; ?>
1898 </tbody></table>
1899
1900 <?php $external->print_section_info_external_ldap(); ?>
1901 <table class="form-table"><tbody>
1902 <tr>
1903 <th scope="row"><?php esc_html_e( 'LDAP Host', 'authorizer' ); ?></th>
1904 <td><?php $ldap->print_text_ldap_host( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1905 </tr>
1906 <tr>
1907 <th scope="row"><?php esc_html_e( 'LDAP Port', 'authorizer' ); ?></th>
1908 <td><?php $ldap->print_text_ldap_port( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1909 </tr>
1910 <tr>
1911 <th scope="row"><?php esc_html_e( 'Use STARTTLS', 'authorizer' ); ?></th>
1912 <td><?php $ldap->print_checkbox_ldap_tls( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1913 </tr>
1914 <tr>
1915 <th scope="row"><?php esc_html_e( 'LDAP Search Base', 'authorizer' ); ?></th>
1916 <td><?php $ldap->print_text_ldap_search_base( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1917 </tr>
1918 <tr>
1919 <th scope="row"><?php esc_html_e( 'LDAP Search Filter', 'authorizer' ); ?></th>
1920 <td><?php $ldap->print_text_ldap_search_filter( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1921 </tr>
1922 <tr>
1923 <th scope="row"><?php esc_html_e( 'LDAP attribute containing username', 'authorizer' ); ?></th>
1924 <td><?php $ldap->print_text_ldap_uid( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1925 </tr>
1926 <tr>
1927 <th scope="row"><?php esc_html_e( 'LDAP attribute containing email', 'authorizer' ); ?></th>
1928 <td><?php $ldap->print_text_ldap_attr_email( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1929 </tr>
1930 <tr>
1931 <th scope="row"><?php esc_html_e( 'LDAP Directory User', 'authorizer' ); ?></th>
1932 <td><?php $ldap->print_text_ldap_user( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1933 </tr>
1934 <tr>
1935 <th scope="row"><?php esc_html_e( 'LDAP Directory User Password', 'authorizer' ); ?></th>
1936 <td><?php $ldap->print_password_ldap_password( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1937 </tr>
1938 <tr>
1939 <th scope="row"><?php esc_html_e( 'Custom lost password URL', 'authorizer' ); ?></th>
1940 <td><?php $ldap->print_text_ldap_lostpassword_url( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1941 </tr>
1942 <tr>
1943 <th scope="row"><?php esc_html_e( 'LDAP attribute containing first name', 'authorizer' ); ?></th>
1944 <td><?php $ldap->print_text_ldap_attr_first_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1945 </tr>
1946 <tr>
1947 <th scope="row"><?php esc_html_e( 'LDAP attribute containing last name', 'authorizer' ); ?></th>
1948 <td><?php $ldap->print_text_ldap_attr_last_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1949 </tr>
1950 <tr>
1951 <th scope="row"><?php esc_html_e( 'LDAP attribute update', 'authorizer' ); ?></th>
1952 <td><?php $ldap->print_select_ldap_attr_update_on_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1953 </tr>
1954 <tr>
1955 <th scope="row"><?php esc_html_e( 'LDAP test connection', 'authorizer' ); ?></th>
1956 <td><?php $ldap->print_text_button_ldap_test_user( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1957 </tr>
1958 </tbody></table>
1959
1960 <?php $advanced->print_section_info_advanced(); ?>
1961 <table class="form-table"><tbody>
1962 <tr>
1963 <th scope="row"><?php esc_html_e( 'Limit invalid login attempts', 'authorizer' ); ?></th>
1964 <td><?php $advanced->print_text_auth_advanced_lockouts( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1965 </tr>
1966 <tr>
1967 <th scope="row"><?php esc_html_e( 'Hide WordPress Logins', 'authorizer' ); ?></th>
1968 <td><?php $advanced->print_checkbox_auth_advanced_hide_wp_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1969 </tr>
1970 <tr>
1971 <th scope="row"><?php esc_html_e( 'Disable WordPress Logins', 'authorizer' ); ?></th>
1972 <td><?php $advanced->print_checkbox_auth_advanced_disable_wp_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1973 </tr>
1974 <tr>
1975 <th scope="row"><?php esc_html_e( 'Bypass Usernames', 'authorizer' ); ?></th>
1976 <td><?php $advanced->print_text_advanced_disable_wp_login_bypass_usernames( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1977 </tr>
1978 <tr>
1979 <th scope="row"><?php esc_html_e( 'Number of users per page', 'authorizer' ); ?></th>
1980 <td><?php $advanced->print_text_auth_advanced_users_per_page( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1981 </tr>
1982 <tr>
1983 <th scope="row"><?php esc_html_e( 'Approved users sort method', 'authorizer' ); ?></th>
1984 <td><?php $advanced->print_select_auth_advanced_users_sort_by( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1985 </tr>
1986 <tr>
1987 <th scope="row"><?php esc_html_e( 'Approved users sort order', 'authorizer' ); ?></th>
1988 <td><?php $advanced->print_select_auth_advanced_users_sort_order( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1989 </tr>
1990 <tr>
1991 <th scope="row"><?php esc_html_e( 'Show Dashboard Widget', 'authorizer' ); ?></th>
1992 <td><?php $advanced->print_checkbox_auth_advanced_widget_enabled( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td>
1993 </tr>
1994 </tbody></table>
1995
1996 <br class="clear" />
1997 </div>
1998 <input type="button" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'authorizer' ); ?>" onclick="saveAuthMultisiteSettings(this);" />
1999 </form>
2000 </div>
2001 <?php
2002 }
2003
2004
2005 /**
2006 * Network Admin menu item
2007 *
2008 * Action: network_admin_menu
2009 *
2010 * @return void
2011 */
2012 public function network_admin_menu() {
2013 // @see http://codex.wordpress.org/Function_Reference/add_menu_page
2014 add_menu_page(
2015 'Authorizer',
2016 'Authorizer',
2017 'manage_network_options',
2018 'authorizer',
2019 array( self::get_instance(), 'create_network_admin_page' ),
2020 'dashicons-groups',
2021 89 // Position.
2022 );
2023 }
2024
2025
2026 /**
2027 * Create the options page under Dashboard > Settings.
2028 *
2029 * Action: admin_menu
2030 */
2031 public function add_plugin_page() {
2032 $options = Options::get_instance();
2033 $admin_menu = $options->get( 'advanced_admin_menu' );
2034 if ( 'settings' === $admin_menu ) {
2035 // @see http://codex.wordpress.org/Function_Reference/add_options_page
2036 add_options_page(
2037 'Authorizer',
2038 'Authorizer',
2039 'create_users',
2040 'authorizer',
2041 array( self::get_instance(), 'create_admin_page' )
2042 );
2043 } else {
2044 // @see http://codex.wordpress.org/Function_Reference/add_menu_page
2045 add_menu_page(
2046 'Authorizer',
2047 'Authorizer',
2048 'create_users',
2049 'authorizer',
2050 array( self::get_instance(), 'create_admin_page' ),
2051 'dashicons-groups',
2052 '99.0018465' // position (decimal is to make overlap with other plugins less likely).
2053 );
2054 }
2055 }
2056
2057
2058 /**
2059 * Load external resources on this plugin's options page.
2060 *
2061 * Action: load-settings_page_authorizer
2062 * Action: load-toplevel_page_authorizer
2063 * Action: admin_head-index.php
2064 */
2065 public function load_options_page() {
2066 wp_enqueue_script( 'authorizer', plugins_url( 'js/authorizer.js', plugin_root() ), array( 'jquery-effects-shake' ), '3.12.0', true );
2067 wp_localize_script(
2068 'authorizer',
2069 'authL10n',
2070 array(
2071 'baseurl' => get_bloginfo( 'url' ),
2072 'saved' => esc_html__( 'Saved', 'authorizer' ),
2073 'duplicate' => esc_html__( 'Duplicate', 'authorizer' ),
2074 'failed' => esc_html__( 'Failed', 'authorizer' ),
2075 'local_wordpress_user' => esc_html__( 'Local WordPress user', 'authorizer' ),
2076 'block_ban_user' => esc_html__( 'Block/Ban user', 'authorizer' ),
2077 'remove_user' => esc_html__( 'Remove user', 'authorizer' ),
2078 'no_users_in' => esc_html__( 'No users in', 'authorizer' ),
2079 'save_changes' => esc_html__( 'Save Changes', 'authorizer' ),
2080 'private_pages' => esc_html__( 'Private Pages', 'authorizer' ),
2081 'public_pages' => esc_html__( 'Public Pages', 'authorizer' ),
2082 'first_page' => esc_html__( 'First page', 'authorizer' ),
2083 'previous_page' => esc_html__( 'Previous page', 'authorizer' ),
2084 'next_page' => esc_html__( 'Next page', 'authorizer' ),
2085 'last_page' => esc_html__( 'Last page', 'authorizer' ),
2086 'is_network_admin' => is_network_admin() ? '1' : '0',
2087 'select_users' => esc_html__( 'Add individual users to notify, if any', 'authorizer' ),
2088 )
2089 );
2090
2091 wp_enqueue_script( 'jquery-autogrow-textarea', plugins_url( 'vendor-custom/jquery.autogrow-textarea/jquery.autogrow-textarea.js', plugin_root() ), array( 'jquery' ), '3.0.7', true );
2092
2093 wp_enqueue_script( 'jquery.multi-select', plugins_url( 'vendor-custom/jquery.multi-select/0.9.12/js/jquery.multi-select.js', plugin_root() ), array( 'jquery' ), '0.9.12', true );
2094
2095 wp_enqueue_script( 'select2', plugins_url( 'vendor-custom/select2/4.0.13/dist/js/select2.min.js', plugin_root() ), array(), '4.0.13', true );
2096
2097 wp_register_style( 'authorizer-css', plugins_url( 'css/authorizer.css', plugin_root() ), array(), '3.10.0' );
2098 wp_enqueue_style( 'authorizer-css' );
2099
2100 wp_register_style( 'jquery-multi-select-css', plugins_url( 'vendor-custom/jquery.multi-select/0.9.12/css/multi-select.css', plugin_root() ), array(), '0.9.12' );
2101 wp_enqueue_style( 'jquery-multi-select-css' );
2102
2103 wp_register_style( 'select2', plugins_url( 'vendor-custom/select2/4.0.13/dist/css/select2.min.css', plugin_root() ), array(), '4.0.13' );
2104 wp_enqueue_style( 'select2' );
2105
2106 add_action( 'admin_notices', array( self::get_instance(), 'admin_notices' ) ); // Add any notices to the top of the options page.
2107 add_action( 'admin_head', array( self::get_instance(), 'admin_head' ) ); // Add help documentation to the options page.
2108 }
2109 }
2110