1717use League \OAuth2 \Client \Token \AccessToken ;
1818use League \OAuth2 \Client \Token \AccessTokenInterface ;
1919use Neos \Flow \Annotations as Flow ;
20+ use Ramsey \Uuid \Uuid ;
2021
2122/**
2223 * An OAuth2 Authorization
@@ -71,6 +72,7 @@ class Authorization
7172 * @param string $clientId
7273 * @param string $grantType
7374 * @param string $scope
75+ * @throws OAuthClientException
7476 */
7577 public function __construct (string $ serviceName , string $ clientId , string $ grantType , string $ scope )
7678 {
@@ -89,9 +91,19 @@ public function __construct(string $serviceName, string $clientId, string $grant
8991 * @param string $grantType
9092 * @param string $scope
9193 * @return string
94+ * @throws OAuthClientException
9295 */
9396 public static function calculateAuthorizationId (string $ serviceName , string $ clientId , string $ grantType , string $ scope ): string
9497 {
98+ // Hotfix: An authorization using Authorization Code Flow must not be deterministic.
99+ // This is properly implemented and solved in the 2.x branch of this package
100+ if ($ scope === self ::GRANT_AUTHORIZATION_CODE ) {
101+ try {
102+ return $ serviceName . '- ' . $ clientId . '- ' . Uuid::uuid4 ()->toString ();
103+ } catch (\Exception $ e ) {
104+ throw new OAuthClientException (sprintf ('Failed generating authorization id for %s %s ' , $ serviceName , $ clientId ), 1597311416 , $ e );
105+ }
106+ }
95107 return sha1 ($ serviceName . $ clientId . $ grantType . $ scope );
96108 }
97109
0 commit comments