r/GoogleAppsScript • u/imthenachoman • Oct 28 '19
Securely allow Google App Engine to internal company network/servers for Google Apps Scripts
It is well documented that Google Apps Script run on Google App Engine servers that would not have access to a company's internal network/server:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
https://developers.google.com/apps-script/guides/jdbc#using_jdbcgetconnectionurl
Per the documentation, if you want a Google Apps Script project to have access to an internal network/server then you will have to white-list Google's IPs. But we all know that isn't the safest option. In fact, the documentation even says so:
Note that using static IP address filtering is not considered a safe and effective means of protection. For example, an attacker could set up a malicious App Engine app which could share the same IP address range as your application. Instead, we suggest that you take a defense in depth approach using OAuth and Certs.
The issue is I cannot find any documentation, reference material, or articles on how best an organization should do what it suggests.
So my question is, how can an organization using G-Suite Enterprise securely allow Google Apps Script projects to access the company's internal network?
2
u/jordvisser Oct 28 '19 edited Oct 28 '19
I have no hands-on knowledge on the subject but I think it's possible.
Create a cloud sql instance and setup cloud vpn for a tunnel to your premise and replicate the data to google and make the instance availble to your gsuite organization.
Search on google for:
Google cloud vpn to on premise
And this link: https://ctrlq.org/code/19978-connect-to-google-cloud-sql-from-apps-script
But definitly come in contact with someone with experience on the subjectmatter ;)
Edit: i forgot one word in my opening sentence, i wrote 'I have' where it should have been 'I have no'
2
u/imthenachoman Oct 29 '19
Replicating all of our data isn’t very practical. We have numerous applications/systems/servers/databases that we want to access. For example, we use an internally hosted Confluence and want to be able to make an API call to it.
2
u/jordvisser Oct 29 '19 edited Oct 29 '19
Understandable.
There was some secure data connector in the past... but cant find good documentation o it..
https://stackoverflow.com/questions/53633449/google-apps-script-fetch-data-from-private-network-vpn
1
u/imthenachoman Oct 30 '19
Google got rid of the secure data connectors. https://developers.google.com/secure-data-connector/?csw=1
I wish they'd bring it back...
2
u/mrkeifer Oct 29 '19
I think /u/jordvisser's answer is probably the approach that you want. If you really are evaluating this for your company - you may want to reach out to your IT security contacts - they may be very particular about doing/allowing this.
2
u/imthenachoman Oct 30 '19
I am talking to them. They are open to the idea if I can find a secure way to do it. There doesn't seem to be a lot of information online -- which is the challenge.
3
u/erickoledadevrel Oct 29 '19
I haven't done the end-to-end setup myself, but I worked with a customer that used Cloud VPN to make their internal applications available to GCP, then wrapped it in the Cloud Identity-Aware Proxy (IAP) to make it publicly accessible. Cloud IAP also allows for programmatic access via OAuth2, and the Apps Script OAuth2 library can be used to generate the appropriate credentials. Samples showing how to use the library to connect to a Cloud-IAP-secured endpoint are available here:
https://github.com/gsuitedevs/apps-script-oauth2/blob/master/samples/CloudIdentityAwareProxy.gs https://github.com/gsuitedevs/apps-script-oauth2/blob/master/samples/CloudIAPServiceAccount.gs