Skip to content

feat(authorization): skip undefined/empty query parameter #4124

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions packages/server/lib/controllers/oauth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,20 @@ class OAuthController {
});
}

if (provider.authorization_url_skip_empty) {
const url = new URL(authorizationUri);
const queryParams = new URLSearchParams(url.search);
// Remove any keys with undefined or empty string values
for (const [key, value] of queryParams.entries()) {
if (value === '') {
queryParams.delete(key);
}
}

url.search = queryParams.toString();
authorizationUri = url.toString();
}

void logCtx.info('Redirecting', {
authorizationUri,
providerConfigKey,
Expand Down
1 change: 1 addition & 0 deletions packages/types/lib/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface BaseProvider {
};
authorization_url?: string;
authorization_url_skip_encode?: string[];
authorization_url_skip_empty?: boolean;
access_token_url?: string;
authorization_params?: Record<string, string>;
authorization_code_param_in_callback?: string;
Expand Down
Loading