Skip to content

Commit 3984f79

Browse files
committed
no need to cache session expiration in ziti context
1 parent 81092f0 commit 3984f79

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

inc_internal/zt_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ struct ziti_ctx {
183183

184184
// HA access_token(JWT) or legacy ziti_api_session.token
185185
char *session_token;
186-
timestamp session_expiration;
187186

188187
ziti_identity_data *identity_data;
189188

library/ziti.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ void ziti_set_fully_authenticated(ziti_context ztx, const char *session_token) {
392392
ztx->auth_state = ZitiAuthStateFullyAuthenticated;
393393
const struct timeval *exp = ztx->auth_method->expiration(ztx->auth_method);
394394
assert(exp);
395-
ztx->session_expiration = *exp;
396395
if (ztx->auth_method->kind == OIDC) {
397396
ZTX_LOG(VERBOSE, "token%s exp[%lu]", jwt_payload(session_token), (unsigned long)exp->tv_sec);
398397
} else {
@@ -1921,13 +1920,14 @@ static void ztx_prep_deadlines(ziti_context ztx) {
19211920
void ztx_prepare(uv_prepare_t *prep) {
19221921
ziti_context ztx = prep->data;
19231922

1924-
if (ztx->session_token && ztx->session_expiration.tv_sec > 0) {
1923+
if (ztx->session_token) {
1924+
const struct timeval *exp = ztx->auth_method ? ztx->auth_method->expiration(ztx->auth_method) : NULL;
19251925
// session token should be kept upto date by the auth_method,
19261926
// but sometimes it may be expired due to device going to sleep
19271927
// so we want to clear it to avoid any channels getting outdated token
19281928
uv_timeval64_t now;
19291929
uv_gettimeofday(&now);
1930-
if (ztx->session_expiration.tv_sec < now.tv_sec) {
1930+
if (exp == NULL || exp->tv_sec < now.tv_sec) {
19311931
ziti_error error = {
19321932
.err = ZITI_NOT_AUTHORIZED,
19331933
.message = "session token has expired",

0 commit comments

Comments
 (0)