summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accesstoken.h4
-rw-r--r--base64.h2
-rw-r--r--crypt.h2
-rw-r--r--session.h2
-rw-r--r--shopify.c21
-rw-r--r--shopify.h2
6 files changed, 16 insertions, 17 deletions
diff --git a/accesstoken.h b/accesstoken.h
index 009cdb0..31d0d29 100644
--- a/accesstoken.h
+++ b/accesstoken.h
@@ -18,8 +18,8 @@ static inline void accesstoken_parse(const char *tok,
"scope")) {
const char *val = json_object_get_string(
json_object_iter_peek_value(&iter));
- session->scope = malloc(strlen(val) + 1);
- strcpy(session->scope, val);
+ session->scopes = malloc(strlen(val) + 1);
+ strcpy(session->scopes, val);
}
json_object_iter_next(&iter);
}
diff --git a/base64.h b/base64.h
index 3b9c3bd..0ee9378 100644
--- a/base64.h
+++ b/base64.h
@@ -1,6 +1,6 @@
#include <gnutls/gnutls.h>
-static inline void base64_decode(const char *host, char **dec_host)
+static inline void base64_getdecoded(const char *host, char **dec_host)
{
gnutls_datum_t result;
gnutls_base64_decode2(&(gnutls_datum_t){
diff --git a/crypt.h b/crypt.h
index 9ae3038..7e7ea29 100644
--- a/crypt.h
+++ b/crypt.h
@@ -5,7 +5,7 @@ static inline void crypt_init()
gcry_check_version("1.9.4");
}
-static inline bool crypt_maccmp(const char *key, const char *query,
+static inline bool crypt_macmatch(const char *key, const char *query,
const char *hmac)
{
gcry_mac_hd_t hd;
diff --git a/session.h b/session.h
index d306bcc..c6bf6e3 100644
--- a/session.h
+++ b/session.h
@@ -2,5 +2,5 @@ struct shopify_session {
char *shop;
char *nonce;
char *access_token;
- char *scope;
+ char *scopes;
};
diff --git a/shopify.c b/shopify.c
index 5c716f1..0ca2627 100644
--- a/shopify.c
+++ b/shopify.c
@@ -45,10 +45,10 @@
#define EMBEDDED_URL_LEN strlen(EMBEDDED_URL) - strlen("%s") * 2
extern inline void crypt_init();
-extern inline bool crypt_maccmp(const char *, const char *, const char *);
+extern inline bool crypt_macmatch(const char *, const char *, const char *);
extern inline void crypt_getnonce(char [], const size_t);
extern inline bool regex_match(const char *);
-extern inline void base64_decode(const char *, char **);
+extern inline void base64_getdecoded(const char *, char **);
extern inline void config_getscopes(const char *, char **);
extern inline void request_init();
extern inline void request_gettoken(const char *, const char *, const char *,
@@ -70,7 +70,7 @@ struct container {
const char *app_url;
const char *redir_url;
const char *app_id;
- const char *scope;
+ const char *scopes;
const char *index;
const struct shopify_api *apis;
struct shopify_session *sessions;
@@ -204,7 +204,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
sizeof(struct parameter),
keycmp)))
hmac = param->val;
- if (!hmac || !crypt_maccmp(secret_key, query, hmac)) {
+ if (!hmac || !crypt_macmatch(secret_key, query, hmac)) {
free(query);
clear(params);
free(params);
@@ -260,7 +260,6 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
shop_len = sizeof(char) * (next - pair);
shop = malloc(shop_len + 1);
strlcpy(shop, pair, shop_len + 1);
- printf("Shop: %s\n", shop);
free(tofree);
if (!regex_match(shop) || !sessiontoken_isvalid(session_token,
secret_key)) {
@@ -281,7 +280,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
param = bsearch(&(struct parameter){ "embedded" }, params,
nparams, sizeof(struct parameter), keycmp);
embedded = param && !strcmp(param->val, "1");
- base64_decode(host, &dec_host);
+ base64_getdecoded(host, &dec_host);
}
const char *key = container->key;
const size_t key_len = strlen(key);
@@ -345,7 +344,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
} else {
const size_t dec_host_len = strlen(dec_host);
char *scopes = NULL;
- config_getscopes(container->scope, &scopes);
+ config_getscopes(container->scopes, &scopes);
const size_t scopes_len = strlen(scopes);
static const size_t nonce_len = 64;
char nonce[nonce_len + 1];
@@ -391,7 +390,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
void shopify_app(const char *api_key, const char *api_secret_key,
const char *app_url, const char *redir_url, const char *app_id,
- const char *scope, const char *index,
+ const char *scopes, const char *index,
const struct shopify_api apis[])
{
crypt_init();
@@ -407,7 +406,7 @@ void shopify_app(const char *api_key, const char *api_secret_key,
app_url,
redir_url,
app_id,
- scope,
+ scopes,
index,
apis,
sessions
@@ -416,8 +415,8 @@ void shopify_app(const char *api_key, const char *api_secret_key,
MHD_stop_daemon(daemon);
int i = 0;
while (sessions[i].shop) {
- if (sessions[i].scope)
- free(sessions[i].scope);
+ if (sessions[i].scopes)
+ free(sessions[i].scopes);
if (sessions[i].access_token)
free(sessions[i].access_token);
free(sessions[i].nonce);
diff --git a/shopify.h b/shopify.h
index 02ac22a..39f620c 100644
--- a/shopify.h
+++ b/shopify.h
@@ -16,7 +16,7 @@ extern "C" {
void shopify_app(const char *api_key, const char *api_secret_key,
const char *app_url, const char *redir_url, const char *app_id,
- const char *scope, const char *index,
+ const char *scopes, const char *index,
const struct shopify_api apis[]);
void shopify_graphql(const char *query, const struct shopify_session *session,
char **json);