Repository navigation
chore: integrate adapters repository - #2898
Conversation
git-subtree-dir: packages/adapters git-subtree-split: f056604bbaf22a1554f0a730f9c355370fe4573d
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds three new server adapter packages— Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant TokenVerifier
participant Cache as TokenCache
participant HttpClient
participant JWKServer as JWK Server
Client->>TokenVerifier: verify(token)
TokenVerifier->>Cache: get(token)
alt cached
Cache-->>TokenVerifier: TokenVerificationData
else not cached
TokenVerifier->>TokenVerifier: extract header / kid
TokenVerifier->>HttpClient: GET /.well-known/jwks or /jwks
HttpClient->>JWKServer: request JWK
JWKServer-->>HttpClient: JWK
HttpClient-->>TokenVerifier: JWK
TokenVerifier->>TokenVerifier: import key & verify JWT
TokenVerifier->>TokenVerifier: compute expiry
TokenVerifier->>Cache: set(token, data, ttl)
Cache-->>TokenVerifier: stored
end
TokenVerifier-->>Client: TokenVerificationData
sequenceDiagram
participant Client
participant TokenVerifier
participant Cache as TokenCache
participant Remote as IntrospectionServer
Client->>TokenVerifier: verify(token)
TokenVerifier->>Cache: get(token)
alt cached
Cache-->>TokenVerifier: TokenVerificationData
else not cached
TokenVerifier->>Remote: POST /introspect (token)
alt success
Remote-->>TokenVerifier: introspection data
TokenVerifier->>TokenVerifier: compute expiry
TokenVerifier->>Cache: set(token, data, ttl)
Cache-->>TokenVerifier: stored
else error
Remote-->>TokenVerifier: error response
TokenVerifier->>TokenVerifier: map to JWTError
end
end
TokenVerifier-->>Client: TokenVerificationData | Error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 18
🧹 Nitpick comments (7)
packages/server-adapter-kit/test/utils/faker.ts (1)
30-49: Use the samekidforuseJwk()andsign().
packages/server-adapter-kit/src/verifier/module.ts:75-92resolves keys byheader.kid. Heresign()always emitskeyId: 'foo', butuseJwk()never stamps thatkidonto the generated JWK, so any mock that actually honors the requested key id will miss.Suggested alignment
export class Faker { + protected readonly keyId = 'foo'; + protected keyPair: CryptoKeyPair | undefined; @@ async useJwk() : Promise<OAuth2JsonWebKey> { @@ - this.jwk = (await key.toJWK()) as OAuth2JsonWebKey; + this.jwk = { + ...(await key.toJWK()) as OAuth2JsonWebKey, + kid: this.keyId, + }; @@ async sign(payload: Record<string, any>) { const keyPair = await this.useKeyPair(); return signToken(payload, { type: 'rsa', key: keyPair.privateKey, - keyId: 'foo', + keyId: this.keyId, }); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-kit/test/utils/faker.ts` around lines 30 - 49, The JWK returned by useJwk() and the keyId used in sign() must match so header.kid resolves; update the implementation to use a single kid value (or derive it from the key pair) and ensure useJwk() sets that kid on the generated OAuth2JsonWebKey (this.jwk.kid) and sign() uses the same kid when calling signToken (referencing the useJwk and sign functions / keyId handling so both produce the identical kid).packages/server-adapter-kit/test/unit/verifier.spec.ts (1)
30-90: Add regression coverage for revoked and nearly expired tokens.The current suite only checks malformed-token failures, so it would miss both an
active: falseintrospection response and a cache entry whose TTL outlives the token's remaining validity. Please add explicit cases for those two paths.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-kit/test/unit/verifier.spec.ts` around lines 30 - 90, Add two unit tests: one that simulates an introspection response with active: false to ensure TokenVerifier.verify throws a JWTError for a revoked token (use TokenVerifier with a creator or mocked response returning { active: false } and assert verify(token) rejects as JWTError); and another that simulates a cached verification whose cache TTL outlives the token's remaining validity by inserting a cached entry via MemoryTokenVerifierCache.set (or constructing the cache entry manually) with an expiry timestamp very near/earlier than now while the cache TTL is longer, then call TokenVerifier.verify(token) and assert it does not accept the stale token (throws JWTError), using the same TokenVerifier.verify, MemoryTokenVerifierCache, and creator where appropriate to trigger revalidation.packages/server-adapter-socket-io/README.md (1)
7-7: Update description to match package purpose.Consider updating the description to be consistent with the naming convention and clearer about the package's role.
📝 Suggested description update
-A socket.io plugin for authup. +A Socket.IO server adapter for Authup authentication.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-socket-io/README.md` at line 7, Update the one-line description in README.md so it matches the package name and purpose: replace "A socket.io plugin for authup." with a clearer statement referencing the package identifier server-adapter-socket-io and describing its role (e.g., "Socket.IO adapter for AuthUp server integration" or similar) so it follows the repo naming convention and clearly communicates that this package adapts AuthUp server auth/events to Socket.IO.packages/server-adapter-kit/LICENSE (1)
189-189: Consider updating the copyright year range.The copyright year ends at 2024. Since the code is being actively developed and integrated, consider updating to 2021-2026 or confirming this is intentional.
📝 Suggested update
- Copyright 2021-2024 Peter Placzek + Copyright 2021-2026 Peter Placzek🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-kit/LICENSE` at line 189, Update the copyright year range in the LICENSE entry that currently reads "Copyright 2021-2024 Peter Placzek" to the correct end year (e.g., "Copyright 2021-2026 Peter Placzek") or confirm and leave as-is; locate and edit the exact line string "Copyright 2021-2024 Peter Placzek" in the LICENSE file to reflect the intended year range.packages/server-adapter-http/rollup.config.mjs (1)
14-16: Remove unnecessaryioredisexternal declaration.The package does not import or depend on
ioredis(verified by searching the source and checkingpackage.json). This declaration appears to be copy-paste from another adapter configuration and can be safely removed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-http/rollup.config.mjs` around lines 14 - 16, Remove the unnecessary external declaration for "ioredis" from the rollup config's external array: locate the external: [...] block in rollup.config.mjs and delete the 'ioredis' entry so the bundle configuration only lists actually used externals; ensure no other references to 'ioredis' remain in the file after the change.packages/server-adapter-http/package.json (1)
37-45: Update the published repository metadata to the monorepo.These fields still point at
authup/adaptersandpackages/server-http, so npm/source links will resolve to the old repo and the wrong directory after this integration.Proposed fix
"repository": { "type": "git", - "url": "git+https://github.com/authup/adapters.git", - "directory": "packages/server-http" + "url": "git+https://github.com/authup/authup.git", + "directory": "packages/server-adapter-http" }, "bugs": { - "url": "https://github.com/authup/adapters/issues" + "url": "https://github.com/authup/authup/issues" }, - "homepage": "https://github.com/authup/adapters#readme", + "homepage": "https://github.com/authup/authup#readme",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-http/package.json` around lines 37 - 45, Update the package.json metadata so links point to the new monorepo and correct package directory: replace repository.url with the monorepo git URL, set repository.directory to "packages/server-adapter-http", update bugs.url to the monorepo issues URL, and change homepage to the monorepo README URL; modify the existing keys (repository, bugs, homepage) in package.json to these new values so npm/source links resolve to the correct repo and package location.packages/server-adapter-socket-io/package.json (1)
37-45: Point the package metadata at the integrated repo and renamed directory.
repository,bugs, andhomepagestill reference the old adapters repo, andpackages/server-socket-iono longer matches this package’s location.Proposed fix
"repository": { "type": "git", - "url": "git+https://github.com/authup/adapters.git", - "directory": "packages/server-socket-io" + "url": "git+https://github.com/authup/authup.git", + "directory": "packages/server-adapter-socket-io" }, "bugs": { - "url": "https://github.com/authup/adapters/issues" + "url": "https://github.com/authup/authup/issues" }, - "homepage": "https://github.com/authup/adapters#readme", + "homepage": "https://github.com/authup/authup#readme",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-socket-io/package.json` around lines 37 - 45, Update the package.json metadata entries so they point to the integrated repository and the package's current directory: change the "repository.url" to the correct monorepo URL, set "repository.directory" to the package's actual path (not "packages/server-socket-io"), and update "bugs.url" and "homepage" to the integrated repo's issue tracker and readme URL respectively; ensure the "repository.type" remains "git" and values are valid URLs for npm metadata consumers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/server-adapter-http/CHANGELOG.md`:
- Line 27: Fix the two typos in the changelog by replacing the misspelled word
"epxlicit" with "explicit" (the entry "* epxlicit cache + tokenVerifier
instance") and replacing "form" with "from" at the other changelog entry; update
those exact strings so the published CHANGELOG.md shows the correct user-facing
text.
In `@packages/server-adapter-http/LICENSE`:
- Line 189: Update the copyright year range in the LICENSE line that currently
reads "Copyright 2021-2024 Peter Placzek" to reflect the current year (change to
"Copyright 2021-2026"); locate and modify that exact string in the LICENSE file
so the header reflects ongoing development.
In `@packages/server-adapter-http/src/module.ts`:
- Around line 33-45: The malformed/bearer checks currently throw Errors directly
(using the authorization variable and its parsing logic), which bypasses the
middleware error path; instead create the Error objects for the three failure
cases (malformed header, non-Bearer type, empty token) and pass them into the
Express-style next(error) handler used elsewhere in this module so all auth
parsing failures follow the same next(e) path as token verification errors.
- Around line 38-40: The check that compares the Authorization scheme is
case-sensitive and will reject valid variants like "bearer" or "BEARER"; update
the comparison around the variables type and spaceIndex so the auth-scheme token
is compared case-insensitively (for example compare type.toLowerCase() to
'bearer' or use a case-insensitive match) and keep the existing error path
otherwise so the code using authorization, spaceIndex, and type behaves the same
for valid Bearer variants.
In `@packages/server-adapter-kit/CHANGELOG.md`:
- Line 20: Typo in the changelog entry: replace the misspelled word "epxlicit"
with "explicit" in the changelog line "* epxlicit cache + tokenVerifier instance
([2a69258]...)" so the entry reads "* explicit cache + tokenVerifier instance
([2a69258]...)" (update the string in CHANGELOG.md where that exact entry
appears).
- Line 64: Correct the typo in the changelog entry by changing "init project
form source" to "init project from source" in the line that contains "* init
project form source
([9bb2008](https://github.com/authup/adapters/commit/9bb20089d4cfce0511789858b49fa5c51eb4b6f2))"
so the wording reads "init project from source" while keeping the existing
commit reference intact.
In `@packages/server-adapter-kit/package.json`:
- Around line 47-55: Update the package.json metadata to point to this monorepo
and package path: change the repository.url to the monorepo repo URL, set
repository.directory to "packages/server-adapter-kit", update bugs.url to the
monorepo issues URL, and update homepage to the monorepo README URL so npm
points to the correct source tree and issue tracker.
In `@packages/server-adapter-kit/src/verifier/cache/types.ts`:
- Around line 10-12: The cache contract currently has an optional TTL parameter
which lets implementations diverge; change the ITokenVerifierCache.set signature
to require seconds: number (i.e., remove the optional flag) so TTL is part of
the shared contract, update any implementation methods referenced by set (e.g.,
the in-memory implementation in memory.ts that multiplies seconds and the Redis
implementation in redis.ts that creates non-expiring entries when seconds is
missing) to accept and apply the required seconds without guards for undefined,
and ensure callers that compute TTL from token iat/exp pass that positive
seconds value when calling ITokenVerifierCache.set (keep get(token: string):
Promise<TokenVerificationData | undefined> and the TokenVerificationData type
unchanged).
In `@packages/server-adapter-kit/src/verifier/module.ts`:
- Around line 137-177: After successful introspection (where payload is set),
verify that payload.active is true and reject inactive responses before
computing TTL or calling getTokenExpiresIn/transform; if payload.active is
false, throw a JWTError (e.g., with ErrorCode.JWT_INVALID and an appropriate
status/message) so inactive tokens are not cached or treated as
authenticated—insert this check between the payload assignment and the calls to
this.getTokenExpiresIn(payload) and this.transform(payload).
- Around line 193-208: The getTokenExpiresIn function currently returns the
original token lifetime (payload.exp - payload.iat); change it to compute
remaining lifetime by subtracting the current Unix time from payload.exp (e.g.,
payload.exp - Math.floor(Date.now()/1000)) so the cache TTL reflects time left
until expiry; keep the existing checks for payload.exp and payload.iat, throw
JWTError.expired() if the computed remaining seconds <= 0, and return the
remaining seconds as an integer. Reference: getTokenExpiresIn and
OAuth2TokenPayload.
In `@packages/server-adapter-kit/test/data/token.ts`:
- Line 30: The fixture contains a personal-looking address in the email property
(email: '[email protected]'); replace that value with a reserved test
address such as [email protected] (or another example/placeholder test value) in
the token fixture object so no PII is committed.
- Around line 14-43: The fixture TokenPayload and its use in introspectToken are
missing iat and exp so getTokenExpiresIn(...) in the verifier will throw; change
the TokenPayload declaration to include both iat and exp (remove the Omit<...,
'exp'> and/or use the full OAuth2TokenIntrospectionResponse type) and populate
iat (e.g. issued-at epoch seconds) and exp (expiry epoch seconds > iat) with
reasonable test values before casting/returning it from introspectToken so the
default branch returns a valid, cacheable token response for the verifier; keep
the symbol names TokenPayload and introspectToken unchanged.
In `@packages/server-adapter-socket-io/CHANGELOG.md`:
- Line 27: Update the release notes to fix typos: replace the misspelled word
"epxlicit" with "explicit" in the entry that contains "epxlicit cache +
tokenVerifier instance" and replace "form" with "from" wherever the entry uses
"form" (the user-visible changelog lines referenced); ensure both corrected
strings are saved in CHANGELOG.md so the published changelog shows "explicit
cache + tokenVerifier instance" and the correct "from" wording.
In `@packages/server-adapter-socket-io/LICENSE`:
- Line 189: Update the copyright year range in the LICENSE file: locate the line
containing "Copyright 2021-2024 Peter Placzek" and change the end year to 2026
so it reads "Copyright 2021-2026 Peter Placzek"; save the LICENSE file and
include the change in the PR.
In `@packages/server-adapter-socket-io/README.md`:
- Around line 1-5: The README uses the wrong package name and badge URLs:
replace occurrences of "@authup/plugin-socket-io" in the title and badges with
the correct package name "@authup/server-adapter-socket-io" and update the badge
links from the "authup/plugins" repo to the "authup/authup" repo (for both npm
badge and GitHub Actions/Snyk badges) so they match the actual package directory
and sibling READMEs; ensure the textual title, npm badge URL, GitHub Actions
badge URL, and Snyk badge URL are all updated consistently.
In `@packages/server-adapter-socket-io/src/module.ts`:
- Around line 19-29: Move the call to context.tokenVerifierHandler(socket, data)
inside the same try block that awaits context.tokenVerifier.verify(token) so any
errors from the handler are caught and forwarded via next(err); remove the outer
undefined widening by declaring data as const (or let) inside the try as type
TokenVerificationData from the verify() result and then call
context.tokenVerifierHandler(socket, data) before returning next(), and in the
catch call next(e as Error) for any thrown errors.
- Around line 13-22: The code currently reads socket.handshake.auth.token and
only checks falsiness; ensure token is a string before calling
context.tokenVerifier.verify by adding an explicit type check (e.g., typeof
token === "string") and return next() when token is missing or not a string;
update the logic around socket.handshake.auth / token and the call to
context.tokenVerifier.verify(token) to only invoke verify with a validated
string to satisfy the verifier contract.
In `@release-please-config.json`:
- Around line 21-23: The linked-versions group is missing the server adapter
packages; update the plugins[1].components array (the components list used for
linked-versions) to include "packages/server-adapter-http",
"packages/server-adapter-kit", and "packages/server-adapter-socket-io" so they
are part of the monorepo's linked-version release cycle; locate the
plugins[1].components entry in release-please-config.json and add those three
package identifiers to that array so they match the top-level packages map.
---
Nitpick comments:
In `@packages/server-adapter-http/package.json`:
- Around line 37-45: Update the package.json metadata so links point to the new
monorepo and correct package directory: replace repository.url with the monorepo
git URL, set repository.directory to "packages/server-adapter-http", update
bugs.url to the monorepo issues URL, and change homepage to the monorepo README
URL; modify the existing keys (repository, bugs, homepage) in package.json to
these new values so npm/source links resolve to the correct repo and package
location.
In `@packages/server-adapter-http/rollup.config.mjs`:
- Around line 14-16: Remove the unnecessary external declaration for "ioredis"
from the rollup config's external array: locate the external: [...] block in
rollup.config.mjs and delete the 'ioredis' entry so the bundle configuration
only lists actually used externals; ensure no other references to 'ioredis'
remain in the file after the change.
In `@packages/server-adapter-kit/LICENSE`:
- Line 189: Update the copyright year range in the LICENSE entry that currently
reads "Copyright 2021-2024 Peter Placzek" to the correct end year (e.g.,
"Copyright 2021-2026 Peter Placzek") or confirm and leave as-is; locate and edit
the exact line string "Copyright 2021-2024 Peter Placzek" in the LICENSE file to
reflect the intended year range.
In `@packages/server-adapter-kit/test/unit/verifier.spec.ts`:
- Around line 30-90: Add two unit tests: one that simulates an introspection
response with active: false to ensure TokenVerifier.verify throws a JWTError for
a revoked token (use TokenVerifier with a creator or mocked response returning {
active: false } and assert verify(token) rejects as JWTError); and another that
simulates a cached verification whose cache TTL outlives the token's remaining
validity by inserting a cached entry via MemoryTokenVerifierCache.set (or
constructing the cache entry manually) with an expiry timestamp very
near/earlier than now while the cache TTL is longer, then call
TokenVerifier.verify(token) and assert it does not accept the stale token
(throws JWTError), using the same TokenVerifier.verify,
MemoryTokenVerifierCache, and creator where appropriate to trigger revalidation.
In `@packages/server-adapter-kit/test/utils/faker.ts`:
- Around line 30-49: The JWK returned by useJwk() and the keyId used in sign()
must match so header.kid resolves; update the implementation to use a single kid
value (or derive it from the key pair) and ensure useJwk() sets that kid on the
generated OAuth2JsonWebKey (this.jwk.kid) and sign() uses the same kid when
calling signToken (referencing the useJwk and sign functions / keyId handling so
both produce the identical kid).
In `@packages/server-adapter-socket-io/package.json`:
- Around line 37-45: Update the package.json metadata entries so they point to
the integrated repository and the package's current directory: change the
"repository.url" to the correct monorepo URL, set "repository.directory" to the
package's actual path (not "packages/server-socket-io"), and update "bugs.url"
and "homepage" to the integrated repo's issue tracker and readme URL
respectively; ensure the "repository.type" remains "git" and values are valid
URLs for npm metadata consumers.
In `@packages/server-adapter-socket-io/README.md`:
- Line 7: Update the one-line description in README.md so it matches the package
name and purpose: replace "A socket.io plugin for authup." with a clearer
statement referencing the package identifier server-adapter-socket-io and
describing its role (e.g., "Socket.IO adapter for AuthUp server integration" or
similar) so it follows the repo naming convention and clearly communicates that
this package adapts AuthUp server auth/events to Socket.IO.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bae5a626-dbab-48c7-a58a-9a1a6949df34
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (48)
.agents/skills/update-docs/SKILL.md.gitignore.release-please-manifest.jsonpackages/server-adapter-http/.editorconfigpackages/server-adapter-http/CHANGELOG.mdpackages/server-adapter-http/LICENSEpackages/server-adapter-http/README.mdpackages/server-adapter-http/package.jsonpackages/server-adapter-http/rollup.config.mjspackages/server-adapter-http/src/index.tspackages/server-adapter-http/src/module.tspackages/server-adapter-http/src/types.tspackages/server-adapter-http/tsconfig.build.jsonpackages/server-adapter-http/tsconfig.jsonpackages/server-adapter-kit/.editorconfigpackages/server-adapter-kit/CHANGELOG.mdpackages/server-adapter-kit/LICENSEpackages/server-adapter-kit/README.mdpackages/server-adapter-kit/package.jsonpackages/server-adapter-kit/rollup.config.mjspackages/server-adapter-kit/src/index.tspackages/server-adapter-kit/src/verifier/cache/index.tspackages/server-adapter-kit/src/verifier/cache/memory.tspackages/server-adapter-kit/src/verifier/cache/redis.tspackages/server-adapter-kit/src/verifier/cache/types.tspackages/server-adapter-kit/src/verifier/index.tspackages/server-adapter-kit/src/verifier/module.tspackages/server-adapter-kit/src/verifier/types.tspackages/server-adapter-kit/test/data/jwk.tspackages/server-adapter-kit/test/data/token.tspackages/server-adapter-kit/test/unit/verifier.spec.tspackages/server-adapter-kit/test/utils/faker.tspackages/server-adapter-kit/test/utils/index.tspackages/server-adapter-kit/test/utils/response-error.tspackages/server-adapter-kit/tsconfig.build.jsonpackages/server-adapter-kit/tsconfig.jsonpackages/server-adapter-socket-io/.editorconfigpackages/server-adapter-socket-io/CHANGELOG.mdpackages/server-adapter-socket-io/LICENSEpackages/server-adapter-socket-io/README.mdpackages/server-adapter-socket-io/package.jsonpackages/server-adapter-socket-io/rollup.config.mjspackages/server-adapter-socket-io/src/index.tspackages/server-adapter-socket-io/src/module.tspackages/server-adapter-socket-io/src/types.tspackages/server-adapter-socket-io/tsconfig.build.jsonpackages/server-adapter-socket-io/tsconfig.jsonrelease-please-config.json
| const type = authorization.substring(0, spaceIndex); | ||
| if (type !== 'Bearer') { | ||
| throw new Error('Only Bearer tokens are accepted as authentication method.'); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Under the HTTP authentication specification for the Authorization header, is the auth-scheme token (for example Bearer) case-insensitive? Please cite the relevant standard text.
💡 Result:
Yes. In HTTP Authentication, the auth-scheme token (e.g., Bearer) is case-insensitive.
Relevant standard text:
- RFC 9110 (HTTP Semantics), §11.1: “It uses a case-insensitive token to identify the authentication scheme:
auth-scheme = token.” [1] - (Older, obsoleted) RFC 7235, §2.1: “It uses a case-insensitive token … to identify the authentication scheme …
auth-scheme = token.” [2]
Therefore, Authorization: bearer ... and Authorization: Bearer ... are equivalent with respect to the scheme token.
Sources: [1] RFC 9110 https://datatracker.ietf.org/doc/html/rfc9110, [2] RFC 7235 https://httpwg.org/specs/rfc7235.html
Use case-insensitive comparison for the Authorization scheme.
Per RFC 9110 §11.1 and RFC 7235 §2.1, the auth-scheme token (e.g., Bearer) must be matched case-insensitively. The current code rejects valid variants like bearer or BEARER because it only accepts the exact spelling Bearer.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/server-adapter-http/src/module.ts` around lines 38 - 40, The check
that compares the Authorization scheme is case-sensitive and will reject valid
variants like "bearer" or "BEARER"; update the comparison around the variables
type and spaceIndex so the auth-scheme token is compared case-insensitively (for
example compare type.toLowerCase() to 'bearer' or use a case-insensitive match)
and keep the existing error path otherwise so the code using authorization,
spaceIndex, and type behaves the same for valid Bearer variants.
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
packages/server-adapter-http/src/module.ts (1)
19-23:⚠️ Potential issue | 🟠 MajorHandle Bearer scheme parsing case-insensitively and with a strict prefix.
Line 19andLine 39currently use case-sensitive checks; this rejects valid scheme variants (bearer,BEARER) and may misclassify cookie values that merely start with"Bearer"but are not"Bearer "prefixed.Proposed fix
- if (!cookieToken.startsWith('Bearer')) { + if (!/^Bearer\s+/i.test(cookieToken)) { authorization = `Bearer ${cookieToken}`; } else { authorization = cookieToken; } ... - if (type !== 'Bearer') { + if (type.toLowerCase() !== 'bearer') { throw new Error('Only Bearer tokens are accepted as authentication method.'); }Also applies to: 38-40
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-http/src/module.ts` around lines 19 - 23, Update the Bearer-scheme parsing so it's case-insensitive and only treats values that start with the scheme plus a space as already-formed. Specifically, where cookieToken and authorization are handled, replace the current startsWith('Bearer') logic with a case-insensitive check for the exact prefix 'bearer ' (e.g. cookieToken.toLowerCase().startsWith('bearer ')); if that is true set authorization = cookieToken (preserve original casing), otherwise set authorization = `Bearer ${cookieToken}`. Apply the same change to both occurrences that manipulate cookieToken/authorization.
🧹 Nitpick comments (1)
packages/server-adapter-socket-io/package.json (1)
1-56: Consider addingsocket.ioas a peerDependency.This package is a socket.io server adapter but doesn't declare
socket.ioas a dependency. Based on the types insrc/types.ts(usingSocket,Handshake,Next), the package expects consumers to have socket.io installed. Adding it as apeerDependencywould make this requirement explicit and help avoid version mismatches.♻️ Suggested addition
"dependencies": { "@authup/core-kit": "^1.0.0-beta.30", "@authup/server-adapter-kit": "^1.0.0-beta.30" }, + "peerDependencies": { + "socket.io": "^4.0.0" + }, "devDependencies": { "vitest": "^4.0.18" },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-adapter-socket-io/package.json` around lines 1 - 56, The package is missing socket.io as a declared peer dependency; update package.json to add a peerDependencies entry for "socket.io" (specifying a compatible semver range aligned with the project's supported socket.io versions) so consumers must provide it, and reference the runtime types used in src/types.ts (Socket, Handshake, Next) to justify the requirement; ensure you also keep any existing "dependencies" entries unchanged and adjust package.json export/build scripts only if needed for publishing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/server-adapter-kit/src/verifier/cache/redis.ts`:
- Around line 32-43: The current buildKey usage exposes raw bearer tokens in
Redis keys via get/set; change buildKey to derive the key from a secure digest
(e.g., HMAC-SHA256 or SHA-256) of the token rather than embedding the token
itself so keys never contain the raw credential; update the buildKey
implementation used by get(token) and set(token, ...) to compute a hex digest
(using a server-side secret for HMAC or a straight SHA-256 if no secret is
available), and ensure any tests/config accept the new deterministic digest
behavior while leaving TokenVerificationData storage in values unchanged.
In `@packages/server-adapter-kit/src/verifier/module.ts`:
- Around line 86-92: The catch block around this.client.getJwk(header.kid) in
module.ts currently maps all failures to JWTError.payloadPropertyInvalid('kid');
change it so only a genuine "key not found" response (e.g., a 404 or explicit
NotFound error from getJwk) is translated to
JWTError.payloadPropertyInvalid('kid'), while transport/timeout/5xx errors from
getJwk are either re-thrown or wrapped in a different error (e.g., an
internal/temporarily-unavailable JWTError) so outages are not misreported as
invalid-kid; specifically inspect the error returned by this.client.getJwk and
branch: if error indicates missing JWK -> throw
JWTError.payloadPropertyInvalid('kid'), else propagate or wrap the original
error instead of collapsing everything into payloadPropertyInvalid.
- Around line 128-132: The current logic short-circuits on this.cache.get(token)
(in the token introspection path) and later stores results until the token's
exp, which causes remote introspection to be effectively cached for the full
token lifetime; change that by introducing a configurable short TTL for remote
introspection (e.g., remoteIntrospectionTTL) and use it when reading/writing the
cache for the remote introspection branch instead of using the token exp or
indefinite caching; locate the cache read at this.cache.get(token) and the store
logic around where the code currently uses exp (the later store block) and
update the store to pass the short TTL (or skip caching by default) and ensure
the get path honors/keys the same TTL-backed entry so
revocations/permission/user-disable changes are respected.
---
Duplicate comments:
In `@packages/server-adapter-http/src/module.ts`:
- Around line 19-23: Update the Bearer-scheme parsing so it's case-insensitive
and only treats values that start with the scheme plus a space as
already-formed. Specifically, where cookieToken and authorization are handled,
replace the current startsWith('Bearer') logic with a case-insensitive check for
the exact prefix 'bearer ' (e.g. cookieToken.toLowerCase().startsWith('bearer
')); if that is true set authorization = cookieToken (preserve original casing),
otherwise set authorization = `Bearer ${cookieToken}`. Apply the same change to
both occurrences that manipulate cookieToken/authorization.
---
Nitpick comments:
In `@packages/server-adapter-socket-io/package.json`:
- Around line 1-56: The package is missing socket.io as a declared peer
dependency; update package.json to add a peerDependencies entry for "socket.io"
(specifying a compatible semver range aligned with the project's supported
socket.io versions) so consumers must provide it, and reference the runtime
types used in src/types.ts (Socket, Handshake, Next) to justify the requirement;
ensure you also keep any existing "dependencies" entries unchanged and adjust
package.json export/build scripts only if needed for publishing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 66f2b0b4-e25a-4f37-881e-7b56ac371fe0
📒 Files selected for processing (13)
packages/server-adapter-http/CHANGELOG.mdpackages/server-adapter-http/package.jsonpackages/server-adapter-http/src/module.tspackages/server-adapter-kit/CHANGELOG.mdpackages/server-adapter-kit/package.jsonpackages/server-adapter-kit/src/verifier/cache/redis.tspackages/server-adapter-kit/src/verifier/cache/types.tspackages/server-adapter-kit/src/verifier/module.tspackages/server-adapter-kit/test/data/token.tspackages/server-adapter-socket-io/CHANGELOG.mdpackages/server-adapter-socket-io/README.mdpackages/server-adapter-socket-io/package.jsonpackages/server-adapter-socket-io/src/module.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- packages/server-adapter-http/package.json
- packages/server-adapter-kit/test/data/token.ts
- packages/server-adapter-kit/package.json
- packages/server-adapter-socket-io/README.md
- packages/server-adapter-socket-io/src/module.ts
- packages/server-adapter-kit/CHANGELOG.md
- packages/server-adapter-socket-io/CHANGELOG.md
resolves #2897
Summary by CodeRabbit
New Features
Documentation
Tests
Chores