FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: simple auth tokens no longer expire after 1 hour by melvincarvalho · Pull Request #256 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub

Repository navigation

fix: simple auth tokens no longer expire after 1 hour - #256

Merged
melvincarvalho merged 3 commits into
gh-pagesfrom
issue-255-token-expiry
Apr 3, 2026
Merged

melvincarvalho merged 3 commits into
gh-pagesfrom
issue-255-token-expiry

Conversation

Copy link
Copy Markdown
Contributor

Summary

  • Pod creation tokens now have no expiry — no refresh path exists in simple auth mode
  • OAuth tokens (AP) keep 1-hour expiry since they have a proper grant flow
  • Verify side already handles missing exp gracefully

Closes #255

Test plan

  • All 353 tests pass
  • createToken() with no expiresIn omits exp from payload
  • OAuth callers pass explicit 3600

Pod creation tokens now have no expiry since there is no refresh
mechanism in simple auth mode. OAuth tokens keep 1-hour expiry.

Closes #255

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR updates the simple HMAC-signed token infrastructure so that “simple auth” pod creation tokens no longer expire after 1 hour (since there’s no refresh path in that mode), while keeping OAuth (ActivityPub) access tokens on a 1-hour TTL.

Changes:

  • Make createToken() omit the exp claim unless an explicit expiresIn is provided.
  • Update OAuth token issuance paths to pass an explicit 3600 seconds expiry.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/auth/token.js Changes createToken() to optionally include exp so simple-mode tokens can be non-expiring.
src/ap/routes/oauth.js Passes explicit 1-hour expiry for OAuth-issued access tokens.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auth/token.js
Comment on lines +45 to +52
export function createToken(webId, expiresIn) {
const payload = {
webId,
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + expiresIn
};
if (expiresIn) {
payload.exp = Math.floor(Date.now() / 1000) + expiresIn;
}

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

if (expiresIn) treats 0 (and NaN) as “no expiry”, producing a non-expiring token even though the caller provided an expiresIn value. Consider validating the parameter (e.g., require a finite number and check expiresIn !== undefined / expiresIn > 0) so accidental falsy values can’t silently disable expiration.

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auth/token.js
Comment on lines +45 to +52
export function createToken(webId, expiresIn) {
const payload = {
webId,
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + expiresIn
};
if (expiresIn !== undefined && expiresIn > 0) {
payload.exp = Math.floor(Date.now() / 1000) + expiresIn;
}

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

expiresIn is treated as “no expiry” unless it’s > 0, which means non-numeric values (e.g., a string, NaN, null) will silently produce a non-expiring token. To avoid accidental non-expiring tokens if a caller ever forwards config/user input, consider validating the type (e.g., typeof expiresIn === 'number' && Number.isFinite(expiresIn) && expiresIn > 0) and otherwise either omit exp explicitly (documented) or throw.

Copilot uses AI. Check for mistakes.
Comment thread src/auth/token.js
Comment on lines 39 to 44
/**
* Create a simple token for a WebID
* @param {string} webId - The WebID to create token for
* @param {number} expiresIn - Expiration time in seconds (default 1 hour)
* @param {number} [expiresIn] - Expiration time in seconds (default: no expiry)
* @returns {string} Token string
*/

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

With createToken() now able to omit exp, the token module’s docs/types should reflect that exp is optional (e.g., the file header comment describing the payload shape and the verifyToken() JSDoc return type currently imply exp is always present). Updating those docs will help avoid confusion for future callers.

Copilot uses AI. Check for mistakes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Simple auth tokens should not expire after 1 hour

2 participants


Back | FazBrowse Home | New Git URL