@@ -65,8 +65,11 @@ const signedOutAfterTokensIssued = ({
65
65
// where the middleware may continually keep running performAuthorizationCodeFlow().
66
66
guSoTimestamp <= Math . floor ( Date . now ( ) / 1000 ) ;
67
67
68
- export const withIdentity : ( statusCodeOverride ?: number ) => RequestHandler =
69
- ( statusCodeOverride ?: number ) =>
68
+ export const withIdentity : (
69
+ statusCodeOverride ?: number ,
70
+ keepQueryParams ?: boolean ,
71
+ ) => RequestHandler =
72
+ ( statusCodeOverride ?: number , keepQueryParams ?: boolean ) =>
70
73
async ( req : Request , res : Response , next : NextFunction ) => {
71
74
if ( CYPRESS === 'SKIP_IDAPI' ) {
72
75
return next ( ) ;
@@ -80,7 +83,13 @@ export const withIdentity: (statusCodeOverride?: number) => RequestHandler =
80
83
: { } ;
81
84
const oktaConfig = await getOktaConfig ( oktaConfigOverride ) ;
82
85
if ( oktaConfig . useOkta ) {
83
- return authenticateWithOAuth ( req , res , next , oktaConfig ) ;
86
+ return authenticateWithOAuth (
87
+ req ,
88
+ res ,
89
+ next ,
90
+ oktaConfig ,
91
+ keepQueryParams ,
92
+ ) ;
84
93
} else {
85
94
return authenticateWithIdapi ( statusCodeOverride ) (
86
95
req ,
@@ -98,10 +107,12 @@ export const authenticateWithOAuth = async (
98
107
res : Response ,
99
108
next : NextFunction ,
100
109
oktaConfig : OktaConfig ,
110
+ keepQueryParams : boolean = false ,
101
111
) => {
102
112
// Get the path of the current page and use it as our returnPath after the OAuth callback.
103
- const returnPath = sanitizeReturnPath ( req . originalUrl ) ;
104
-
113
+ const returnPath = keepQueryParams
114
+ ? req . originalUrl
115
+ : sanitizeReturnPath ( req . originalUrl ) ;
105
116
try {
106
117
const verifiedTokens = await verifyOAuthCookiesLocally ( req ) ;
107
118
const guSoTimestamp = parseInt ( req . cookies [ 'GU_SO' ] ) ;
0 commit comments