-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve OIDC account linking and show SSO error messages #28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,4 +56,6 @@ next-env.d.ts | |
| # codeql | ||
| .codeql/ | ||
|
|
||
| /scripts/* | ||
| /scripts/* | ||
| # worktrees | ||
| .worktrees/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -178,7 +178,7 @@ async function getAuthInstance() { | |||||||||
| issuer: oidc.issuer, | ||||||||||
| clientId: oidc.clientId, | ||||||||||
| clientSecret: oidc.clientSecret, | ||||||||||
| allowDangerousEmailAccountLinking: false, | ||||||||||
| allowDangerousEmailAccountLinking: true, | ||||||||||
| client: { | ||||||||||
| token_endpoint_auth_method: oidc.tokenEndpointAuthMethod, | ||||||||||
| }, | ||||||||||
|
|
@@ -201,6 +201,7 @@ async function getAuthInstance() { | |||||||||
| const groupsClaim = settings?.oidcGroupsClaim ?? "groups"; | ||||||||||
| const profileData = profile as Record<string, unknown> | undefined; | ||||||||||
| const userGroups = (profileData?.[groupsClaim] as string[] | undefined) ?? []; | ||||||||||
| console.log(`[oidc] User ${user.email} groups (claim "${groupsClaim}"):`, userGroups); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Permanent PII logging on every OIDC login This line logs the user's email address and their full group membership list on every SSO login. These are server logs that may be collected by log aggregation pipelines, and group membership can reveal organizational structure and access levels. The PR description calls this "debug logging," but it's unconditional and permanent — there's no debug flag guarding it. Consider either removing it after diagnosis or gating it on an environment variable:
Suggested change
Rule Used: ## Security & Cryptography Review Rules When revi... (source) Prompt To Fix With AIThis is a comment left during a code review.
Path: src/auth.ts
Line: 204
Comment:
**Permanent PII logging on every OIDC login**
This line logs the user's email address and their full group membership list on every SSO login. These are server logs that may be collected by log aggregation pipelines, and group membership can reveal organizational structure and access levels.
The PR description calls this "debug logging," but it's unconditional and permanent — there's no debug flag guarding it. Consider either removing it after diagnosis or gating it on an environment variable:
```suggestion
if (process.env.DEBUG_OIDC_GROUPS === "true") {
console.log(`[oidc] User ${user.email} groups (claim "${groupsClaim}"):`, userGroups);
}
```
**Rule Used:** ## Security & Cryptography Review Rules
When revi... ([source](https://app.greptile.com/review/custom-context?memory=7cb20c56-ca6a-40aa-8660-7fa75e6e3db2))
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||
|
|
||||||||||
| // Ensure user exists in the database | ||||||||||
| let dbUser = await prisma.user.findUnique({ | ||||||||||
|
|
@@ -231,7 +232,7 @@ async function getAuthInstance() { | |||||||||
| console.warn( | ||||||||||
| `OIDC login blocked: local account exists for ${dbUser.email}. Admin must explicitly link accounts.`, | ||||||||||
| ); | ||||||||||
| return false; | ||||||||||
| return "/login?error=local_account"; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Refresh profile picture on each OIDC sign-in | ||||||||||
|
|
||||||||||
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.
replaceStatedoesn't sync Next.js router statewindow.history.replaceStateupdates the browser URL directly but does NOT update Next.js's internal router state. As a result,useSearchParams()may still return the old params (containing?error=...) on subsequent renders, causing thisuseEffectto re-run and redundantly re-set the same error message.The recommended pattern in Next.js App Router is to use
router.replace('/login')instead, which flushes both the browser URL and Next.js'ssearchParamsstate:This ensures
searchParamsis cleanly emptied after the error is consumed, preventing any stale re-invocation of the effect.Rule Used: ## Code Style & Conventions
TypeScript Conven... (source)
Prompt To Fix With AI