Skip to content

Commit

Permalink
Merge pull request #51 from DrDaveD/add-htdestroytoken
Browse files Browse the repository at this point in the history
Add htdestroytoken, htdecodetoken symlink, and update to 1.16
  • Loading branch information
DrDaveD authored Oct 12, 2022
2 parents 1bd4e7e + 026850a commit 9abaea0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
25 changes: 25 additions & 0 deletions htdestroytoken
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

VERBOSE=true
if [ "$1" = "-q" ]; then
VERBOSE=false
shift
fi

if [ $# != 0 ]; then
echo "Usage: htdestroytoken [-q]" >&2
echo "Removes bearer and vault tokens" >&2
echo "-q means to do it silently" >&2
exit 2
fi

# UID is a standard bash variable
TOKENFILE="${BEARER_TOKEN_FILE:-${XDG_RUNTIME_DIR:-/tmp}/bt_u$UID}"
for FILE in $TOKENFILE /tmp/vt_u$UID*; do
if [ -f "$FILE" ]; then
if $VERBOSE; then
echo "Removing $FILE"
fi
rm -f $FILE
fi
done
2 changes: 1 addition & 1 deletion htgettoken
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from __future__ import print_function

prog = "htgettoken"
version = "1.15"
version = "1.16"

import os
import sys
Expand Down
13 changes: 9 additions & 4 deletions htgettoken.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Summary: Get OIDC bearer tokens by interacting with Hashicorp vault
Name: htgettoken
Version: 1.15
Version: 1.16
Release: 1%{?dist}
License: BSD
Group: Applications/System
Expand Down Expand Up @@ -104,7 +104,9 @@ cat > $RPM_BUILD_ROOT%{_bindir}/%{name} <<'!EOF!'
#!/bin/bash
exec %{_libexecdir}/%{name}/%{name} "$@"
!EOF!
cp htdestroytoken $RPM_BUILD_ROOT%{_bindir}
cp httokendecode $RPM_BUILD_ROOT%{_bindir}
ln -s httokendecode $RPM_BUILD_ROOT%{_bindir}/htdecodetoken
chmod +x $RPM_BUILD_ROOT%{_bindir}/*
gzip -c %{name}.1 >$RPM_BUILD_ROOT%{_datadir}/man/man1/%{name}.1.gz

Expand All @@ -122,9 +124,12 @@ rm -rf $RPM_BUILD_ROOT


%changelog
# Fix httokendecode -H functionality to only attempt to convert a parsed word
# if it is entirely numeric, not if it just contains one digit. At the same
# time, rewrite the functionality in native bash instead of using grep and sed.
* Wed Oct 12 2022 Dave Dykstra <dwd@fnal.gov> 1.16-1
- Fix httokendecode -H functionality to only attempt to convert a parsed word
if it is entirely numeric, not if it just contains one digit. At the same
time, rewrite the functionality in native bash instead of using grep and sed.
- Add htdestroytoken command.
- Add a symlink htdecodetoken pointing to httokendecode.

* Thu Jun 16 2022 Dave Dykstra <dwd@fnal.gov> 1.15-1
- Revert to prior method for allowing --vaultalias as an alternate name
Expand Down

0 comments on commit 9abaea0

Please sign in to comment.