@@ -271,6 +271,7 @@ def parse_args(args = None):
271
271
x .add_argument ('-K' , '--no-cookies' , dest = 'cookies' , action = 'store_const' , const = None ,
272
272
help = "Don't use or store cookies at all" )
273
273
x = p .add_mutually_exclusive_group ()
274
+ p .add_argument ('-i' , '--ignore-redirects' , action = 'store_true' , help = 'Use specified gateway hostname as server, ignoring redirects' )
274
275
x .add_argument ('-g' ,'--gateway' , dest = 'interface' , action = 'store_const' , const = 'gateway' , default = 'portal' ,
275
276
help = 'SAML auth to gateway' )
276
277
x .add_argument ('-p' ,'--portal' , dest = 'interface' , action = 'store_const' , const = 'portal' ,
@@ -401,7 +402,10 @@ def main(args = None):
401
402
402
403
# extract response and convert to OpenConnect command-line
403
404
un = slv .saml_result .get ('saml-username' )
404
- server = slv .saml_result .get ('server' , args .server )
405
+ if args .ignore_redirects :
406
+ server = args .server
407
+ else :
408
+ server = slv .saml_result .get ('server' , args .server )
405
409
406
410
for cn , ifh in (('prelogin-cookie' ,'gateway' ), ('portal-userauthcookie' ,'portal' )):
407
411
cv = slv .saml_result .get (cn )
@@ -439,9 +443,14 @@ def main(args = None):
439
443
if args .verbose :
440
444
# Warn about ambiguities
441
445
if server != args .server and not args .uri :
442
- print ('''IMPORTANT: During the SAML auth, you were redirected from {0} to {1}. This probably '''
443
- '''means you should specify {1} as the server for final connection, but we're not 100% '''
444
- '''sure about this. You should probably try both.\n ''' .format (args .server , server ), file = stderr )
446
+ if args .ignore_redirects :
447
+ print ('''IMPORTANT: During the SAML auth, you were redirected from {0} to {1}. This probably '''
448
+ '''means you should specify {1} as the server for final connection, but we're not 100% '''
449
+ '''sure about this. You should probably try both; if necessary, use the '''
450
+ '''--ignore-redirects option to specify desired behavior.\n ''' .format (args .server , server ), file = stderr )
451
+ else :
452
+ print ('''IMPORTANT: During the SAML auth, you were redirected from {0} to {1}, however the '''
453
+ '''redirection was ignored because you specified --ignore-redirects.\n ''' .format (args .server , server ), file = stderr )
445
454
if ifh != args .interface and not args .uri :
446
455
print ('''IMPORTANT: We started with SAML auth to the {} interface, but received a cookie '''
447
456
'''that's often associated with the {} interface. You should probably try both.\n ''' .format (args .interface , ifh ),
0 commit comments