Skip to content

Commit 21cce40

Browse files
authored
add an option to ignore gateway redirects (#93)
For some gateway configurations, gp-saml-gui prints a message: IMPORTANT: During the SAML auth, you were redirected from [...] gp-saml-gui uses the target of the redirect, but this is not always correct. Add an option to direct gp-saml-gui to ignore the redirect. Signed-off-by: Daniel Lenski <[email protected]>
1 parent 322abd3 commit 21cce40

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

gp-saml-gui.8

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Don't use or store cookies at all
6565
.B -g, --gateway
6666
SAML auth to gateway
6767
.IP
68+
.B -i, --ignore-redirects
69+
Use specified gateway hostname as server, ignoring redirects
70+
.IP
6871
.B -p, --portal
6972
SAML auth to portal (default)
7073
.IP

gp_saml_gui.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)