From af0bbe6bbed943c7bd60905b09e1dd1a7c656569 Mon Sep 17 00:00:00 2001 From: Jonathan Daggerhart Date: Mon, 21 Sep 2015 11:02:41 -0400 Subject: [PATCH] updating version number and readme. prepared upgrade flow --- openid-connect-generic.php | 35 ++++++++++++++++++++++++++--------- readme.md | 10 ++++++++-- readme.txt | 12 +++++++++--- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/openid-connect-generic.php b/openid-connect-generic.php index 5a25584..f10a938 100644 --- a/openid-connect-generic.php +++ b/openid-connect-generic.php @@ -3,7 +3,7 @@ Plugin Name: OpenID Connect - Generic Client Plugin URI: https://github.com/daggerhart/openid-connect-generic Description: Connect to an OpenID Connect identity provider with Authorization Code Flow -Version: 3.0 +Version: 3.0.1 Author: daggerhart Author URI: http://www.daggerhart.com License: GPLv2 Copyright (c) 2015 daggerhart @@ -25,7 +25,7 @@ Notes User Meta - openid-connect-generic-user - (bool) if the user was created by this plugin - - openid-connect-generic-user-identity - the identity of the user provided by the idp + - openid-connect-generic-subject-identity - the identity of the user provided by the idp - openid-connect-generic-last-id-token-claim - the user's most recent id_token claim, decoded - openid-connect-generic-last-user-claim - the user's most recent user_claim @@ -34,10 +34,10 @@ Notes - openid-connect-generic-valid-states - locally stored generated states */ -define( 'OPENID_CONNECT_GENERIC_DIR', dirname( __FILE__ ) ); - class OpenID_Connect_Generic { + // plugin version + const VERSION = '3.0.1'; // plugin settings private $settings; @@ -53,7 +53,7 @@ class OpenID_Connect_Generic { // login form adjustments private $login_form; - + /** * Setup the plugin * @@ -83,6 +83,8 @@ class OpenID_Connect_Generic { $this->client_wrapper = OpenID_Connect_Generic_Client_Wrapper::register( $this->client, $this->settings, $this->logger ); $this->login_form = OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper ); + $this->upgrade(); + if ( is_admin() ){ $this->settings_page = OpenID_Connect_Generic_Settings_Page::register( $this->settings, $this->logger ); } @@ -116,15 +118,30 @@ class OpenID_Connect_Generic { } /** - * Autoloader + * Handle plugin upgrades + */ + function upgrade(){ + $last_version = get_option( 'openid-connect-generic-plugin-version', self::VERSION ); + + if ( version_compare( self::VERSION, $last_version, '>' ) ) { + // upgrade required + + // update the stored version number + update_option( 'openid-connect-generic-plugin-version', self::VERSION ); + } + } + + /** + * Simple autoloader * * @param $class */ static public function autoload( $class ) { $filename = strtolower( str_replace( '_', '-', $class ) ) . '.php'; - - if ( file_exists( OPENID_CONNECT_GENERIC_DIR . '/includes/' . $filename ) ) { - require OPENID_CONNECT_GENERIC_DIR . '/includes/' . $filename; + $filepath = dirname( __FILE__ ) . '/includes/' . $filename; + + if ( file_exists( $filepath ) ) { + require $filepath; } } diff --git a/readme.md b/readme.md index d2cf0fb..3dc68be 100644 --- a/readme.md +++ b/readme.md @@ -14,8 +14,8 @@ new users are created in WordPress database. Much of the documentation can be found on the Settings > OpenID Connect Generic dashboard page. -Heavily based on the plugin provided by shirounagi - https://wordpress.org/plugins/generic-openid-connect/ but -has been completely rewritten to provide a bit more flexibility in development going forward. +Originally based on the plugin provided by shirounagi - https://wordpress.org/plugins/generic-openid-connect/ - but +has been completely rewritten. ### Installation @@ -34,6 +34,12 @@ Replace `example.com` with your domain name and path to WordPress. ### Changelog +**3.0** + +* Complete rewrite to separate concerns +* Changed settings keys for clarity (requires updating settings if upgrading from another version) +* Error logging + **2.1** * Working my way closer to spec. Possible breaking change. Now checking for preferred_username as priority. diff --git a/readme.txt b/readme.txt index e5bb446..e07ed49 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: daggerhart Donate link: http://www.daggerhart.com/ Tags: security, login, oauth2, openidconnect, apps, authentication, autologin, sso -Requires at least: 3.0.1 +Requires at least: 4 Tested up to: 4.2.2 Stable tag: trunk License: GPLv2 or later @@ -19,8 +19,8 @@ new users are created in WordPress database. Much of the documentation can be found on the Settings > OpenID Connect Generic dashboard page. -Heavily based on the plugin provided by shirounagi - https://wordpress.org/plugins/generic-openid-connect/ but -has been completely rewritten to provide a bit more flexibility in development going forward. +Originally based on the plugin provided by shirounagi - https://wordpress.org/plugins/generic-openid-connect/ - but +has been completely rewritten. == Installation == @@ -40,6 +40,12 @@ Replace `example.com` with your domain name and path to WordPress. == Changelog == += 3.0 = + +* Complete rewrite to separate concerns +* Changed settings keys for clarity (requires updating settings if upgrading from another version) +* Error logging + = 2.1 = * Possible breaking change. Now checking for preferred_username as priority.