Skip to content
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

[FIX] OAuth mismatch redirect_uri error #24450

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion client/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../ee/client/ecdh';
import './polyfills';

import './lib/oauthRedirectUri';
import '../lib/oauthRedirectUri';
import './lib/meteorCallWrapper';
import './importPackages';

Expand Down
17 changes: 17 additions & 0 deletions client/lib/oauthRedirectUri.ts → lib/oauthRedirectUri.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import { Meteor } from 'meteor/meteor';
import { OAuth } from 'meteor/oauth';

const { _redirectUri } = OAuth;

const warn = ((): ((message: unknown) => void) => {
if (Meteor.isServer) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { SystemLogger } = require('../server/lib/logger/system');
return (message: unknown): void => {
SystemLogger.warn(message);
};
}

return console.warn;
})();

OAuth._redirectUri = (serviceName: string, config: any, params: unknown, absoluteUrlOptions: unknown): string => {
const ret = _redirectUri(serviceName, config, params, absoluteUrlOptions);

// DEPRECATED: Remove in v5.0.0
// Meteor 2.3 removed ?close from redirect uri so we need to add it back to not break old oauth clients
// https://github.com/meteor/meteor/commit/b5b7306bedc3e8eb241e64efb1e281925aa75dd3#diff-59244f4e0176cb1beed2e287924e97dc7ae2c0cc51494ce121a85d8937d116a5L11
if (!config?.loginStyle && !ret.includes('close')) {
warn(
`Automatically added ?close to 'redirect_uri' for ${serviceName}, this behavior will be removed in v5.0.0.\n` +
"Please update your OAuth config to accept both with and without ?close as the 'redirect_uri'.",
);
return `${ret + (ret.includes('?') ? '&' : '?')}close`;
}

Expand Down
1 change: 1 addition & 0 deletions server/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../ee/server/broker';
import '../app/settings/server/startup';
import '../lib/oauthRedirectUri';
import './lib/logger/startup';
import './importPackages';
import '../imports/startup/server';
Expand Down