Produced by Araxis Merge on 10/4/2017 8:04:43 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | rdk.zip\rdk\product\tests | curl-rdk | Mon Aug 21 12:51:01 2017 UTC |
| 2 | rdk.zip\rdk\product\tests | curl-rdk | Wed Oct 4 12:42:12 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 138 |
| Changed | 2 | 8 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | #!/bin/bas h | |
| 2 | ||
| 3 | usage() { | |
| 4 | echo " curl-rdk: send authe nticated r equests to RDK-based servers" | |
| 5 | echo "Usag e: curl-rd k [-s R E D A CTED ] [-u REDACT ] [-p ' REDACTED '] <url> [ CURL-ARGS. ..]" | |
| 6 | exit 1 | |
| 7 | } | |
| 8 | ||
| 9 | TOKEN_FILE =~/jwts | |
| 10 | OTHER_ARGU MENTS=() | |
| 11 | ||
| 12 | parse_argu ments() { | |
| 13 | while [[ $# -gt 0 ]]; do | |
| 14 | ke y="$1" | |
| 15 | ca se $key in | |
| 16 | -s |--site) | |
| 17 | SITE="$2 " | |
| 18 | shift | |
| 19 | ;; | |
| 20 | -u |--accessC ode) | |
| 21 | ACCESS_C ODE="$2" | |
| 22 | shift | |
| 23 | ;; | |
| 24 | -p |--verifyC ode) | |
| 25 | VERIFY_C ODE="$2" | |
| 26 | shift | |
| 27 | ;; | |
| 28 | ht tp*) | |
| 29 | URL="$1" | |
| 30 | HOST="$( echo "$URL " | sed 's |\(.*//[^/ ]*\).*|\1| ')" | |
| 31 | ;; | |
| 32 | *) | |
| 33 | OTHER_AR GUMENTS+=( "$1") | |
| 34 | ;; | |
| 35 | es ac | |
| 36 | sh ift | |
| 37 | done | |
| 38 | SITE="${SI TE:- R E D A CTED }" | |
| 39 | ACCESS_COD E="${ACCES S_CODE:- REDACT }" | |
| 40 | VERIFY_COD E="${VERIF Y_CODE:- REDACTED }" | |
| 41 | [[ -z "$URL" ]] && usage | |
| 42 | } | |
| 43 | ||
| 44 | parse_argu ments "$@" | |
| 45 | ||
| 46 | get_sessio n() { | |
| 47 | [[ -f "$TOKEN_FI LE" ]] && eval "$( a wk -F'\t' -v host="$ HOST" -v site="$SIT E" -v acc ess="$ACCE SS_CODE" -v verify= "$VERIFY_C ODE" '$1 ~ host && $2 ~ site && $3 ~ ac cess && $4 ~ verify { printf " JWT=%s COO KIE=%s EXP IRES=%s", $5, $6, $7 }' "$TOKE N_FILE")" | |
| 48 | } | |
| 49 | get_sessio n | |
| 50 | ||
| 51 | acquire_to kens() { | |
| 52 | auth_u rl="$HOST/ resource/a uthenticat ion" | |
| 53 | auth_r esponse=$( curl -vs - X POST -k "$auth_url " -H 'Cont ent-Type: applicatio n/json' -d '{"site": "'"$SITE"' ","accessC ode":"'"$A CCESS_CODE "'","verif yCode":"'" $VERIFY_CO DE"'"}' &> /dev/stdo ut) | |
| 54 | EXPIRE S=$(gdate -d "$(echo -n "$auth _response" | grep '< set-cooki e' | sed ' s/.*Expire s=\([^;]*\ ).*/\1/')" +%s) | |
| 55 | COOKIE =$(echo -n "$auth_re sponse" | grep '< se t-cookie' | sed 's/. * \(.*.sid =[^;]*\).* /\1/') | |
| 56 | JWT=$( echo -n "$ auth_respo nse" | gre p '< X-Set -JWT' | cu t -c 14- | sed 's/[[ :space:]]* $//') | |
| 57 | save_t okens | |
| 58 | } | |
| 59 | ||
| 60 | save_token s() { | |
| 61 | [[ -f "$TOKEN_FI LE" ]] && grep -v "$ HOST\t$SIT E\t$ACCESS _CODE\t$VE RIFY_CODE" "$TOKEN_F ILE" > "${ TOKEN_FILE }.new" | |
| 62 | echo - e "$HOST\t $SITE\t$AC CESS_CODE\ t$VERIFY_C ODE\t$JWT\ t$COOKIE\t $EXPIRES" >> "${TOKE N_FILE}.ne w" | |
| 63 | mv "${ TOKEN_FILE }.new" "$T OKEN_FILE" | |
| 64 | } | |
| 65 | ||
| 66 | tokens_rea dy() { | |
| 67 | [[ $(( ${EXPIRES :-0} - $(d ate +%s) ) ) -ge 60 ] ] | |
| 68 | } | |
| 69 | ||
| 70 | tokens_rea dy || acqu ire_tokens | |
| 71 | ||
| 72 | curl "${OT HER_ARGUME NTS[@]/#/} " --cookie "$COOKIE" -H "Autho rization: Bearer $JW T" "$URL" | |
| 73 | echo |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.