@@ -85,7 +85,8 @@ public final class OidcAuthenticator extends SaslAuthenticator {
85
85
private static final List <String > ALLOWS_USERNAME = Arrays .asList (
86
86
AZURE_ENVIRONMENT );
87
87
88
- private static final Duration CALLBACK_TIMEOUT = Duration .ofMinutes (5 );
88
+ private static final Duration CALLBACK_TIMEOUT = Duration .ofMinutes (1 );
89
+ private static final Duration HUMAN_CALLBACK_TIMEOUT = Duration .ofMinutes (5 );
89
90
90
91
public static final String OIDC_TOKEN_FILE = "OIDC_TOKEN_FILE" ;
91
92
@@ -112,6 +113,10 @@ public OidcAuthenticator(final MongoCredentialWithCache credential,
112
113
}
113
114
}
114
115
116
+ private Duration getCallbackTimeout () {
117
+ return isHumanCallback () ? HUMAN_CALLBACK_TIMEOUT : CALLBACK_TIMEOUT ;
118
+ }
119
+
115
120
@ Override
116
121
public String getMechanismName () {
117
122
return MONGODB_OIDC .getMechanismName ();
@@ -306,7 +311,7 @@ private byte[] evaluate(final byte[] challenge) {
306
311
// Invoke Callback using cached Refresh Token
307
312
fallbackState = FallbackState .PHASE_2_REFRESH_CALLBACK_TOKEN ;
308
313
OidcCallbackResult result = requestCallback .onRequest (new OidcCallbackContextImpl (
309
- CALLBACK_TIMEOUT , cachedIdpInfo , cachedRefreshToken , userName ));
314
+ getCallbackTimeout () , cachedIdpInfo , cachedRefreshToken , userName ));
310
315
jwt [0 ] = populateCacheWithCallbackResultAndPrepareJwt (cachedIdpInfo , result );
311
316
} else {
312
317
// cache is empty
@@ -315,7 +320,7 @@ private byte[] evaluate(final byte[] challenge) {
315
320
// no principal request
316
321
fallbackState = FallbackState .PHASE_3B_CALLBACK_TOKEN ;
317
322
OidcCallbackResult result = requestCallback .onRequest (new OidcCallbackContextImpl (
318
- CALLBACK_TIMEOUT , userName ));
323
+ getCallbackTimeout () , userName ));
319
324
jwt [0 ] = populateCacheWithCallbackResultAndPrepareJwt (null , result );
320
325
if (result .getRefreshToken () != null ) {
321
326
throw new MongoConfigurationException (
@@ -345,7 +350,7 @@ private byte[] evaluate(final byte[] challenge) {
345
350
// there is no cached refresh token
346
351
fallbackState = FallbackState .PHASE_3B_CALLBACK_TOKEN ;
347
352
OidcCallbackResult result = requestCallback .onRequest (new OidcCallbackContextImpl (
348
- CALLBACK_TIMEOUT , idpInfo , null , userName ));
353
+ getCallbackTimeout () , idpInfo , null , userName ));
349
354
jwt [0 ] = populateCacheWithCallbackResultAndPrepareJwt (idpInfo , result );
350
355
}
351
356
}
@@ -606,6 +611,11 @@ public static void validateBeforeUse(final MongoCredential credential) {
606
611
Object environmentName = credential .getMechanismProperty (ENVIRONMENT_KEY , null );
607
612
Object machineCallback = credential .getMechanismProperty (OIDC_CALLBACK_KEY , null );
608
613
Object humanCallback = credential .getMechanismProperty (OIDC_HUMAN_CALLBACK_KEY , null );
614
+ boolean allowedHostsIsSet = credential .getMechanismProperty (ALLOWED_HOSTS_KEY , null ) != null ;
615
+ if (humanCallback == null && allowedHostsIsSet ) {
616
+ throw new IllegalArgumentException (ALLOWED_HOSTS_KEY + " must be specified only when "
617
+ + OIDC_HUMAN_CALLBACK_KEY + " is specified" );
618
+ }
609
619
if (environmentName == null ) {
610
620
// callback
611
621
if (machineCallback == null && humanCallback == null ) {
0 commit comments