-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1830 from amazeeio/python-jwt
Re-implement JWT generation script using pyjwt
- Loading branch information
Showing
17 changed files
with
52 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
FROM alpine:3.11 | ||
|
||
RUN apk add --no-cache mysql-client tini openssl bash wget curl nodejs nodejs-npm \ | ||
&& npm config set unsafe-perm true \ | ||
&& npm -g install jwtgen | ||
RUN apk add --no-cache tini bash wget py3-jwt | ||
|
||
ENV JWTSECRET=super-secret-string \ | ||
JWTAUDIENCE=api.dev | ||
|
||
COPY api-watch-push.sh create_jwt.sh /home/ | ||
COPY api-watch-push.sh create_jwt.py /home/ | ||
|
||
CMD ["tini", "--", "/home/api-watch-push.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import jwt | ||
|
||
payload = {'role': 'admin', 'iss': 'api-data-watcher-pusher', | ||
'aud': os.environ['JWTAUDIENCE'], 'sub': 'api-data-watcher-pusher'} | ||
|
||
print(jwt.encode(payload, os.environ['JWTSECRET'], algorithm='HS256').decode()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import jwt | ||
|
||
payload = {'role': 'admin', 'iss': 'auto-idler', | ||
'aud': os.environ['JWTAUDIENCE'], 'sub': 'auto-idler'} | ||
|
||
print(jwt.encode(payload, os.environ['JWTSECRET'], algorithm='HS256').decode()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import jwt | ||
from datetime import datetime, timezone, timedelta | ||
|
||
iat = datetime.now(timezone.utc) | ||
exp = iat + timedelta(minutes=1) | ||
payload = {'exp': exp, 'iat': iat, 'role': 'admin', 'aud': os.environ['JWTAUDIENCE'], 'sub': 'ssh'} | ||
|
||
print(jwt.encode(payload, os.environ['JWTSECRET'], algorithm='HS256').decode()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import jwt | ||
|
||
payload = {'role': 'admin', 'iss': 'storage-calculator', | ||
'aud': os.environ['JWTAUDIENCE'], 'sub': 'storage-calculator'} | ||
|
||
print(jwt.encode(payload, os.environ['JWTSECRET'], algorithm='HS256').decode()) |
This file was deleted.
Oops, something went wrong.