summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-20 08:40:16 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-20 08:40:16 +0800
commit48247900f53f3668f2eb28f9a74c99ffdf65b837 (patch)
treefb5de6b7f77ec3c48d418f43ac6b22a664b43d65
parent6f272634eb23bf3e28009156d271393766da81b6 (diff)
Validate iss though won't be valid yet
Rename vars for consistency.
-rw-r--r--sessiontoken.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/sessiontoken.h b/sessiontoken.h
index 8069ba9..45ee463 100644
--- a/sessiontoken.h
+++ b/sessiontoken.h
@@ -1,19 +1,20 @@
#include <l8w8jwt/decode.h>
-static inline bool sessiontoken_isvalid(const char *token, const char *key,
- const char *secret_key, const char *shop)
+static inline bool sessiontoken_isvalid(const char *token, const char *api_key,
+ const char *api_secret_key, const char *shop)
{
struct l8w8jwt_decoding_params params;
l8w8jwt_decoding_params_init(&params);
params.alg = L8W8JWT_ALG_HS256;
params.jwt = (char *)token;
params.jwt_length = strlen(token);
- params.verification_key = (unsigned char *)secret_key;
- params.verification_key_length = strlen(secret_key);
+ params.verification_key = (unsigned char *)api_secret_key;
+ params.verification_key_length = strlen(api_secret_key);
params.validate_exp = 1;
params.validate_nbf = 1;
- params.validate_aud = (char *)key;
+ params.validate_iss = (char *)shop;
+ params.validate_aud = (char *)api_key;
enum l8w8jwt_validation_result validation;
- int decode = l8w8jwt_decode(&params, &validation, NULL,NULL);
+ int decode = l8w8jwt_decode(&params, &validation, NULL, NULL);
return decode == L8W8JWT_SUCCESS && validation == L8W8JWT_VALID;
}