return / branca

Authenticated and encrypted API tokens written in Rust. A secure JWT alternative.

Home Page:https://branca.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Branca builder incorrectly sets timestamp to non-zero on new()

brycx opened this issue · comments

The Branca builder sets the timestamp to the current system time when calling new():

let timestamp = SystemTime::now()

But encode() then checks if it is non-zero. If it is zero, it uses the current system time to encode the token. If it is not zero, it uses the timestamp field of the Branca struct:

if timestamp == 0 {

This means, if an instance of Branca is created at one point, and some given time later is used to encode a token, the token would use the timestamp of when the instance was created, not when the token was created.