Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New 3rd-party PHP dependency manager for e107 core #4099

Merged
merged 25 commits into from
Feb 26, 2020

Conversation

Deltik
Copy link
Member

@Deltik Deltik commented Feb 14, 2020

Motivation and Context

3rd-party dependencies are put into the e107 core repository but periodically need updating, which is a bit of a hassle without a dependency manager.

The e107 core also does not have a standard structure for where 3rd-party libraries are stored. Examples:

These external libraries are mixed in with core handlers/interfaces, which can make it confusing for plugin authors to know which public interfaces are stable and part of e107. One notable case is the removal of the calendar library, which required all plugins that used it to be modified to use the equivalent stable e107 core interface (thanks @Jimmi08).

Description

This pull request introduces Composer as the external dependency manager for the e107 core. External dependencies now go into a dedicated folder: ./e107_handler/vendor/.

The public interfaces in ./e107_handlers/vendor/ are not considered stable.

Plugins should not call code inside ./e107_handlers/vendor/ directly.
They should only use interfaces (handlers) provided by the e107 framework. In e107 v2, the handler factory is the e107 class.

Because this change fundamentally changes how third-party libraries are included in e107, there is a transition plan.

e107 has historically bundled the full source code of external dependencies in the core repository.
Some code, particularly syncing from the GitHub remote, expects dependencies to be included in the core source.

This behavior will be maintained until all existing code depending on the behavior is updated to support resolving dependencies with Composer.

Transition plan:

e107 Version Dependency Location Managed with Composer? Dependencies Copied in Core Repository? Behavior Change
<2.3 ./e107_handlers/ No Yes Legacy behavior
^2.3 ./e107_handlers/vendor/ Yes Yes Dependencies begin moving to be managed by Composer. Dependencies target the lowest version of PHP supported by e107 (config.platform.php option in ./composer.json).
^3 ./e107_handlers/vendor/ Yes No All dependency code is deleted from the core repository's ./e107_handlers/vendor/ folder. The e107 installer runs composer install at the beginning of the install process. The e107 self-updater runs composer install after deploying the desired e107 version. Only e107 releases may have dependencies bundled in the release package for offline/Intranet/firewalled installations.

To demonstrate these new changes, the Hybridauth (formerly known as HybridAuth) library has been updated from version 2.9.6 to version 3.1.1 in this pull request. Fixes: #3492

How Has This Been Tested?

Tests have not been written for the updated Hybridauth because I haven't figured out how Hybridauth works yet…

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist

@Deltik Deltik self-assigned this Feb 14, 2020
@Deltik Deltik added the type: enhancement An improvement or new feature request label Feb 14, 2020
@Deltik Deltik requested a review from CaMer0n February 14, 2020 11:57
@Deltik Deltik changed the title New 3rd-party library manager for e107 core New 3rd-party PHP dependency manager for e107 core Feb 14, 2020
@CaMer0n
Copy link
Member

CaMer0n commented Feb 14, 2020

The e107 core also does not have a standard structure for where 3rd-party libraries are stored.

Actually it does. subfolders of e107_handlers (phpmailer, phpthumb etc) ARE the vendor folders.
./e107_handlers/pclzip.lib.php is not a typical example as it dates back to pre v1.x. and could actually be phased out altogether in favor of ZipArchive which is bundled with PHP.

- MOD: Replaced e107::getPref('social_login') with
       SocialLoginConfigManager::getValidConfiguredProviderConfigs()
- FIX: signup_shortcodes updated with new social login providers
- MOD: e107::filter_request() code de-duplication: HTTP 400 exits
- MOD: Deprecated e107::getHybridAuth() to discourage direct access to
       third-party dependency Hybridauth
- FIX: Updated e_user_provider for Hybridauth 3
- FIX: e_user::tryProviderSession() and Hybridauth 3
- NEW: Dynamic auth provider support in social_adminarea
- NEW: Database migration for social plugin's social_login pref
In PHP 7.0.12 and earlier, a class could not be loaded with the same
name as another class in a different namespace.  This commit patches the
Hybridauth dependency to avoid PHP bug 66773.  Unfortunately, the fix
will be rolled back any time Hybridauth is updated or overwritten.

PHP bug link: https://bugs.php.net/bug.php?id=66773
- FIX: Duplicate invalid login messages in userlogin::login()
- NEW: e_user_provider: Return URL passthrough to go back where intended
- MOD: Cleanup of some confusing APIs in e_user_provider
- MOD: Return URL passthrough in system/xup/*
- MOD: system/xup/test: Logout test renamed into something clearer
Now guests can't snoop there unless the admin allows it.
Documentation has been improved accordingly.
Also fixed variable passing weirdness in API of e_user_provider
@LaocheXe
Copy link
Member

LaocheXe commented Feb 22, 2020

@Deltik - While updating the code, Social Plugin did not save the Keys/ID code, (I used Steam Login on a site, so idk if the secrets, and scopes are saved or not).

Also notice once updated, I can no longer login to Steam - get Error: [6]Couldn't resolve host 'XXX'
{XXX} was displaying my Steam Key/ID so I replace it with XXX's

@Deltik
Copy link
Member Author

Deltik commented Feb 22, 2020

@LaocheXe: This pull request changes the social plugin to generate the list of social login providers dynamically. Unfortunately, there's no API in Hybridauth 3 to know what supplemental fields are present. Steam is currently treated as plain OpenID, which doesn't accept a secret key. I hope to have a satisfactory fix for this in a future update to this pull request.

The site-wide social login system is now backwards-compatible with how
the social_login_active core pref worked since commit
3b2d833.

social_login_active's least significant bit is now treated as a global
bit, so if it's not set, no other bits are allowed to be set. This
un-breaks all existing checks for whether social_login_active is empty.

Except in themes, the social_login_active check has been replaced with
an e_user_provider API to check if social login is enabled site-wide.
@LaocheXe
Copy link
Member

LaocheXe commented Feb 22, 2020

@Deltik alright, I removed the key/id that I need for the old method, try to log in and get an Error Code 5 - SQL Insert Error. In System Log I see XUP_SIGNUP Failure, under that I see ADMINUI_04: Admin-UI DB Error: user
[ERROR] => SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_email' cannot be null

The testing site I have set up uses the same method for logging in as the current main site (which uses the current e107 social plugin), I have it set just to Login, and it never ask for email address because Steam doesn't give out that type of information.

I dont know, but do all OpenID's not require a key/id? if not then we could remove that from them so users would only have to hit the on or off switch

@Deltik
Copy link
Member Author

Deltik commented Feb 23, 2020

@LaocheXe: The SQL insert error has been fixed in daa31be.


f03e60d is my ridiculous solution to figuring out the odd fields in some social login providers (namely Facebook, Foursquare, Google, Odnoklassniki, StackExchange, Steam, Telegram, Twitter, and Vkontakte), but it's not enough for all situations.

For example, StackExchange requires the site argument, but the way the frontend currently works, only one site can be used site-wide. This means that everyone has to log in via one specific Stack Exchange site; users cannot select their own Stack Exchange site.

Another example is that Twitter has two authentication methods depending on the authorize argument. I don't quite understand what the differences are yet, but this is another bit of uncharted complexity.


Some social login providers have weird nuances that can't be expressed in the three existing input columns, "Key/ID", "Secret", and "Scope". ./e107_plugins/social/admin_config.php needs to be redesigned to accommodate the "special" fields.

@Deltik Deltik marked this pull request as ready for review February 25, 2020 13:37
@LaocheXe
Copy link
Member

@Deltik with your version I see that message, however, with current e107 - it allows the user to login (and add's their account to the database). That's is what I would like it to do, it's a way to combat spam bots.

@Deltik
Copy link
Member Author

Deltik commented Feb 25, 2020

@LaocheXe: I am still not following. The error message didn't show before due to a bug that was fixed in c260152. If you use ?route=system/xup/test on the master branch today, the "Test login only with Steam" button would fail the login silently if the user does not exist.

The "Test signup/login with Steam" button will actually register and log in the new user.

What "login only" setting are you talking about?

@LaocheXe
Copy link
Member

@Deltik Preferences > User Registration/Login > User registration system - "Login Only".

https://www.501stlegion-a3.com - using master branch of e107.
https://testing.501stlegion-a3.com - using your branch of e107.

"3rd. I have it set up to login only, Which allowed new users to just use Steam to login, so even with the first two changes, it would login me in as a new account."

What I mean is I failed to login, and it threw up an error that it couldn't find "Steam_xxx" but in the database it was listed as "steam_https://xxx" - it should have created that account in the database since it couldn't find it?

Both sites use the same setting as listed above, on the main site, new users just login, account is created.

Testing site, new user login's but fails, because their account is not on the database.

@Deltik
Copy link
Member Author

Deltik commented Feb 25, 2020

@LaocheXe: Your staging site is using the login-only endpoint (system/xup/login), but your production site is using the signup-and-login endpoint (system/xup/signup). To restore the behavior you have in production, use the signup-and-login endpoint.

The bug with user_xup being stored as Steam_https://steamcommunity.com/openid/id/76561198006790310 instead of the correct Steam_76561198006790310 has been fixed in 639943e. The incorrect records will be corrected by a manually triggered database update at /e107_admin/e107_update.php.

@codeclimate
Copy link

codeclimate bot commented Feb 26, 2020

Code Climate has analyzed commit 4d7ce7e and detected 23 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 23

The test coverage on the diff in this pull request is 12.9% (80% is the threshold).

This pull request will bring the total coverage in the repository to 6.2% (0.2% change).

View more on Code Climate.

@CaMer0n CaMer0n merged commit 35e2e3b into e107inc:master Feb 26, 2020
@Deltik Deltik deleted the fix-3492 branch February 26, 2020 21:58
Deltik added a commit to Deltik/e107 that referenced this pull request Feb 26, 2020
App root files introduced in e107inc#4099
Deltik added a commit to Deltik/e107 that referenced this pull request Feb 28, 2020
App root files introduced in e107inc#4099
Deltik added a commit that referenced this pull request Feb 28, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Feb 29, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 7, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 7, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 7, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 8, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 14, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 20, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 22, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 23, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 27, 2020
App root files introduced in #4099
Deltik added a commit that referenced this pull request Mar 27, 2020
App root files introduced in #4099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement An improvement or new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maybe it's time to change hybridauth to the new version?
3 participants