diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-22 15:59:10 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-22 15:59:10 +0800 |
commit | 8b8e2ea050458e976e00059dd50ee7ba9ff7ab3b (patch) | |
tree | a61265a734a0010621b1c5c70d9e79ab289aec6f /sessiontoken.h | |
parent | df4c72aba93f9a9bed7fdd181c128f58649995da (diff) |
Merge sessiontoken.h
Diffstat (limited to 'sessiontoken.h')
-rw-r--r-- | sessiontoken.h | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/sessiontoken.h b/sessiontoken.h deleted file mode 100644 index cff077c..0000000 --- a/sessiontoken.h +++ /dev/null @@ -1,37 +0,0 @@ -#include <l8w8jwt/decode.h> - -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(¶ms); - params.alg = L8W8JWT_ALG_HS256; - params.jwt = (char *)token; - params.jwt_length = strlen(token); - 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 *)api_key; - - enum l8w8jwt_validation_result validation; - struct l8w8jwt_claim *claims; - size_t claims_len; - int decode = l8w8jwt_decode(¶ms, &validation, &claims, &claims_len); - - struct l8w8jwt_claim *dest - = l8w8jwt_get_claim(claims, claims_len, "dest", 4); - _Bool iss_isvalid = !strncmp(dest->value, - l8w8jwt_get_claim(claims, claims_len, "iss", 3)->value, - dest->value_length); - if (validation != L8W8JWT_NBF_FAILURE) - printf("nbf invalid\n"); - printf("JWT payload sub: %s\n", - l8w8jwt_get_claim(claims, claims_len, "sub", 3)->value); - l8w8jwt_free_claims(claims, claims_len); - - return decode == L8W8JWT_SUCCESS - && (validation == L8W8JWT_VALID - || validation == L8W8JWT_NBF_FAILURE) - && iss_isvalid; -} |