@@ -41,32 +41,48 @@ public function isAuthenticationRequest(ServerRequestInterface $request): bool
41
41
return $ language && $ request ->getUri ()->getPath () === $ this ->getAuthenticationUrlRoutePath ($ language );
42
42
}
43
43
44
+ /**
45
+ * @deprecated
46
+ */
44
47
public function getAuthenticationRequestUrl (): ?UriInterface
45
48
{
46
- $ request = $ GLOBALS ['TYPO3_REQUEST ' ] ?? null ;
47
- if ($ request ) {
48
- $ loginUrl = GeneralUtility::getIndpEnv ('TYPO3_REQUEST_URL ' );
49
- $ redirectUrl = $ request ->getParsedBody ()['redirect_url ' ] ?? $ request ->getQueryParams ()['redirect_url ' ] ?? '' ;
50
-
51
- // TYPO3 v13
52
- if (class_exists (\TYPO3 \CMS \Core \Crypto \HashService::class)) {
53
- $ hash = GeneralUtility::makeInstance (\TYPO3 \CMS \Core \Crypto \HashService::class)->hmac ($ loginUrl . $ redirectUrl , 'oidc ' );
54
- } else {
55
- $ hash = GeneralUtility::hmac ($ loginUrl . $ redirectUrl , 'oidc ' );
56
- }
57
-
58
- $ query = GeneralUtility::implodeArrayForUrl ('' , [
59
- 'login_url ' => $ loginUrl ,
60
- 'redirect_url ' => $ redirectUrl ,
61
- 'validation_hash ' => $ hash ,
62
- ]);
63
-
64
- $ language = $ request ->getAttribute ('language ' , $ request ->getAttribute ('site ' )->getDefaultLanguage ());
65
- return $ language ->getBase ()
66
- ->withPath ($ this ->getAuthenticationUrlRoutePath ($ language ))
67
- ->withQuery ($ query );
49
+ trigger_error (
50
+ 'Calling getAuthenticationRequestUrl will be removed. Consider using getFrontendAuthenticationRequestUrl instead. ' ,
51
+ E_USER_DEPRECATED ,
52
+ );
53
+ $ request = $ GLOBALS ['TYPO3_REQUEST ' ];
54
+ return $ this ->getFrontendAuthenticationRequestUrl (
55
+ $ request ->getAttribute ('language ' , $ request ->getAttribute ('site ' )->getDefaultLanguage ()),
56
+ GeneralUtility::getIndpEnv ('TYPO3_REQUEST_URL ' ),
57
+ $ request ->getParsedBody ()['redirect_url ' ] ?? $ request ->getQueryParams ()['redirect_url ' ] ?? '' ,
58
+ );
59
+ }
60
+
61
+ public function getFrontendAuthenticationRequestUrl (
62
+ SiteLanguage $ language ,
63
+ UriInterface $ loginUrl ,
64
+ ?UriInterface $ redirectUrl = null ,
65
+ ): ?UriInterface {
66
+ $ queryParameters = ['login_url ' => (string )$ loginUrl ];
67
+ if ($ redirectUrl ) {
68
+ $ queryParameters ['redirect_url ' ] = (string )$ redirectUrl ;
69
+ }
70
+
71
+ $ queryParametersString = implode (array_values ($ queryParameters ));
72
+ // TYPO3 v13
73
+ if (class_exists (\TYPO3 \CMS \Core \Crypto \HashService::class)) {
74
+ $ hash = GeneralUtility::makeInstance (\TYPO3 \CMS \Core \Crypto \HashService::class)->hmac ($ queryParametersString , 'oidc ' );
75
+ } else {
76
+ $ hash = GeneralUtility::hmac ($ queryParametersString , 'oidc ' );
68
77
}
69
- return null ;
78
+
79
+ $ queryParameters ['validation_hash ' ] = $ hash ;
80
+
81
+ $ query = GeneralUtility::implodeArrayForUrl ('' , $ queryParameters );
82
+
83
+ return $ language ->getBase ()
84
+ ->withPath ($ this ->getAuthenticationUrlRoutePath ($ language ))
85
+ ->withQuery ($ query );
70
86
}
71
87
72
88
public function generateAuthenticationContext (ServerRequestInterface $ request , array $ authorizationUrlOptions = []): AuthenticationContext
0 commit comments