Skip to content

Conversation

@aaryan359
Copy link

Description

As discussed in this fossology/LicenseDb-UI#26, I updated the expire_in logic to expire_at, and also created a PR in the frontend fossology/LicenseDb-UI#54

Changes

  • Added backend-generated expires_at field for access tokens
  • Removed reliance on client-side expiry calculation using expires_in
  • Ensured token expiry is authoritative and latency-safe

Submitter Checklist

  • Includes tests
  • [x ] Includes docs
  • I have tested my changes locally.

References

N/A

@aaryan359
Copy link
Author

@deo002 Please check this? Does it looks good?

Copy link
Collaborator

@deo002 deo002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contributions! Some changes are required.

}

expiresInSeconds := int64(accessTokenLifespan * 3600)
expiresAt := now.Add(time.Second * time.Duration(expiresInSeconds))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same value here that is used for the creation of the access token at line 1093

t.Fatalf("invalid expires_at format: %v", err)
}

min := before.Add(59 * time.Minute)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this configurable in the .env.test.example file and the test would fail if I change it? Also, let's not check it this way. We have a field called iat in the token. We can get the exact expiry date by adding the lifespan set in the .env file to the issued_at attribute.

}

// Expect ~1 hour validity again
min := before.Add(59 * time.Minute)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants