@@ -271,6 +271,7 @@ def parse_args(args = None):
271271 x .add_argument ('-K' , '--no-cookies' , dest = 'cookies' , action = 'store_const' , const = None ,
272272 help = "Don't use or store cookies at all" )
273273 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' )
274275 x .add_argument ('-g' ,'--gateway' , dest = 'interface' , action = 'store_const' , const = 'gateway' , default = 'portal' ,
275276 help = 'SAML auth to gateway' )
276277 x .add_argument ('-p' ,'--portal' , dest = 'interface' , action = 'store_const' , const = 'portal' ,
@@ -401,7 +402,10 @@ def main(args = None):
401402
402403 # extract response and convert to OpenConnect command-line
403404 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 )
405409
406410 for cn , ifh in (('prelogin-cookie' ,'gateway' ), ('portal-userauthcookie' ,'portal' )):
407411 cv = slv .saml_result .get (cn )
@@ -439,9 +443,14 @@ def main(args = None):
439443 if args .verbose :
440444 # Warn about ambiguities
441445 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 )
445454 if ifh != args .interface and not args .uri :
446455 print ('''IMPORTANT: We started with SAML auth to the {} interface, but received a cookie '''
447456 '''that's often associated with the {} interface. You should probably try both.\n ''' .format (args .interface , ifh ),
0 commit comments