-
Notifications
You must be signed in to change notification settings - Fork 11.3k
fix: add tests for simple test flow #25566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| totpCode: { label: "Two-factor Code", type: "input", placeholder: "Code from authenticator app" }, | ||
| backupCode: { label: "Backup Code", type: "input", placeholder: "Two-factor backup code" }, | ||
| }, | ||
| async authorize(credentials): Promise<User | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this function to "authoriseCredentials" so we can test easier without logic being caught be AuthJS credential provider
| authorize: authorizeCredentials, | ||
| }); | ||
|
|
||
| const providers: Provider[] = [calComCredentialsProvider, ImpersonationProvider]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the provider tsame as before
emrysal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, let's start refactoring this straight away indeed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/features/auth/lib/next-auth-options.ts">
<violation number="1" location="packages/features/auth/lib/next-auth-options.ts:143">
P1: Rule violated: **Avoid Logging Sensitive Information**
`authorizeCredentials` logs the entire credentials payload (email, password, TOTP, backup code), exposing sensitive authentication data in logs. Replace it with a sanitized log that omits secrets or remove the log entirely.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| export async function authorizeCredentials( | ||
| credentials: Record<"email" | "password" | "totpCode" | "backupCode", string> | undefined | ||
| ): Promise<User | null> { | ||
| log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Rule violated: Avoid Logging Sensitive Information
authorizeCredentials logs the entire credentials payload (email, password, TOTP, backup code), exposing sensitive authentication data in logs. Replace it with a sanitized log that omits secrets or remove the log entirely.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/auth/lib/next-auth-options.ts, line 143:
<comment>`authorizeCredentials` logs the entire credentials payload (email, password, TOTP, backup code), exposing sensitive authentication data in logs. Replace it with a sanitized log that omits secrets or remove the log entirely.</comment>
<file context>
@@ -133,139 +133,144 @@ const checkIfUserShouldBelongToOrg = async (idP: IdentityProvider, email: string
+export async function authorizeCredentials(
+ credentials: Record<"email" | "password" | "totpCode" | "backupCode", string> | undefined
+): Promise<User | null> {
+ log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials }));
+ if (!credentials) {
+ console.error(`For some reason credentials are missing`);
</file context>
| log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials })); | |
| log.debug("CredentialsProvider:credentials:authorize", { | |
| hasCredentials: Boolean(credentials), | |
| identifier: credentials?.email ? hashEmail(credentials.email) : undefined, | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/features/auth/lib/next-auth-options.ts">
<violation number="1" location="packages/features/auth/lib/next-auth-options.ts:143">
P1: Rule violated: **Avoid Logging Sensitive Information**
`authorizeCredentials` still logs the full `credentials` object, exposing email, password, TOTP, and backup codes in logs, which violates the “Avoid Logging Sensitive Information” rule.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| export async function authorizeCredentials( | ||
| credentials: Record<"email" | "password" | "totpCode" | "backupCode", string> | undefined | ||
| ): Promise<User | null> { | ||
| log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Rule violated: Avoid Logging Sensitive Information
authorizeCredentials still logs the full credentials object, exposing email, password, TOTP, and backup codes in logs, which violates the “Avoid Logging Sensitive Information” rule.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/auth/lib/next-auth-options.ts, line 143:
<comment>`authorizeCredentials` still logs the full `credentials` object, exposing email, password, TOTP, and backup codes in logs, which violates the “Avoid Logging Sensitive Information” rule.</comment>
<file context>
@@ -133,139 +133,144 @@ const checkIfUserShouldBelongToOrg = async (idP: IdentityProvider, email: string
+export async function authorizeCredentials(
+ credentials: Record<"email" | "password" | "totpCode" | "backupCode", string> | undefined
+): Promise<User | null> {
+ log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials }));
+ if (!credentials) {
+ console.error(`For some reason credentials are missing`);
</file context>
| log.debug("CredentialsProvider:credentials:authorize", safeStringify({ credentials })); | |
| log.debug("CredentialsProvider:credentials:authorize", safeStringify({ hasCredentials: Boolean(credentials) })); |
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
hbjORbj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
What does this PR do?
This PR extracts the credentials provider authorization logic from the NextAuth provider configuration into a separate, testable function. This enables comprehensive unit testing of the authorization flow, particularly the simplified password validation logic introduced in PR #25563.