echo ok
+echo -n "Authenticating with username/password/authgroup... "
+( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443/?domains=xyz,abc,def --authgroup=abc -u test $FINGERPRINT --cookieonly >/dev/null 2>&1) ||
+ fail $PID "Could not receive cookie from fake F5 server"
+
+echo ok
+
echo -n "Authenticating with username/password, then proceeding to tunnel stage... "
echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443 -u test $FINGERPRINT >/dev/null 2>&1
test $? = 2 || # what OpenConnect returns when server rejects cookie upon tunnel connection, as the fake server does
########################################
# Respond to initial 'GET /' with a redirect to '/my.policy'
+# [Save list of domains/authgroups in the session for use later]
@app.route('/')
def root():
- session.update(step='initial-GET')
+ domains = request.args.get('domains')
+ session.update(step='initial-GET', domains=domains and domains.split(','))
# print(session)
return redirect(url_for('get_policy'))
@app.route('/my.policy')
def get_policy():
session.update(step='GET-login-form')
+ domains = session.get('domains')
+ sel = ''
+ if domains:
+ sel = '<select name="domain">%s</select>' % ''.join(
+ '<option value="%d">%s</option>' % nv for nv in enumerate(domains))
+
return '''
<html><body><form id="auth_form" method="post">
<input type="text" name="username"/>
<input type="password" name="password"/>
-</form></body></html>'''
+%s</form></body></html>''' % sel
# Respond to 'POST /my.policy with a redirect response containing MRHSession and F5_ST
# cookies (OpenConnect uses the combination of the two to detect successful authentication)
@app.route('/my.policy', methods=['POST'])
def post_policy():
- session.update(step='POST-login', username=request.form.get('username'), credential=request.form.get('password'))
+ domains = session.get('domains')
+ if domains:
+ assert 0 <= int(request.form.get('domain',-1)) < len(domains)
+ session.update(step='POST-login', username=request.form.get('username'),
+ credential=request.form.get('password'),
+ domain=request.form.get('domain'))
# print(session)
resp = redirect(url_for('webtop'))