Skip to content

Commit

Permalink
Add jwt-decode utility command (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Monska85 authored Oct 2, 2022
1 parent 38a19e2 commit 49fc8a4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.vscode
/.idea
/config/*.yaml
pkglist.txt
4 changes: 2 additions & 2 deletions playbooks/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Add user to docker group
user:
name: '{{ system.username }}'
name: "{{ system.username }}"
groups: docker
append: yes

Expand All @@ -24,7 +24,7 @@

- name: Configure systemd-resolved to play well with dnsdock
copy:
dest: '/etc/systemd/resolved.conf.d/docker-dev-dns.conf'
dest: "/etc/systemd/resolved.conf.d/docker-dev-dns.conf"
content: |
[Resolve]
DNS=172.17.0.1
Expand Down
29 changes: 29 additions & 0 deletions playbooks/roles/sparkfabrik/files/bin/jwt-decode
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

if [ -z "${1}" ]; then
echo "Usage: ${0} <jwt> [piece]"
exit 1
fi

PIECE=2
if [ -n "${2}" ]; then
PIECE="${2}"
fi

if [ "${PIECE}" != "1" ] && [ "${PIECE}" != "2" ] && [ "${PIECE}" != "3" ]; then
echo "The piece option must be 1, 2, or 3"
echo "Usage: ${0} <jwt> [piece]"
exit 2
fi

decode_base64_url() {
len=$((${#1} % 4))
result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
# echo "$result" | tr '_-' '/+' | openssl enc -d -base64
echo "$result" | tr '_-' '/+' | base64 -d
}

decode_base64_url "$(echo "${1}" | cut -d "." -f "${PIECE}")"
42 changes: 24 additions & 18 deletions playbooks/roles/sparkfabrik/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
tags: [vendor, sparkfabrik]
when: sparkfabrik | default(false)
block:
- name: Install wallpapers
synchronize:
src: wallpapers/
dest: /usr/share/backgrounds/sparkfabrik
delete: no
recursive: yes
- name: Install wallpapers
synchronize:
src: wallpapers/
dest: /usr/share/backgrounds/sparkfabrik
delete: no
recursive: yes

- name: Install wallpapers xml
copy:
src: gnome-spark-wallpapers.xml
dest: /usr/share/gnome-background-properties

- name: Copy ayse-get-sm binary to print serial-number
copy:
src: "bin/ayse-get-sm"
dest: /usr/local/bin/ayse-get-sm
force: yes
mode: u+rwx,g-wx,o-rwx
owner: "{{ system.username }}"
- name: Install wallpapers xml
copy:
src: gnome-spark-wallpapers.xml
dest: /usr/share/gnome-background-properties

- name: Copy ayse-get-sm binary to print serial-number
copy:
src: "bin/ayse-get-sm"
dest: /usr/local/bin/ayse-get-sm
force: yes
mode: u+rwx,g-wx,o-rwx
owner: "{{ system.username }}"

- name: Copy jwt-decode script
copy:
src: "bin/jwt-decode"
dest: /usr/local/bin/jwt-decode
force: yes
mode: u+rwx,g-wx,o-rwx
owner: "{{ system.username }}"

0 comments on commit 49fc8a4

Please sign in to comment.