PluginProbe
Authorizer / 3.14.4
Authorizer v3.14.4
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.14.4, at src/authorizer/class-admin-page.php

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