From 1cbe0c35450d372a9363f2d18f41bc1bbd6b6491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Sun, 7 Nov 2021 23:50:58 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c9950cd..d20fd1a 100644 --- a/README.md +++ b/README.md @@ -3,28 +3,28 @@ JSON Web Token library for Godot Engine written in GDScript ## Create JWT ```gdscript - var secret: String = "" - var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret) - var jwt: String = JWT.create() \ - .with_expires_at(OS.get_unix_time()) \ - .with_issuer("Godot") \ - .with_claim("id","someid").sign(jwt_algorithm) - print(jwt) +var secret: String = "" +var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret) +var jwt: String = JWT.create() \ +.with_expires_at(OS.get_unix_time()) \ +.with_issuer("Godot") \ +.with_claim("id","someid").sign(jwt_algorithm) +print(jwt) ``` ## Decode a JWT ```gdscript - var jwt: String = "" - var jwt_decoder : JWTDecoder = JWT.decode(jwt) - print("%s.%s.%s" % jwt_decoder.parts) +var jwt: String = "" +var jwt_decoder : JWTDecoder = JWT.decode(jwt) +print("%s.%s.%s" % jwt_decoder.parts) ``` ## Verify JWT ```gdscript - var jwt: String = "" - var secret: String = "" - var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret) - var jwt_verification: int = JWT.require(jwt_algorithm).verify(jwt) - if jwt_verification == JWTVerifier.Exceptions.OK : - print("Verified!") -``` \ No newline at end of file +var jwt: String = "" +var secret: String = "" +var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret) +var jwt_verification: int = JWT.require(jwt_algorithm).verify(jwt) +if jwt_verification == JWTVerifier.Exceptions.OK : + print("Verified!") +``` From ee69737107d75cf15b2a3f751d27eb0cb18de449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Sun, 7 Nov 2021 23:57:02 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d20fd1a..4c7c813 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,5 @@ var jwt_verification: int = JWT.require(jwt_algorithm).verify(jwt) if jwt_verification == JWTVerifier.Exceptions.OK : print("Verified!") ``` + +You can also verify a GDScript created JWT [here](https://jwt.io/) From 6b2702281ab47e98085bba3fdd47acd2e8ccda4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Sun, 7 Nov 2021 23:58:33 +0100 Subject: [PATCH 3/3] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..45a44b7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Nicolò Santilio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.