-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next-7873/update-oauth2-server-dependency' into 'trunk'
NEXT-7873 - bumped league/oauth2-server to major version 8 See merge request shopware/6/product/platform!4379
- Loading branch information
Showing
14 changed files
with
197 additions
and
97 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...og/_unreleased/2021-02-03-bumped-oauth2-server-dependency-to-major-version-8.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Bumped oauth2-server dependency to major version 8 | ||
issue: NEXT-7873 | ||
author: Lennart Tinkloh | ||
author_email: l.tinkloh@shopware.com | ||
author_github: lernhart | ||
--- | ||
# Core | ||
* Added `src/Core/Framework/Api/OAuth/ClientRepository::validateClient` | ||
* Added `src/Core/Framework/Api/OAuth/Client/ApiClient::isConfidential` | ||
* Added `src/Core/Checkout/Payment/Cart/Token/JWTConfigurationFactory`, which creates an injectable JWT configuration object | ||
* Added parameter `configuration` to `src/Core/Framework/Api/OAuth/BearerTokenValidator` constructor. | ||
|
||
___ | ||
# Upgrade Information | ||
The parameter signature of `src/Core/Framework/Api/OAuth/ClientRepository::getClientEntity` changed due to the major update of the oauth2-server dependency. | ||
OAuth2-Clients should be validated separately in the new `validateClient` method. | ||
See: https://github.com/thephpleague/oauth2-server/pull/938 | ||
|
||
The parameter signature of `src/Core/Checkout/Payment/Cart/Token/JWTFactoryV2` changed. | ||
It uses the injected configuration object rather than a private key. | ||
|
||
The parameter signature of `src/Core/Framework/Api/OAuth/BearerTokenValidator` changed. | ||
The injected configuration object was added as parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Core/Checkout/Payment/Cart/Token/JWTConfigurationFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Checkout\Payment\Cart\Token; | ||
|
||
use Lcobucci\JWT\Configuration; | ||
use Lcobucci\JWT\Decoder; | ||
use Lcobucci\JWT\Encoder; | ||
use Lcobucci\JWT\Signer; | ||
use Lcobucci\JWT\Signer\Key\InMemory; | ||
use Lcobucci\JWT\Validation\Constraint\SignedWith; | ||
use League\OAuth2\Server\CryptKey; | ||
|
||
class JWTConfigurationFactory | ||
{ | ||
public static function createJWTConfiguration( | ||
Signer $signer, | ||
CryptKey $privateKey, | ||
CryptKey $publicKey, | ||
?Encoder $encoder = null, | ||
?Decoder $decoder = null | ||
): Configuration { | ||
$privateKey = InMemory::file($privateKey->getKeyPath(), $privateKey->getPassPhrase() ?? ''); | ||
$publicKey = InMemory::file($publicKey->getKeyPath(), $publicKey->getPassPhrase() ?? ''); | ||
|
||
$configuration = Configuration::forAsymmetricSigner( | ||
$signer, | ||
$privateKey, | ||
$publicKey, | ||
$encoder, | ||
$decoder | ||
); | ||
|
||
// add basic constraint for token signature validation | ||
$constraint = new SignedWith($signer, $publicKey); | ||
$configuration->setValidationConstraints($constraint); | ||
|
||
return $configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
656c82d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/shopware/platform/blob/v6.4.0.0/UPGRADE-6.4.md#oauth2-upgrade
So api/oauth/token no longer works? How do we auth now?
The docs also don't mention anything new.
https://developer.shopware.com/docs/guides/integrations-api/admin-api/authentication
656c82d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @treffner.
Authentication should work as it worked before.
The breaks come from the updated dependencies
(league/oauth2-server, lcobucci/jwt)
and are only for developers, extending/modifying the Shopware OAuth workflow.656c82d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lernhart Ah thanks for the fast response.
I was worried because of the wording in the changelog "This comes with a break in our current oauth2 core implementation.".
656c82d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@treffner
Maybe this is a bit misleading, but the upgrade.md should only have changes regarding the plugin developer in general.
656c82d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lernhart
Ah ok, well I can't login with client credentials anymore. But I'm not sure if this commit introduced the regression. I opened an issue #1846