Skip to content

Commit

Permalink
Update midway.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
64rl0 authored Jan 12, 2025
1 parent 8dc506f commit c61d176
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions plugins/tmux-midway/scripts/midway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ mw_cookie() {
local time_remaining_sec=$((expiry_timestamp - now_timestamp))
local time_remaining_min=$((time_remaining_sec / 60))

# AEA COOKIE
if [[ "${cookie_name}" == "amazon_enterprise_access" ]]; then
# AWS
if [[ "${cookie_domain}" =~ midway-auth.amazon.com ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
Expand All @@ -45,6 +47,16 @@ mw_cookie() {
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# CN
if [[ "${cookie_domain}" =~ midway-auth.aws-border.cn ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-CN ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]AEA-CN $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-CN ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-NCL
elif [[ "${cookie_domain}" =~ auth.midway.csphome.adc-e.uk ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-NCL ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
Expand All @@ -53,8 +65,46 @@ mw_cookie() {
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-NCL ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-LCK
elif [[ "${cookie_domain}" =~ midway-auth.sc2s.sgov.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-LCK ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]AEA-LCK $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-LCK ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-ALE
elif [[ "${cookie_domain}" =~ auth.midway.csphome.hci.ic.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-ALE ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]AEA-ALE $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-ALE ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-ITAR
elif [[ "${cookie_domain}" =~ midway-auth-itar.amazon.com ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-ITAR ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]AEA-ITAR $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-ITAR ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-DCA
elif [[ "${cookie_domain}" =~ midway-auth.c2s.ic.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]AEA-DCA ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]AEA-DCA $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]AEA-DCA ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
fi
# MIDWAY COOKIE
elif [[ "${cookie_name}" == "session" ]]; then
# AWS
if [[ "${cookie_domain}" =~ midway-auth.amazon.com ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
Expand All @@ -63,6 +113,16 @@ mw_cookie() {
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# CN
elif [[ "${cookie_domain}" =~ midway-auth.aws-border.cn ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-CN ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]MW-CN $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-CN ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-NCL
elif [[ "${cookie_domain}" =~ auth.midway.csphome.adc-e.uk ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-NCL ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
Expand All @@ -71,6 +131,42 @@ mw_cookie() {
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-NCL ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-LCK
elif [[ "${cookie_domain}" =~ midway-auth.sc2s.sgov.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-LCK ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]MW-LCK $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-LCK ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-ALE
elif [[ "${cookie_domain}" =~ auth.midway.csphome.hci.ic.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-ALE ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]MW-ALE $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-ALE ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-ITAR
elif [[ "${cookie_domain}" =~ midway-auth-itar.amazon.com ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-ITAR ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]MW-ITAR $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-ITAR ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
# ADC-DCA
elif [[ "${cookie_domain}" =~ midway-auth.c2s.ic.gov ]]; then
if [[ "${time_remaining_sec}" -gt "${secs_for_expiring}" ]]; then
mw_cookie_text+="#[fg=$mw_cookie_valid_color_fg,bg=$mw_cookie_valid_color_bg]MW-DCA ✔#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le "${secs_for_expiring}" && "${time_remaining_sec}" -gt 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expiring_color_fg,bg=$mw_cookie_expiring_color_bg]MW-DCA $time_remaining_min#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
elif [[ "${time_remaining_sec}" -le 0 ]]; then
mw_cookie_text+="#[fg=$mw_cookie_expired_color_fg,bg=$mw_cookie_expired_color_bg]MW-DCA ✖#[fg=$mw_cookie_color_end_fg,bg=$mw_cookie_color_end_bg] "
fi
fi
fi
done <"${HOME}/.midway/cookie" || printf 'NOT-FOUND'
Expand Down

0 comments on commit c61d176

Please sign in to comment.