[FIX] Add ?close to OAuth callback url (#24381)

pull/24432/head
Diego Sampaio 4 years ago committed by Pierre Lehnen
parent 6daa041d7f
commit 440ac9b4e0
  1. 16
      client/lib/oauthRedirectUri.ts
  2. 1
      client/main.ts
  3. 3
      client/startup/oauth.ts
  4. 7
      definition/externals/meteor/oauth.d.ts

@ -0,0 +1,16 @@
import { OAuth } from 'meteor/oauth';
const { _redirectUri } = OAuth;
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')) {
return `${ret + (ret.includes('?') ? '&' : '?')}close`;
}
return ret;
};

@ -1,6 +1,7 @@
import '../ee/client/ecdh';
import './polyfills';
import './lib/oauthRedirectUri';
import './lib/meteorCallWrapper';
import './importPackages';

@ -1,5 +1,4 @@
import { Meteor } from 'meteor/meteor';
// @ts-ignore #ToDo: Add definitions for meteor/oauth
import { OAuth } from 'meteor/oauth';
// OAuth._retrieveCredentialSecret is a meteor method modified to also check the global localStorage
@ -8,7 +7,7 @@ import { OAuth } from 'meteor/oauth';
Meteor.startup(() => {
const meteorOAuthRetrieveCredentialSecret = OAuth._retrieveCredentialSecret;
OAuth._retrieveCredentialSecret = (credentialToken: string): string | undefined => {
OAuth._retrieveCredentialSecret = (credentialToken: string): string | null => {
let secret = meteorOAuthRetrieveCredentialSecret.call(OAuth, credentialToken);
if (!secret) {
const localStorageKey = `${OAuth._storageTokenPrefix}${credentialToken}`;

@ -0,0 +1,7 @@
declare module 'meteor/oauth' {
namespace OAuth {
function _redirectUri(serviceName: string, config: any, params: any, absoluteUrlOptions: any): string;
function _retrieveCredentialSecret(credentialToken: string): string | null;
const _storageTokenPrefix: string;
}
}
Loading…
Cancel
Save