Skip to content

Instantly share code, notes, and snippets.

@novotnyr
Created November 29, 2016 14:19
Show Gist options
  • Save novotnyr/0db0f0c7a32e17e47404adf373f2baee to your computer and use it in GitHub Desktop.
Save novotnyr/0db0f0c7a32e17e47404adf373f2baee to your computer and use it in GitHub Desktop.
redis-cli utility to handle Spring Security / Spring Session sessions
#!/bin/sh
COMMAND="$1"
REDIS_CLI="redis-cli"
case "$COMMAND" in
list)
"$REDIS_CLI" keys 'spring:session:sessions:[a-f0-9][a-f0-9]*'
;;
hkeys)
if [ -z "$2" ]; then
echo "Missing session UUID"
exit 1
fi
"$REDIS_CLI" hkeys 'spring:session:sessions:'"$2"
;;
context)
if [ -z "$2" ]; then
echo "Missing session UUID"
exit 1
fi
"$REDIS_CLI" hget 'spring:session:sessions:'"$2" "sessionAttr:SPRING_SECURITY_CONTEXT"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment