Created
October 9, 2024 15:19
-
-
Save TheLexoPlexx/dc6679e6d93591ca0d4df40335006cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import jwt, time, sys | |
| if len(sys.argv) < 2: | |
| print(" ") | |
| print("Error: Missing secret") | |
| print("Usage: python3 supabase_jwt.py <secret>") | |
| print(" ") | |
| sys.exit(1) | |
| issued_at_timestamp = int(time.time()) | |
| expiry_timestamp = issued_at_timestamp + (2 * 365 * 24 * 60 * 60) # 2 years | |
| print("issued_at", issued_at_timestamp) | |
| print("expires", expiry_timestamp) | |
| payload_anon = { | |
| "role": "anon", | |
| "iss": "supabase", | |
| "iat": issued_at_timestamp, | |
| "exp": expiry_timestamp | |
| } | |
| payload_service_role = { | |
| "role": "service_role", | |
| "iss": "supabase", | |
| "iat": issued_at_timestamp, | |
| "exp": expiry_timestamp | |
| } | |
| secret = sys.argv[1] | |
| encoded_anon = jwt.encode(payload_anon, secret, algorithm="HS256") | |
| encoded_sr = jwt.encode(payload_service_role, secret, algorithm="HS256") | |
| print(" ") | |
| print("JWT_SECRET=" + secret) | |
| print("SERVICE_ROLE_KEY=" + encoded_sr) | |
| print("ANON_KEY=" + encoded_anon) | |
| print(" ") | |
| print("SUPABASE_SERVICE_ROLE_KEY=" + encoded_sr) | |
| print("NEXT_PUBLIC_SUPABASE_ANON_KEY=" + encoded_anon) | |
| print(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment