@@ -280,7 +280,9 @@ protected String getAuthorizationServerEndpoint(Map<String, String> authenticato
280
280
* configuration.
281
281
* @return Callback URL configured in OIDC federated authenticator configuration. If it is empty returns
282
282
* /commonauth endpoint URL path as the default value.
283
+ * @deprecated use {@link #getCallbackUrl(Map, AuthenticationContext)}.
283
284
*/
285
+ @ Deprecated
284
286
protected String getCallbackUrl (Map <String , String > authenticatorProperties ) {
285
287
286
288
String callbackUrl = authenticatorProperties .get (IdentityApplicationConstants .OAuth2 .CALLBACK_URL );
@@ -295,6 +297,33 @@ protected String getCallbackUrl(Map<String, String> authenticatorProperties) {
295
297
return callbackUrl ;
296
298
}
297
299
300
+ /**
301
+ * Returns the callback URL of the IdP Hub.
302
+ *
303
+ * @param authenticatorProperties Authentication properties configured in OIDC federated authenticator
304
+ * configuration.
305
+ * @param context Authentication context.
306
+ * @return If API based authn flow, returns the redirect URL from the authentication context. If not returns the
307
+ * callback URL configured in OIDC federated authenticator configuration and if it is empty returns
308
+ * /commonauth endpoint URL path as the default value.
309
+ */
310
+ protected String getCallbackUrl (Map <String , String > authenticatorProperties , AuthenticationContext context ) {
311
+
312
+ if (Boolean .parseBoolean ((String ) context .getProperty (IS_API_BASED ))) {
313
+ return (String ) context .getProperty (REDIRECT_URL );
314
+ }
315
+ String callbackUrl = authenticatorProperties .get (IdentityApplicationConstants .OAuth2 .CALLBACK_URL );
316
+ if (StringUtils .isBlank (callbackUrl )) {
317
+ try {
318
+ callbackUrl = ServiceURLBuilder .create ().addPath (FrameworkConstants .COMMONAUTH ).build ()
319
+ .getAbsolutePublicURL ();
320
+ } catch (URLBuilderException e ) {
321
+ throw new RuntimeException ("Error occurred while building URL in tenant qualified mode." , e );
322
+ }
323
+ }
324
+ return callbackUrl ;
325
+ }
326
+
298
327
/**
299
328
* Resolve the callback URL from the context properties to use in the API based authentication flow.
300
329
*
@@ -379,6 +408,10 @@ protected String getAuthenticateUser(AuthenticationContext context, Map<String,
379
408
return (String ) oidcClaims .get (OIDCAuthenticatorConstants .Claim .SUB );
380
409
}
381
410
411
+ /**
412
+ * @deprecated use {@link #getCallbackUrl(Map, AuthenticationContext)} instead.
413
+ */
414
+ @ Deprecated
382
415
protected String getCallBackURL (Map <String , String > authenticatorProperties ) {
383
416
384
417
return getCallbackUrl (authenticatorProperties );
@@ -514,11 +547,8 @@ protected String prepareLoginPage(HttpServletRequest request, AuthenticationCont
514
547
if (authenticatorProperties != null ) {
515
548
String clientId = authenticatorProperties .get (OIDCAuthenticatorConstants .CLIENT_ID );
516
549
String authorizationEP = getOIDCAuthzEndpoint (authenticatorProperties );
517
- String callbackurl = getCallbackUrl (authenticatorProperties );
550
+ String callbackurl = getCallbackUrl (authenticatorProperties , context );
518
551
519
- if (Boolean .parseBoolean ((String ) context .getProperty (IS_API_BASED ))) {
520
- callbackurl = resolveCallBackURLForAPIBasedAuthFlow (context );
521
- }
522
552
String state = getStateParameter (request , context , authenticatorProperties );
523
553
context .setProperty (OIDCAuthenticatorConstants .AUTHENTICATOR_NAME + STATE_PARAM_SUFFIX , state );
524
554
String nonce = UUID .randomUUID ().toString ();
@@ -1321,7 +1351,7 @@ protected void initiateLogoutRequest(HttpServletRequest request, HttpServletResp
1321
1351
paramMap .put (OIDCAuthenticatorConstants .ID_TOKEN_HINT , idTokenHint );
1322
1352
}
1323
1353
1324
- String callback = getCallbackUrl (context .getAuthenticatorProperties ());
1354
+ String callback = getCallbackUrl (context .getAuthenticatorProperties (), context );
1325
1355
paramMap .put (OIDCAuthenticatorConstants .POST_LOGOUT_REDIRECT_URI , callback );
1326
1356
1327
1357
String sessionID = getStateParameter (request , context , context .getAuthenticatorProperties ());
@@ -1493,11 +1523,7 @@ protected OAuthClientRequest getAccessTokenRequest(AuthenticationContext context
1493
1523
1494
1524
String callbackUrl = getCallbackUrlFromInitialRequestParamMap (context );
1495
1525
if (StringUtils .isBlank (callbackUrl )) {
1496
- if (Boolean .parseBoolean ((String ) context .getProperty (IS_API_BASED ))) {
1497
- callbackUrl = resolveCallBackURLForAPIBasedAuthFlow (context );
1498
- } else {
1499
- callbackUrl = getCallbackUrl (authenticatorProperties );
1500
- }
1526
+ callbackUrl = getCallbackUrl (authenticatorProperties , context );
1501
1527
}
1502
1528
1503
1529
boolean isHTTPBasicAuth = Boolean .parseBoolean (authenticatorProperties .get (OIDCAuthenticatorConstants
0 commit comments