Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/weak-hands-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': patch
'@clerk/shared': patch
'@clerk/types': patch
---
5 changes: 5 additions & 0 deletions packages/nextjs/src/server/data/getAuthDataFromRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const getAuthDataFromRequestSync = (
return getAuthObjectFromJwt(jwt, options);
}

console.log('auth object from auth data request', { authObject });
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove console.log statement before production.

This debugging statement should be removed as it may expose sensitive authentication data in production logs and create unnecessary console noise.

-  console.log('auth object from auth data request', { authObject });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('auth object from auth data request', { authObject });
🤖 Prompt for AI Agents
In packages/nextjs/src/server/data/getAuthDataFromRequest.ts at line 81, remove
the console.log statement that outputs the authObject to prevent exposing
sensitive authentication data and avoid unnecessary console noise in production
environments.


return authObject;
};

Expand Down Expand Up @@ -132,6 +134,9 @@ export const getAuthDataFromRequestAsync = async (

// Fallback to session logic (sync version) for all other cases
const authObject = getAuthDataFromRequestSync(req, opts);

console.log('auth data from request', { authObject });

return getAuthObjectForAcceptedToken({ authObject, acceptsToken });
};

Expand Down
13 changes: 8 additions & 5 deletions packages/shared/src/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const prefixWithOrg = (value: string) => value.replace(/^(org:)*/, 'org:');
/**
* Checks if a user has the required organization-level authorization.
* Verifies if the user has the specified role or permission within their organization.
* @returns null, if unable to determine due to missing data or unspecified role/permission.
*
* @returns Null, if unable to determine due to missing data or unspecified role/permission.
*/
const checkOrgAuthorization: CheckOrgAuthorization = (params, options) => {
const { orgId, orgRole, orgPermissions } = options;
Expand Down Expand Up @@ -162,7 +163,8 @@ const validateReverificationConfig = (config: ReverificationConfig | undefined |
* Evaluates if the user meets re-verification authentication requirements.
* Compares the user's factor verification ages against the specified maxAge.
* Handles different verification levels (first factor, second factor, multi-factor).
* @returns null, if requirements or verification data are missing.
*
* @returns Null, if requirements or verification data are missing.
*/
const checkReverificationAuthorization: CheckReverificationAuthorization = (params, { factorVerificationAge }) => {
if (!params.reverification || !factorVerificationAge) {
Expand Down Expand Up @@ -237,6 +239,7 @@ type AuthStateOptions = {
/**
* Shared utility function that centralizes auth state resolution logic,
* preventing duplication across different packages.
*
* @internal
*/
const resolveAuthState = ({
Expand Down Expand Up @@ -306,7 +309,7 @@ const resolveAuthState = ({
} as const;
}

if (!!sessionId && !!sessionClaims && !!userId && !!orgId && !!orgRole) {
if (!!sessionId && !!userId && !!orgId && !!orgRole) {
return {
isLoaded: true,
isSignedIn: true,
Expand All @@ -323,7 +326,7 @@ const resolveAuthState = ({
} as const;
}

if (!!sessionId && !!sessionClaims && !!userId && !orgId) {
if (!!sessionId && !!userId && !orgId) {
return {
isLoaded: true,
isSignedIn: true,
Expand All @@ -341,4 +344,4 @@ const resolveAuthState = ({
}
};

export { createCheckAuthorization, validateReverificationConfig, resolveAuthState, splitByScope };
export { createCheckAuthorization, resolveAuthState, splitByScope, validateReverificationConfig };
4 changes: 2 additions & 2 deletions packages/types/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export type UseAuthReturn =
isSignedIn: true;
userId: string;
sessionId: string;
sessionClaims: JwtPayload;
sessionClaims?: JwtPayload | null;
actor: ActClaim | null;
orgId: null;
orgRole: null;
Expand All @@ -108,7 +108,7 @@ export type UseAuthReturn =
isSignedIn: true;
userId: string;
sessionId: string;
sessionClaims: JwtPayload;
sessionClaims?: JwtPayload | null;
actor: ActClaim | null;
orgId: string;
orgRole: OrganizationCustomRoleKey;
Expand Down
Loading