struct afb_session *next; /**< link to the next */
unsigned refcount; /**< count of reference to the session */
int timeout; /**< timeout of the session */
- time_t expiration; /**< expiration time of the token */
+ time_t expiration; /**< expiration time of the session */
pthread_mutex_t mutex; /**< mutex of the session */
struct cookie *cookies[COOKIECOUNT]; /**< cookies of the session */
char *lang; /**< current language setting for the session */
uint8_t closed: 1; /**< is the session closed ? */
uint8_t autoclose: 1; /**< close the session when unreferenced */
uint8_t notinset: 1; /**< session removed from the set of sessions */
- uuid_stringz_t uuid; /**< long term authentication of remote client */
- struct afb_token *token;/**< short term authentication of remote client */
+ uuid_stringz_t uuid; /**< indentification of client seesion */
};
/**
afb_hook_session_destroy(session);
#endif
pthread_mutex_destroy(&session->mutex);
- afb_token_unref(session->token);
free(session->lang);
free(session);
}
pthread_mutex_init(&session->mutex, NULL);
session->refcount = 1;
strcpy(session->uuid, uuid);
- session->token = afb_token_addref(sessions.initok);
session->timeout = timeout;
session_update_expiration(session, now);
/* add */
if (sessionset_add(session, hashidx)) {
- afb_token_unref(session->token);
free(session);
return NULL;
}
* @param max_session_count maximum allowed session count in the same time
* @param timeout the initial default timeout of sessions
* @param initok the initial default token of sessions
- *
*/
int afb_session_init (int max_session_count, int timeout, const char *initok)
{
return session->closed;
}
-/*
- * check whether the token of 'session' is 'token'
- * return 1 if true or 0 otherwise
- */
-int afb_session_check_token (struct afb_session *session, const char *token)
-{
- int r;
-
- session_lock(session);
- r = !session->closed
- && session->expiration >= NOW
- && !(session->token && strcmp(token, afb_session_token(session)));
- session_unlock(session);
- 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)
{
return session->uuid;
}
-/* Returns the token of 'session' */
-const char *afb_session_token (struct afb_session *session)
-{
- return afb_token_string(session->token);
-}
-
/**
* Get the index of the 'key' in the cookies array.
* @param key the key to scan