summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2019-11-15 15:33:26 +0100
committerJose Bollo <jose.bollo@iot.bzh>2019-11-25 11:48:31 +0100
commit0d3dc9722c610857c2f83c4f3bf06299f2426a95 (patch)
tree5d2a8b950e32d5ca61b73ffe17266f0d9c5e5aac
parente6908a2ee7b645517c062f2fd0419fcb3f4f976e (diff)
Remove refreshing token
The token is no more generated by the binder but by some external component. Bug-AGL: SPEC-2968 Change-Id: I2c6221034272ab097e21e7727e4840b6b47bd0dc Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-context.c25
-rw-r--r--src/afb-context.h3
-rw-r--r--src/afb-hook-flags.c1
-rw-r--r--src/afb-hook.c11
-rw-r--r--src/afb-hook.h10
-rw-r--r--src/afb-monitor.c7
-rw-r--r--src/afb-session.c23
-rw-r--r--src/afb-session.h1
-rw-r--r--src/afb-trace.c6
-rw-r--r--src/afb-xreq.c6
-rw-r--r--src/tests/session/test-session.c6
11 files changed, 3 insertions, 96 deletions
diff --git a/src/afb-context.c b/src/afb-context.c
index 6057e69d..33cca0e9 100644
--- a/src/afb-context.c
+++ b/src/afb-context.c
@@ -77,7 +77,6 @@ int afb_context_connect(struct afb_context *context, const char *uuid, const cha
init_context(context, session, token);
if (created) {
context->created = 1;
- /* context->refreshing = 1; */
}
return 0;
}
@@ -93,10 +92,6 @@ int afb_context_connect_validated(struct afb_context *context, const char *uuid)
void afb_context_disconnect(struct afb_context *context)
{
if (context->session && !context->super) {
- if (context->refreshing && !context->refreshed) {
- afb_session_new_token (context->session);
- context->refreshed = 1;
- }
if (context->closing && !context->closed) {
afb_context_change_loa(context, 0);
afb_context_set(context, NULL, NULL);
@@ -111,12 +106,6 @@ const char *afb_context_sent_token(struct afb_context *context)
{
if (context->session == NULL || context->closing || context->super)
return NULL;
- if (!context->refreshing)
- return NULL;
- if (!context->refreshed) {
- afb_session_new_token (context->session);
- context->refreshed = 1;
- }
return afb_session_token(context->session);
}
@@ -157,20 +146,6 @@ void afb_context_close(struct afb_context *context)
context->closing = 1;
}
-void afb_context_refresh(struct afb_context *context)
-{
- if (context->super)
- afb_context_refresh(context->super);
- else {
- assert(context->validated);
- context->refreshing = 1;
- if (!context->refreshed) {
- afb_session_new_token (context->session);
- context->refreshed = 1;
- }
- }
-}
-
int afb_context_check(struct afb_context *context)
{
if (context->super)
diff --git a/src/afb-context.h b/src/afb-context.h
index 21af4b23..2d44611b 100644
--- a/src/afb-context.h
+++ b/src/afb-context.h
@@ -32,8 +32,6 @@ struct afb_context
unsigned created: 1;
unsigned validated: 1;
unsigned invalidated: 1;
- unsigned refreshing: 1;
- unsigned refreshed: 1;
unsigned closing: 1;
unsigned closed: 1;
};
@@ -55,7 +53,6 @@ extern int afb_context_set(struct afb_context *context, void *value, void (*free
extern void *afb_context_make(struct afb_context *context, int replace, void *(*make_value)(void *closure), void (*free_value)(void *item), void *closure);
extern void afb_context_close(struct afb_context *context);
-extern void afb_context_refresh(struct afb_context *context);
extern int afb_context_check(struct afb_context *context);
extern int afb_context_check_loa(struct afb_context *context, unsigned loa);
extern int afb_context_change_loa(struct afb_context *context, unsigned loa);
diff --git a/src/afb-hook-flags.c b/src/afb-hook-flags.c
index 874d21b6..9a7cf6e9 100644
--- a/src/afb-hook-flags.c
+++ b/src/afb-hook-flags.c
@@ -140,7 +140,6 @@ static struct flag session_flags[] = { /* must be sorted by names */
{ "common", afb_hook_flags_session_common },
{ "create", afb_hook_flag_session_create },
{ "destroy", afb_hook_flag_session_destroy },
- { "renew", afb_hook_flag_session_renew },
{ "unref", afb_hook_flag_session_unref },
};
diff --git a/src/afb-hook.c b/src/afb-hook.c
index f8b593df..6b1ab10c 100644
--- a/src/afb-hook.c
+++ b/src/afb-hook.c
@@ -1544,11 +1544,6 @@ static void hook_session_destroy_cb(void *closure, const struct afb_hookid *hook
_hook_session_(session, "destroy");
}
-static void hook_session_renew_cb(void *closure, const struct afb_hookid *hookid, struct afb_session *session)
-{
- _hook_session_(session, "renew -> token=%s", afb_session_token(session));
-}
-
static void hook_session_addref_cb(void *closure, const struct afb_hookid *hookid, struct afb_session *session)
{
_hook_session_(session, "addref");
@@ -1563,7 +1558,6 @@ static struct afb_hook_session_itf hook_session_default_itf = {
.hook_session_create = hook_session_create_cb,
.hook_session_close = hook_session_close_cb,
.hook_session_destroy = hook_session_destroy_cb,
- .hook_session_renew = hook_session_renew_cb,
.hook_session_addref = hook_session_addref_cb,
.hook_session_unref = hook_session_unref_cb
};
@@ -1605,11 +1599,6 @@ void afb_hook_session_destroy(struct afb_session *session)
_HOOK_SESSION_(destroy, session);
}
-void afb_hook_session_renew(struct afb_session *session)
-{
- _HOOK_SESSION_(renew, session);
-}
-
void afb_hook_session_addref(struct afb_session *session)
{
_HOOK_SESSION_(addref, session);
diff --git a/src/afb-hook.h b/src/afb-hook.h
index 9131621c..290bf746 100644
--- a/src/afb-hook.h
+++ b/src/afb-hook.h
@@ -415,12 +415,10 @@ extern void afb_hook_unref_evt(struct afb_hook_evt *hook);
#define afb_hook_flag_session_create 0x000001
#define afb_hook_flag_session_close 0x000002
#define afb_hook_flag_session_destroy 0x000004
-#define afb_hook_flag_session_renew 0x000008
-#define afb_hook_flag_session_addref 0x000010
-#define afb_hook_flag_session_unref 0x000020
+#define afb_hook_flag_session_addref 0x000008
+#define afb_hook_flag_session_unref 0x000010
-#define afb_hook_flags_session_common (afb_hook_flag_session_create|afb_hook_flag_session_close\
- |afb_hook_flag_session_renew)
+#define afb_hook_flags_session_common (afb_hook_flag_session_create|afb_hook_flag_session_close)
#define afb_hook_flags_session_all (afb_hook_flags_session_common|afb_hook_flag_session_destroy\
|afb_hook_flag_session_addref|afb_hook_flag_session_unref)
@@ -428,7 +426,6 @@ struct afb_hook_session_itf {
void (*hook_session_create)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
void (*hook_session_close)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
void (*hook_session_destroy)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
- void (*hook_session_renew)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
void (*hook_session_addref)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
void (*hook_session_unref)(void *closure, const struct afb_hookid *hookid, struct afb_session *session);
};
@@ -436,7 +433,6 @@ struct afb_hook_session_itf {
extern void afb_hook_session_create(struct afb_session *session);
extern void afb_hook_session_close(struct afb_session *session);
extern void afb_hook_session_destroy(struct afb_session *session);
-extern void afb_hook_session_renew(struct afb_session *session);
extern void afb_hook_session_addref(struct afb_session *session);
extern void afb_hook_session_unref(struct afb_session *session);
diff --git a/src/afb-monitor.c b/src/afb-monitor.c
index 15dd1a49..13687d36 100644
--- a/src/afb-monitor.c
+++ b/src/afb-monitor.c
@@ -297,7 +297,6 @@ static struct json_object *get_apis(struct json_object *spec)
static const char _verbosity_[] = "verbosity";
static const char _apis_[] = "apis";
-static const char _refresh_token_[] = "refresh-token";
static void f_get(afb_req_t req)
{
@@ -373,7 +372,6 @@ static void f_trace(afb_req_t req)
static void f_session(afb_req_t req)
{
struct json_object *r = NULL;
- int refresh = 0;
struct afb_xreq *xreq = xreq_from_req_x2(req);
/* check right to call it */
@@ -382,11 +380,6 @@ static void f_session(afb_req_t req)
return;
}
- /* renew the token if required */
- wrap_json_unpack(afb_req_json(req), "{s?:b}", _refresh_token_, &refresh);
- if (refresh)
- afb_context_refresh(&xreq->context);
-
/* make the result */
wrap_json_pack(&r, "{s:s,s:s,s:i,s:i}",
"uuid", afb_session_uuid(xreq->context.session),
diff --git a/src/afb-session.c b/src/afb-session.c
index fe5aa4af..8fa44341 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -545,29 +545,6 @@ int afb_session_check_token (struct afb_session *session, const char *token)
return r;
}
-/* generate a new token and update client context */
-void afb_session_new_token (struct afb_session *session)
-{
- int rc;
- uuid_stringz_t uuid;
- struct afb_token *previous, *next;
- session_lock(session);
- uuid_new_stringz(uuid);
- rc = afb_token_get(&next, uuid);
- if (rc < 0)
- ERROR("can't renew token");
- else {
- previous = session->token;
- session->token = next;
- session_update_expiration(session, NOW);
-#if WITH_AFB_HOOK
- afb_hook_session_renew(session);
-#endif
- afb_token_unref(previous);
- }
- session_unlock(session);
-}
-
/* Returns the uuid of 'session' */
const char *afb_session_uuid (struct afb_session *session)
{
diff --git a/src/afb-session.h b/src/afb-session.h
index 71b1556e..f6e848c8 100644
--- a/src/afb-session.h
+++ b/src/afb-session.h
@@ -41,7 +41,6 @@ extern void afb_session_close(struct afb_session *session);
extern int afb_session_is_closed (struct afb_session *session);
extern int afb_session_check_token(struct afb_session *session, const char *token);
-extern void afb_session_new_token(struct afb_session *session);
extern const char *afb_session_token(struct afb_session *session);
extern int afb_session_timeout(struct afb_session *session);
extern int afb_session_what_remains(struct afb_session *session);
diff --git a/src/afb-trace.c b/src/afb-trace.c
index 0de78da5..5e349c7e 100644
--- a/src/afb-trace.c
+++ b/src/afb-trace.c
@@ -866,11 +866,6 @@ static void hook_session_destroy(void *closure, const struct afb_hookid *hookid,
hook_session(closure, hookid, session, "destroy", NULL);
}
-static void hook_session_renew(void *closure, const struct afb_hookid *hookid, struct afb_session *session)
-{
- hook_session(closure, hookid, session, "renew", "{ss}", "token", afb_session_token(session));
-}
-
static void hook_session_addref(void *closure, const struct afb_hookid *hookid, struct afb_session *session)
{
hook_session(closure, hookid, session, "addref", NULL);
@@ -885,7 +880,6 @@ static struct afb_hook_session_itf hook_session_itf = {
.hook_session_create = hook_session_create,
.hook_session_close = hook_session_close,
.hook_session_destroy = hook_session_destroy,
- .hook_session_renew = hook_session_renew,
.hook_session_addref = hook_session_addref,
.hook_session_unref = hook_session_unref
};
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 17a603c3..85427419 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -760,9 +760,6 @@ static int xreq_session_check_apply_v1(struct afb_xreq *xreq, int sessionflags)
}
}
- if ((sessionflags & AFB_SESSION_RENEW_X1) != 0) {
- afb_context_refresh(&xreq->context);
- }
if ((sessionflags & AFB_SESSION_CLOSE_X1) != 0) {
afb_context_change_loa(&xreq->context, 0);
afb_context_close(&xreq->context);
@@ -798,9 +795,6 @@ static int xreq_session_check_apply_v2(struct afb_xreq *xreq, uint32_t sessionfl
return -1;
}
- if ((sessionflags & AFB_SESSION_REFRESH_X2) != 0) {
- afb_context_refresh(&xreq->context);
- }
if ((sessionflags & AFB_SESSION_CLOSE_X2) != 0) {
afb_context_close(&xreq->context);
}
diff --git a/src/tests/session/test-session.c b/src/tests/session/test-session.c
index fdbb0435..444475ef 100644
--- a/src/tests/session/test-session.c
+++ b/src/tests/session/test-session.c
@@ -61,12 +61,6 @@ START_TEST (check_creation)
ck_assert(afb_session_check_token(s, GOOD_UUID));
ck_assert(afb_session_check_token(s, afb_session_token(s)));
- /* token can be renewed */
- afb_session_new_token(s);
- ck_assert(strcmp(afb_session_token(s), GOOD_UUID));
- ck_assert(!afb_session_check_token(s, GOOD_UUID));
- ck_assert(afb_session_check_token(s, afb_session_token(s)));
-
/* query the session */
uuid = strdup(afb_session_uuid(s));
x = afb_session_search(uuid);