Skip to content
Snippets Groups Projects
Commit 1cb9db95 authored by ale's avatar ale
Browse files

Fix deserialization of expiry field

The expiration timestamp was added to the current time upon
deserialization, as if it were an offset. Fix the ambiguity in the
internal API.
parent 807724d6
No related branches found
No related tags found
No related merge requests found
......@@ -60,19 +60,26 @@ static char *strdup_or_null(const char *s) {
return strdup(s);
}
sso_ticket_t sso_ticket_new(const char *user, const char *service,
static sso_ticket_t sso_ticket_new_with_expiry(const char *user, const char *service,
const char *domain, const char *nonce,
const char **groups, int validity_seconds) {
const char **groups, time_t expires) {
sso_ticket_t t = (sso_ticket_t)malloc(sizeof(struct sso_ticket));
t->user = strdup_or_null(user);
t->service = strdup_or_null(service);
t->domain = strdup_or_null(domain);
t->nonce = strdup_or_null(nonce);
t->groups = group_list_dup(groups);
t->expires = time(NULL) + validity_seconds;
t->expires = expires;
return t;
}
sso_ticket_t sso_ticket_new(const char *user, const char *service,
const char *domain, const char *nonce,
const char **groups, int validity_seconds) {
time_t expires = time(NULL) + validity_seconds;
return sso_ticket_new_with_expiry(user, service, domain, nonce, groups, expires);
}
void sso_ticket_free(sso_ticket_t t) {
if (t->user != NULL) {
free(t->user);
......@@ -275,7 +282,7 @@ static int sso_ticket_deserialize(sso_ticket_t *t, const char *s, int sz) {
goto fail;
}
*t = sso_ticket_new(user, service, domain, nonce, (const char **)groups, expires);
*t = sso_ticket_new_with_expiry(user, service, domain, nonce, (const char **)groups, expires);
fail:
if (version != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment