Repository navigation
Expand file tree
/
Copy pathfaable-auth.php
More file actions
61 lines (55 loc) · 2.11 KB
/
Copy pathfaable-auth.php
File metadata and controls
61 lines (55 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Plugin Name: Faable Auth
* Plugin URI: https://github.com/faablecloud/faable-auth-wordpress
* Description: Sign in to WordPress with Faable Auth (OpenID Connect). Replaces the password login, syncs roles on every login and accepts Faable machine-to-machine tokens on the REST API.
* Version: 1.1.3
* Requires at least: 6.4
* Requires PHP: 8.1
* Author: Faable
* Author URI: https://faable.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: faable-auth
*
* @package FaableAuth
*/
defined( 'ABSPATH' ) || exit;
// Loaded twice (e.g. as a regular plugin AND required by a host's
// must-use loader): the first copy wins.
if ( defined( 'FAABLE_AUTH_VERSION' ) ) {
return;
}
define( 'FAABLE_AUTH_VERSION', '1.1.3' );
define( 'FAABLE_AUTH_FILE', __FILE__ );
// Where this build is distributed from: 'github' (its releases) or 'wporg',
// which bin/build-zip.sh --wporg sets.
define( 'FAABLE_AUTH_DISTRIBUTION', 'github' );
foreach ( array( 'Jwt', 'Pkce', 'RoleMapper', 'BreakGlass', 'Crypto', 'Config', 'Oidc', 'LoginLink', 'Login', 'UserSync', 'UserEnumeration', 'Rest', 'Admin' ) as $faable_auth_class ) {
require_once __DIR__ . '/src/' . $faable_auth_class . '.php';
}
unset( $faable_auth_class );
// Nothing here needs an activation hook: the plugin also works when a host
// loads it as a must-use plugin, where activation never runs.
add_action(
'plugins_loaded',
static function () {
FaableAuth\Login::init();
FaableAuth\UserSync::init();
FaableAuth\UserEnumeration::init();
FaableAuth\Rest::init();
if ( is_admin() ) {
FaableAuth\Admin::init();
}
// wporg:strip-start — the wordpress.org build leaves this out (bin/build-zip.sh --wporg).
if ( 'github' === FAABLE_AUTH_DISTRIBUTION && is_readable( __DIR__ . '/src/Updater.php' ) ) {
require_once __DIR__ . '/src/Updater.php';
FaableAuth\Updater::init();
}
// wporg:strip-end
}
);
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once __DIR__ . '/src/Cli.php';
WP_CLI::add_command( 'faable-auth', 'FaableAuth\\Cli' );
}