This module is broken for me, running D9 and PHP 8. This is due to incompatibility with the underlying dependencies as opposed to PHP 8-specific code issues. This incompatibility is related to what's noted in this comment, namely that "drupal/simple_oauth": "^5.0" is not compatible with league/oauth2-server": "^8.2". They mention a workaround that pegs to a lower version of oath2-server, but this is not an option when running PHP 8.
The first error that's encountered is addressed in https://www.drupal.org/project/simple_oauth/issues/3187358#comment-13931772. However, this leads to a cascade of bugs. Specifically, adding that patch fixes ArgumentCountError: Too few arguments to function Drupal\simple_oauth\Entities\AccessTokenEntity::convertToJWT(), 0 passed in /var/www/html/drupal/vendor/league/oauth2-server/src/Entities/Traits/AccessTokenTrait.php, but then leads to another error Error: Cannot instantiate interface Lcobucci\JWT\Builder in Drupal\simple_oauth\Entities\AccessTokenEntity->convertToJWT() (line 30 of /var/www/html/drupal/web/modules/contrib/simple_oauth/src/Entities/AccessTokenEntity.php).
That error led me to https://github.com/lcobucci/jwt/discussions/744, which points out that this is an issue that's likely to surface as a result of migrating from lcobucci/jwt v3 to v4. That specific error is due to the Builder class now being an Interface instead. There are general upgrade steps outlined in https://lcobucci-jwt.readthedocs.io/en/stable/upgrading/. Deprecation notices seem to be being addressed in https://www.drupal.org/project/simple_oauth/issues/3194635.
I'd imagine the best way forward would be to peg simple_oauth to jwt v4 and make updates accordingly.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3230707-16.patch | 3.92 KB | taran2l |
Issue fork simple_oauth-3230707
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mrweiner commentedComment #3
mrweiner commentedAttaching a patch that updates the syntax used in
src/Entities/AccessTokenEntity.phpto be compatible with JWT v4 per https://lcobucci-jwt.readthedocs.io/en/stable/upgrading/. Credit to @bucefal91 and @NickLediet as well for trying to address parts of this on their own, probably based on versioning that was relevant at the time.This patch does not update composer.json requirements as I'm not sure exactly what they need to be pegged to, but I'll note thay my own
composer.lockis showing oauth2-server@8.3.2 and lcobucci/jwt@4.1.4.Comment #4
mrweiner commentedLooks like $this->getExpiryDateTime() already gives us a DateTimeImmutable, so no reason to create a new one in expiresAt(). Doing this is causing a weird unexpected character exception randomly.
Comment #5
mrweiner commentedWhoops, last one includes a composer.json change that's causing issues.
Comment #7
mrweiner commentedDon't really understand why #3 passed and #5 failed when it just simplifies the expiresAt method param. Maybe somebody else has an idea.
Comment #8
mattjones86I can confirm this patch works for me on PHP8.0. Thanks!
EDIT: Also seems to have passed tests when requesting re-test.
Comment #9
jwwj commentedThe patch works for me as well. Though in order for all the parts to fit together while using a composer based setup I had to do the following:
This gave me the latest dependency versions that work on PHP8 even though simple_oauth currently requires oauth2-server < 8.2. After that I could apply the patch in #5, and everything seems to work so far :)
Comment #10
mrweiner commented@jwwj interesting -- I actually didn't need to manually require anything non-drupal. I do have
"drupal/simple_oauth": "^5.0"and"drupal/jwt": "^1.0@RC"tho.Comment #11
taran2lComment #12
taran2lComment #14
taran2lOk, new version of the
league/oauth2-serverlibrary has slightly changed what errors are being thrown, see https://github.com/thephpleague/oauth2-server/commit/96b76efc5c70cdccf97...Updated patch is here (also fixes a few code style errors)
Comment #16
taran2lResponse code too ...
Comment #17
bradjones1Applied #16 and ran the test suite locally against PHP 7.4; got a bunch of test-related deprecation notices (#3253976: Address test deprecation notices & get CI working again) but no failures. Running DrupalCI against latest Drupal core for PHP 7.4 and 8.0.
Comment #18
bradjones1I think we may still want to express our own direct dependency on lcobucci/jwt since we directly implement it, but otherwise this LGTM.
Comment #19
bradjones1Need to address PHP 8: https://www.drupal.org/pift-ci-job/2262963
Looks like 2.x of the OIDC library isn't really much of a BC break.
The league library is compatible with the jwt library 3.x or 4.x.
Comment #21
bradjones1Comment #22
bradjones1Hrm... well now I need to figure out how to get ext-sodium installed on DrupalCI. I've pinged on Drupal Slack for an example to customize the runner.
Comment #23
bradjones1PP on DrupalCI
Comment #24
bradjones1Note to anyone also using Commerce Authnet: #3254044: Bump lcobucci/jwt to ^4
Raised the question re: ext-sodium on Drupal Slack; doesn't look like there's any straightforward answer?
Comment #25
bradjones1If DrupalCI can't handle this, I will test locally and upload artifacts here; this will limit testing for the whole module so perhaps also we might need to switch to GitLab CI, which is now a thing (though I think, opt-in.)
Comment #26
bradjones1Definitive: DrupalCI is going to choke on this. I think *maybe* we could disable checking platform requirements on composer install, but I kind of don't want to do that.
So I'll have to figure out something different, e.g. mirroring this to gitlab.com until Drupal's GitLab implementation catches up.
See https://drupal.slack.com/archives/C223PR743/p1639594406185700?thread_ts=...
Comment #27
simonbaeseJust a short feedback. Have been running #5 and later #16 with multiple different configurations during the past months without any problems. Also, the implementation looks good to go for me.
Comment #28
bradjones1Thanks. There are a few deprecations I'm addressing from local testing against 8.x but I should be wrapped up with that today.
Comment #30
bradjones1Comment #32
bradjones1Comment #34
bradjones1Comment #35
bradjones1For anyone following this issue, please test https://www.drupal.org/project/simple_oauth/releases/5.1.0-beta1 and open new issues if there are any oversights.