summaryrefslogtreecommitdiff
path: root/create-token
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-10-29 09:48:08 +0200
committerLars Wirzenius <liw@liw.fi>2018-10-29 09:48:08 +0200
commit0d00065bfff93d025c41cb96a26988c8d1d38e8a (patch)
tree3467c1874ceab7fa31958273bf47c6c49fc593e4 /create-token
parent8f5c7b0fc2b273e55b2116ddece21ac2c19fa863 (diff)
downloadmuck-poc-0d00065bfff93d025c41cb96a26988c8d1d38e8a.tar.gz
Add: script to benchmark http API over localhost
Diffstat (limited to 'create-token')
-rwxr-xr-xcreate-token44
1 files changed, 44 insertions, 0 deletions
diff --git a/create-token b/create-token
new file mode 100755
index 0000000..7496f97
--- /dev/null
+++ b/create-token
@@ -0,0 +1,44 @@
+#!/usr/bin/python3
+# Copyright (C) 2017 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import sys
+import time
+
+import Crypto.PublicKey.RSA
+
+import apifw
+
+key_text = sys.stdin.read()
+key = Crypto.PublicKey.RSA.importKey(key_text)
+
+iss = 'test-issuer'
+aud = 'test-audience'
+sub = 'test-subject'
+scope = 'create update show delete'
+lifetime = 24 * 60 * 60
+
+now = time.time()
+claims = {
+ 'iss': iss,
+ 'sub': sub,
+ 'aud': aud,
+ 'exp': now + lifetime,
+ 'scope': scope,
+}
+
+token = apifw.create_token(claims, key)
+sys.stdout.write(token.decode('ascii'))