File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
packages/apollo-collaboration-server Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 6363 "express" : " ^4.18.0" ,
6464 "express-session" : " ^1.17.3" ,
6565 "generic-filehandle" : " ^3.0.0" ,
66+ "https-proxy-agent" : " ^7.0.6" ,
6667 "joi" : " ^17.7.0" ,
6768 "material-ui-popup-state" : " ^5.0.4" ,
6869 "mobx" : " ^6.6.1" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import fs from 'node:fs'
33import { Injectable , Logger } from '@nestjs/common'
44import { ConfigService } from '@nestjs/config'
55import { PassportStrategy } from '@nestjs/passport'
6+ import { HttpsProxyAgent } from 'https-proxy-agent'
67import { Profile , Strategy } from 'passport-google-oauth20'
78
89import { AuthenticationService } from '../../authentication/authentication.service'
@@ -62,6 +63,22 @@ export class GoogleStrategy extends PassportStrategy(Strategy) {
6263 scope : [ 'email' , 'profile' ] ,
6364 store : true ,
6465 } )
66+
67+ // Apply proxy to OAuth2 instance
68+ const proxy = process . env . HTTPS_PROXY ?? process . env . HTTP_PROXY
69+ if ( proxy ) {
70+ const agent = new HttpsProxyAgent ( proxy )
71+
72+ // Access the internal OAuth2 instance and set the agent
73+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
74+ const oauth2 = ( this as any ) . _oauth2
75+ if ( oauth2 ) {
76+ // https://github.com/ciaranj/node-oauth/blob/master/lib/oauth2.js#L20
77+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
78+ oauth2 . _agent = agent
79+ this . logger . debug ( `GoogleStrategy configured to use proxy: ${ proxy } ` )
80+ }
81+ }
6582 }
6683
6784 async validate ( accessToken : string , refreshToken : string , profile : Profile ) {
Original file line number Diff line number Diff line change @@ -409,6 +409,7 @@ __metadata:
409409 express: "npm:^4.18.0"
410410 express-session: "npm:^1.17.3"
411411 generic-filehandle: "npm:^3.0.0"
412+ https-proxy-agent: "npm:^7.0.6"
412413 jest: "npm:^29.6.2"
413414 joi: "npm:^17.7.0"
414415 material-ui-popup-state: "npm:^5.0.4"
@@ -11513,6 +11514,13 @@ __metadata:
1151311514 languageName: node
1151411515 linkType: hard
1151511516
11517+ "agent-base@npm:^7.1.2":
11518+ version: 7.1.4
11519+ resolution: "agent-base@npm:7.1.4"
11520+ checksum: 10c0/c2c9ab7599692d594b6a161559ada307b7a624fa4c7b03e3afdb5a5e31cd0e53269115b620fcab024c5ac6a6f37fa5eb2e004f076ad30f5f7e6b8b671f7b35fe
11521+ languageName: node
11522+ linkType: hard
11523+
1151611524"agentkeepalive@npm:^4.1.3, agentkeepalive@npm:^4.2.1":
1151711525 version: 4.5.0
1151811526 resolution: "agentkeepalive@npm:4.5.0"
@@ -19663,6 +19671,16 @@ __metadata:
1966319671 languageName: node
1966419672 linkType: hard
1966519673
19674+ "https-proxy-agent@npm:^7.0.6":
19675+ version: 7.0.6
19676+ resolution: "https-proxy-agent@npm:7.0.6"
19677+ dependencies:
19678+ agent-base: "npm:^7.1.2"
19679+ debug: "npm:4"
19680+ checksum: 10c0/f729219bc735edb621fa30e6e84e60ee5d00802b8247aac0d7b79b0bd6d4b3294737a337b93b86a0bd9e68099d031858a39260c976dc14cdbba238ba1f8779ac
19681+ languageName: node
19682+ linkType: hard
19683+
1966619684"human-signals@npm:^1.1.1":
1966719685 version: 1.1.1
1966819686 resolution: "human-signals@npm:1.1.1"
You can’t perform that action at this time.
0 commit comments