Skip to content

Commit

Permalink
Fix bug that prevented output of HTTP response file
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed Feb 4, 2017
1 parent 42401a9 commit 8db0713
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions lib/saml_tools.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#######################################################################
# Copyright 2013--2016 Internet2
# Copyright 2013--2017 Internet2
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@
#
# The function records the details of the various processing steps
# and the resulting HTTP transaction in files stored in the given
# temporary directory. If the -v option is specified on the command
# temporary directory. If the -V option is specified on the command
# line, a curl trace of the transaction is also provided.
#
#######################################################################
Expand Down Expand Up @@ -258,7 +258,7 @@ probe_saml_idp_endpoint () {
#
# The function records the details of the various processing steps
# and the resulting HTTP transaction in files stored in the given
# temporary directory. If the -v option is specified on the command
# temporary directory. If the -V option is specified on the command
# line, a curl trace of the transaction is also provided. In the
# temporary directory, see these log files for details:
#
Expand Down Expand Up @@ -315,7 +315,6 @@ probe_saml2_idp_endpoint () {
# default curl options
curl_opts="--silent --show-error"
curl_opts="$curl_opts --insecure --tlsv1"
curl_opts="$curl_opts --output /dev/null"

local opt
local OPTARG
Expand Down Expand Up @@ -407,22 +406,25 @@ probe_saml2_idp_endpoint () {
tmp_log_file="$tmp_dir/${FUNCNAME}_log"
echo "$FUNCNAME using temporary directory: $tmp_dir" > "$tmp_log_file"

# temporary files
cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt"
curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file"
header_file="${tmp_dir}/idp_http_header.txt"
curl_opts="$curl_opts --dump-header $header_file"
[ -z "$response_file" ] && response_file=/dev/null
curl_opts="$curl_opts --output $response_file"

# log input data
printf "$FUNCNAME using connection timeout (option -t): %d\n" "$connect_timeout" >> "$tmp_log_file"
printf "$FUNCNAME using max time (option -m): %d\n" "$max_time" >> "$tmp_log_file"
printf "$FUNCNAME using max redirects (option -r): %d\n" "$max_redirs" >> "$tmp_log_file"
printf "$FUNCNAME using IdP endpoint binding: %s\n" "$idp_endpoint_binding" >> "$tmp_log_file"
printf "$FUNCNAME using IdP endpoint location: %s\n" "$idp_endpoint_location" >> "$tmp_log_file"
printf "$FUNCNAME using SAML message (flattened): %s\n" "$( echo $saml_message | /usr/bin/tr -d '\n\r' )" >> "$tmp_log_file"

# temporary files
header_file="${tmp_dir}/idp_http_header.txt"
curl_opts="$curl_opts --dump-header $header_file"
printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file"
cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt"
curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file"
printf "$FUNCNAME using IdP cookie file: %s\n" "$cookie_jar_file" >> "$tmp_log_file"

printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file"
printf "$FUNCNAME using IdP response file: %s\n" "$response_file" >> "$tmp_log_file"

###################################################################
# Compute the protocol URL.
###################################################################
Expand Down Expand Up @@ -546,7 +548,7 @@ probe_saml2_idp_endpoint () {
#
# The function records the details of the various processing steps
# and the resulting HTTP transaction in files stored in the given
# temporary directory. If the -v option is specified on the command
# temporary directory. If the -V option is specified on the command
# line, a curl trace of the transaction is also provided. In the
# temporary directory, see this log file for details:
#
Expand Down Expand Up @@ -614,7 +616,6 @@ probe_shibboleth_sso_endpoint () {
# default curl options
curl_opts="--silent --show-error"
curl_opts="$curl_opts --insecure --tlsv1"
curl_opts="$curl_opts --output /dev/null"

local opt
local OPTARG
Expand Down Expand Up @@ -713,6 +714,14 @@ probe_shibboleth_sso_endpoint () {
tmp_log_file="$tmp_dir/${FUNCNAME}_log"
echo "$FUNCNAME using temporary directory: $tmp_dir" > "$tmp_log_file"

# temporary files
cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt"
curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file"
header_file="${tmp_dir}/idp_http_header.txt"
curl_opts="$curl_opts --dump-header $header_file"
[ -z "$response_file" ] && response_file=/dev/null
curl_opts="$curl_opts --output $response_file"

# log global env vars
printf "$FUNCNAME using SP with entityID: %s\n" "$SAML1_SP_ENTITY_ID" >> "$tmp_log_file"
printf "$FUNCNAME using SP ACS URL: %s\n" "$SAML1_SP_ACS_URL" >> "$tmp_log_file"
Expand All @@ -724,15 +733,10 @@ probe_shibboleth_sso_endpoint () {
printf "$FUNCNAME using max redirects (option -r): %d\n" "$max_redirs" >> "$tmp_log_file"
printf "$FUNCNAME using IdP endpoint location: %s\n" "$idp_shibboleth_sso_location" >> "$tmp_log_file"
printf "$FUNCNAME using IdP endpoint binding: %s\n" "$idp_shibboleth_sso_binding" >> "$tmp_log_file"

# temporary files
header_file="${tmp_dir}/idp_http_header.txt"
curl_opts="$curl_opts --dump-header $header_file"
printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file"
cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt"
curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file"
printf "$FUNCNAME using IdP cookie file: %s\n" "$cookie_jar_file" >> "$tmp_log_file"

printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file"
printf "$FUNCNAME using IdP response file: %s\n" "$response_file" >> "$tmp_log_file"

###################################################################
# Compute the protocol URL.
###################################################################
Expand Down

0 comments on commit 8db0713

Please sign in to comment.