Skip to content

Commit 668cc28

Browse files
committed
feat: improve OAuth parameter detection with stricter logic
- Require both client identifier (client_id/redirect_uri) AND flow parameter - Prevents false positives from single parameters like 'state=california' - Maintains support for SAML flows with SAMLRequest/SAMLResponse - Addresses maintainer feedback for more robust authentication detection
1 parent 31ef08f commit 668cc28

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/ui/main/serverView/index.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,39 @@ const isAuthenticationPopup = (
6161
try {
6262
const parsedUrl = new URL(url);
6363

64+
// HIGHEST PRIORITY: Check for OAuth parameters in URL query string
65+
// This ensures support for custom/in-house OAuth providers (e.g., BitWarden, custom SSO)
66+
// Use stricter logic to avoid false positives - require meaningful OAuth parameter combinations
67+
const { searchParams } = parsedUrl;
68+
69+
// Core OAuth identifiers that strongly indicate OAuth flow
70+
const clientIdentifiers = ['client_id', 'redirect_uri'];
71+
const oauthFlowParams = [
72+
'response_type',
73+
'state',
74+
'scope',
75+
'code_challenge',
76+
'nonce',
77+
];
78+
const samlParams = ['SAMLRequest', 'SAMLResponse'];
79+
80+
// Check for SAML authentication (definitive indicators)
81+
if (samlParams.some((param) => searchParams.has(param))) {
82+
return true;
83+
}
84+
85+
// Check for OAuth: require both a client identifier AND at least one flow parameter
86+
const hasClientIdentifier = clientIdentifiers.some((param) =>
87+
searchParams.has(param)
88+
);
89+
const hasFlowParam = oauthFlowParams.some((param) =>
90+
searchParams.has(param)
91+
);
92+
93+
if (hasClientIdentifier && hasFlowParam) {
94+
return true;
95+
}
96+
6497
// Check frame name for explicit authentication indicators
6598
if (frameName === 'Login' || frameName === 'OAuth' || frameName === 'SSO') {
6699
return true;
@@ -83,7 +116,7 @@ const isAuthenticationPopup = (
83116
return true;
84117
}
85118

86-
// Check for known authentication providers
119+
// Check for known authentication providers (fallback for well-known domains)
87120
const authProviders = [
88121
/^([a-z0-9-]+\.)*google\.com$/,
89122
/^([a-z0-9-]+\.)*microsoft\.com$/,

0 commit comments

Comments
 (0)