Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(auth): block custom OAuth signup when registration disabled (#1503)

Corentin Thomasset2993c6ea6a3b
diff --git a/.changeset/humble-rules-walk.md b/.changeset/humble-rules-walk.md
new file mode 100644
index 00000000..2a21b9a2
--- /dev/null
+++ b/.changeset/humble-rules-walk.md
@@ -0,0 +1,5 @@
+---
+'@papra/app': patch
+---
+
+Security fix: Prevent custom OAuth providers from creating new accounts when registration is disabled, while allowing existing users to sign in.
diff --git a/apps/papra-server/src/modules/app/auth/auth.services.ts b/apps/papra-server/src/modules/app/auth/auth.services.ts
index 21098ef3..32cff0be 100644
--- a/apps/papra-server/src/modules/app/auth/auth.services.ts
+++ b/apps/papra-server/src/modules/app/auth/auth.services.ts
@@ -135,7 +135,15 @@ export function getAuth({
twoFactor(),
...(config.auth.providers.customs.length > 0
- ? [genericOAuth({ config: config.auth.providers.customs })]
+ ? [
+ genericOAuth({
+ config: config.auth.providers.customs.map((oauthConfig) => ({
+ ...oauthConfig,
+ disableSignUp: !config.auth.isRegistrationEnabled,
+ disableImplicitSignUp: !config.auth.isRegistrationEnabled,
+ })),
+ }),
+ ]
: []),
],
});