Skip to content

Commit a88a3d6

Browse files
committed
fix cf10 compatibility issue with cfhttp calls with proxy settings
1 parent a4044e0 commit a88a3d6

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

packages/security/GoogleUserDirectory.cfc

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,19 @@
166166
<cfif len(arguments.proxy)>
167167
<cfif listlen(arguments.proxy,"@") eq 2>
168168
<cfset stResult.login = listfirst(arguments.proxy,"@") />
169-
<cfset stResult.user = listfirst(stResult.login,":") />
170-
<cfset stResult.password = listlast(stResult.login,":") />
169+
<cfset stResult.proxyUser = listfirst(stResult.login,":") />
170+
<cfset stResult.proxyPassword = listlast(stResult.login,":") />
171171
<cfelse>
172-
<cfset stResult.user = "" />
173-
<cfset stResult.password = "" />
172+
<cfset stResult.proxyUser = "" />
173+
<cfset stResult.proxyPassword = "" />
174174
</cfif>
175175
<cfset stResult.server = listlast(arguments.proxy,"@") />
176-
<cfset stResult.domain = listfirst(stResult.server,":") />
176+
<cfset stResult.proxyServer = listfirst(stResult.server,":") />
177177
<cfif listlen(stResult.server,":") eq 2>
178-
<cfset stResult.port = listlast(stResult.server,":") />
178+
<cfset stResult.proxyPort = listlast(stResult.server,":") />
179179
<cfelse>
180-
<cfset stResult.port = "80" />
180+
<cfset stResult.proxyPort = "80" />
181181
</cfif>
182-
<cfelse>
183-
<cfset stResult.user = "" />
184-
<cfset stResult.password = "" />
185-
<cfset stResult.domain = "" />
186-
<cfset stREsult.port = "80" />
187182
</cfif>
188183

189184
<cfreturn stResult />
@@ -219,14 +214,14 @@
219214
<cfset var stResult = structnew() />
220215
<cfset var stProxy = parseProxy(arguments.proxy) />
221216

222-
<cfhttp url="https://accounts.google.com/o/oauth2/token" method="POST" proxyServer="#stProxy.domain#" proxyPort="#stProxy.port#" proxyUser="#stProxy.user#" proxyPassword="#stProxy.password#">
217+
<cfhttp url="https://accounts.google.com/o/oauth2/token" method="POST" attributeCollection="#stProxy#">
223218
<cfhttpparam type="formfield" name="code" value="#arguments.authorizationCode#" />
224219
<cfhttpparam type="formfield" name="client_id" value="#arguments.clientID#" />
225220
<cfhttpparam type="formfield" name="client_secret" value="#arguments.clientSecret#" />
226221
<cfhttpparam type="formfield" name="redirect_uri" value="#arguments.redirectURL#" />
227222
<cfhttpparam type="formfield" name="grant_type" value="authorization_code" />
228223
</cfhttp>
229-
224+
230225
<cfif not cfhttp.statuscode eq "200 OK">
231226
<cfset throwError(message="Error accessing Google API: #cfhttp.statuscode#",endpoint="https://accounts.google.com/o/oauth2/token",response=cfhttp.filecontent,argumentCollection=arguments) />
232227
</cfif>
@@ -248,7 +243,7 @@
248243
<cfset var stProxy = parseProxy(arguments.proxy) />
249244

250245
<cfif isdefined("arguments.refresh_token") and datecompare(arguments.access_token_expires,now()) lt 0>
251-
<cfhttp url="https://accounts.google.com/o/oauth2/token" method="POST" proxyServer="#stProxy.domain#" proxyPort="#stProxy.port#" proxyUser="#stProxy.user#" proxyPassword="#stProxy.password#">
246+
<cfhttp url="https://accounts.google.com/o/oauth2/token" method="POST" attributeCollection="#stProxy#">
252247
<cfhttpparam type="formfield" name="refresh_token" value="#arguments.refreshToken#" />
253248
<cfhttpparam type="formfield" name="client_id" value="#arguments.clientID#" />
254249
<cfhttpparam type="formfield" name="client_secret" value="#arguments.clientSecret#" />
@@ -278,7 +273,7 @@
278273
<cfset var stResult = structnew() />
279274
<cfset var stProxy = parseProxy(arguments.proxy) />
280275

281-
<cfhttp url="https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=#arguments.accessToken#" method="GET" proxyServer="#stProxy.domain#" proxyPort="#stProxy.port#" proxyUser="#stProxy.user#" proxyPassword="#stProxy.password#" />
276+
<cfhttp url="https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=#arguments.accessToken#" method="GET" attributeCollection="#stProxy#" />
282277

283278
<cfif not cfhttp.statuscode eq "200 OK">
284279
<cfset throwError(message="Error accessing Google API: #cfhttp.statuscode#",endpoint="https://www.googleapis.com/oauth2/v1/tokeninfo",response=cfhttp.filecontent,argumentCollection=arguments) />
@@ -303,10 +298,10 @@
303298
<cfset var stResult = structnew() />
304299
<cfset var stProxy = parseProxy(arguments.proxy) />
305300

306-
<cfhttp url="https://www.googleapis.com/oauth2/v1/userinfo" method="GET" proxyServer="#stProxy.domain#" proxyPort="#stProxy.port#" proxyUser="#stProxy.user#" proxyPassword="#stProxy.password#">
301+
<cfhttp url="https://www.googleapis.com/oauth2/v1/userinfo" method="GET" attributeCollection="#stProxy#">
307302
<cfhttpparam type="header" name="Authorization" value="Bearer #arguments.accessToken#" />
308303
</cfhttp>
309-
304+
310305
<cfif not cfhttp.statuscode eq "200 OK">
311306
<cfset throwError(message="Error accessing Google API: #cfhttp.statuscode#",endpoint="https://www.googleapis.com/oauth2/v1/userinfo",response=cfhttp.filecontent,argumentCollection=arguments) />
312307
</cfif>

0 commit comments

Comments
 (0)