Skip to content

Commit c254a90

Browse files
Merge pull request #1 from jamesmorrison/feature/enhancements
Updates and enhancements to documentation.
2 parents 1c55298 + 3895be7 commit c254a90

File tree

5 files changed

+112
-29
lines changed

5 files changed

+112
-29
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
All notable changes to this project will be documented in this file, per [the Keep a Changelog standard](http://keepachangelog.com/), and will adhere to [Semantic Versioning](http://semver.org/).
44

5+
## [1.0.0] - 2023-06-23
6+
- Updates and enhancements to documentation. 🎉
7+
58
## [0.1.0] - 2023-02-27
69
- Initial private release! 🎉

cloudflare-access-sso.php

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?php
22
/**
3-
* Coudflare Access SSO
3+
* Cloudflare Access SSO
44
*
55
* @package CloudflareAccessSSO
66
* @link https://github.com/jamesmorrison/cloudflare-access-sso
77
* @author James Morrison
88
* @copyright James Morrison 2023
99
* @license GPL v2 or later
1010
*
11-
* Plugin Name: Cloudflare Access SSO
12-
* Description: Facilitates automatic login to WordPress when domain is protected with Cloudflare Access
13-
* Version: 0.1.0
14-
* Plugin URI: https://github.com/jamesmorrison/cloudflare-access-sso
15-
* Author: James Morrison
16-
* Author URI: https://jamesmorrison.uk/
17-
* Text Domain: cloudflare-access-sso
18-
* Domain Path: /languages/
11+
* Plugin Name: Cloudflare Access SSO
12+
* Description: Facilitates automatic login to WordPress when domain is protected with Cloudflare Access
13+
* Version: 1.0.0
14+
* Plugin URI: https://github.com/jamesmorrison/cloudflare-access-sso
15+
* Author: James Morrison
16+
* Author URI: https://jamesmorrison.uk/
17+
* Text Domain: cloudflare-access-sso
18+
* Domain Path: /languages/
19+
* License: GPL v2 or later
20+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
1921
*
2022
* This program is free software; you can redistribute it and/or modify
2123
* it under the terms of the GNU General Public License as published by
@@ -31,23 +33,18 @@
3133
// Security check
3234
defined( 'ABSPATH' ) || exit;
3335

34-
// The Cloudflare Team Name is required.
36+
// The Cloudflare Team Name is required
3537
if ( ! defined( 'CF_ACCESS_TEAM_NAME' ) ) {
3638
error_log( 'Cloudflare Access SSO Error: CF_ACCESS_TEAM_NAME is not defined.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
3739
return;
3840
}
3941

40-
// The Cloudflare Application ID is required.
42+
// The Cloudflare Application ID is required
4143
if ( ! defined( 'CF_ACCESS_AUD' ) ) {
4244
error_log( 'Cloudflare Access SSO Error: CF_ACCESS_AUD is not defined.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
4345
return;
4446
}
4547

46-
// Default to not enforcing SSO (which redirects wp-login => wp-admin)
47-
if ( ! defined( 'CF_ACCESS_ENFORCE_SSO' ) ) {
48-
define( 'CF_ACCESS_ENFORCE_SSO', false );
49-
}
50-
5148
// Default to 3 attempts to complete authentication
5249
if ( ! defined( 'CF_ACCESS_ATTEMPTS' ) ) {
5350
define( 'CF_ACCESS_ATTEMPTS', 3 );
@@ -58,24 +55,23 @@
5855
define( 'CF_ACCESS_LEEWAY', 60 );
5956
}
6057

61-
62-
// Useful global constants.
63-
define( 'CLOUDFLARE_ACCESS_SSO_PLUGIN_VERSION', '0.1.0' );
58+
// Useful global constants
59+
define( 'CLOUDFLARE_ACCESS_SSO_PLUGIN_VERSION', '1.0.0' );
6460
define( 'CLOUDFLARE_ACCESS_SSO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
6561
define( 'CLOUDFLARE_ACCESS_SSO_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
6662
define( 'CLOUDFLARE_ACCESS_SSO_PLUGIN_INC', CLOUDFLARE_ACCESS_SSO_PLUGIN_PATH . 'includes/' );
6763

68-
// Require Composer autoloader if it exists.
64+
// Require Composer autoloader if it exists
6965
if ( file_exists( CLOUDFLARE_ACCESS_SSO_PLUGIN_PATH . 'vendor/autoload.php' ) ) {
7066
require_once CLOUDFLARE_ACCESS_SSO_PLUGIN_PATH . 'vendor/autoload.php';
7167
}
7268

73-
// Include files.
69+
// Include files
7470
require_once CLOUDFLARE_ACCESS_SSO_PLUGIN_INC . '/core.php';
7571

76-
// Activation/Deactivation.
72+
// Activation / Deactivation
7773
register_activation_hook( __FILE__, '\CloudflareAccessSSO\Core\activate' );
7874
register_deactivation_hook( __FILE__, '\CloudflareAccessSSO\Core\deactivate' );
7975

80-
// Bootstrap.
76+
// Bootstrap
8177
CloudflareAccessSSO\Core\setup();

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jamesmorrison/cloudflare-access-sso",
33
"description": "Facilitates SSO login to WordPress via Cloudflare Access.",
4-
"version": "0.1.0",
4+
"version": "1.0.0",
55
"type": "wordpress-plugin",
66
"homepage": "https://james.morrison.uk/plugins/cloudflare-access-sso/",
77
"readme": "./readme.md",
@@ -20,11 +20,11 @@
2020
},
2121
"require": {
2222
"php": ">=8.0",
23-
"firebase/php-jwt": "^6.4"
23+
"firebase/php-jwt": "^6.8"
2424
},
2525
"autoload": {
2626
"psr-4": {
2727
"CloudflareAccessSSO\\": "includes/classes/"
2828
}
2929
}
30-
}
30+
}

composer.lock

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/classes/Plugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function process_login() {
9494
JWT::$leeway = CF_ACCESS_LEEWAY;
9595
$jwt_decoded = JWT::decode( $authorisation_header, JWK::parseKeySet( $certificates ), array( 'RS256' ) );
9696

97-
if ( isset( $jwt_decoded->email ) && isset( $jwt_decoded->aud ) && $this->verify_aud( $jwt_decoded->aud ) ) {
97+
if ( isset( $jwt_decoded->email ) && isset( $jwt_decoded->aud ) && isset( $jwt_decoded->aud[0] ) && $this->verify_aud( $jwt_decoded->aud[0] ) ) {
9898
$user = get_user_by( 'email', $jwt_decoded->email );
9999

100100
// If a matching user is found, facilitate log in.
@@ -180,8 +180,8 @@ protected function get_cloudflare_certificates( $force = false ) {
180180
* @return bool
181181
*/
182182
protected function verify_aud( $aud ) {
183-
if ( is_array( $aud ) ) {
184-
return in_array( CF_ACCESS_AUD, $aud, true );
183+
if ( is_array( CF_ACCESS_AUD ) ) {
184+
return in_array( $aud, CF_ACCESS_AUD, true );
185185
} elseif ( is_string( $aud ) ) {
186186
return CF_ACCESS_AUD === $aud;
187187
}

0 commit comments

Comments
 (0)