-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accessing a Vouch Proxy domain using Google App Script? #432
Comments
@tahuk I'm not familiar with Google App Scripts. Could you please clarify your use case and describe in plain terms what you're trying to do? Are you trying to use javascript to access Google Docs? I would love to understand what you're doing. |
Yes, partially. I'd like to use Google App Script (essentially JavaScript) to access a domain protected with Vouch. The use case here is that we have a 3rd party web app I was previously able to access using the API. https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app The app in question is Zabbix, API docs link: https://www.zabbix.com/documentation/current/manual/api/reference/user/login Per the Zabbix docs, I was able to do something like:
However, now we have moved the web app to a Vouch domain, and when the same request, I am only returned the 'sign in with Google' HTML. I thought that maybe I could use .getOAuthToken() to authenticate my user and log me in but I was not aware of the Vouch oAuth flow. I am fairly comfortable in Javascript/Google App Script, but not aware at all of Nginx or the concepts used here. In my post, I reference how to get and send cookies as a header, so I'm sure it must be possible but what I want to be able to do is some sort of request that effectively logs me in and then allows me to fetch like the Zabbix API example above. Does that help? |
@tahuk thanks for sharing a bit more about what's going on The user information from VP can be passed down to an application (such as Zabbix) via HTTP headers. It's a bit of a hack but by making an fetch request to @tahuk would that work? We have talked on occasion about offering a mechanism to access the user's information via a javascript library but we have not approached a design in earnest. The Vouch Proxy JWT is held in a cookie and could be parsed but that would require decompressing the cookie and evaluating the blob including the signature. The JWT may be held in several similarly named cookies due to browser cookie size limitations so this is a bit of an operation. [1] https://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript |
@bnfinet Thanks. I'm not needing to pass anything to Zabbix in this instance, but do want to get enough to login to Google. Another example would be if I had mydomain.com/file.csv, I want to be able to view file.csv programmatically. I can't see any This is what I've tried so far: Have tried both auth in my request header, either:
Request URL: Zabbix install URL
Request URL: Zabbix install URL
Request URL: https://vouch.oursites.com/validate
Request URL: https://vouch.oursites.com/validate/login?url=https://ZABBIX-URL/
Request URL: https://accounts.google.com/o/oauth2/auth?client_id=114..........kh.apps.googleusercontent.com&hd=oursites.com&redirect_uri=https%3A%2F%2Fvouch.oursites.com%2Fauth&response_type=code&scope=email&state=pEMPv0.................OkR1k
|
just use https://vouch.oursites.com/validate for the time being try Could you please include the response codes, like "200 OK" or "401 Not Authorized" as well, really all info returned by the response header would be helpful. |
Thanks, with Request URL: https://vouch.oursites.com/validate
|
@tahuk excellent, now we're getting somewhere. Try it with My suspicion is that the VP cookies (multiple as per #109) are being sent but are not recombined into a working JWT. Could you please use developer tools to look at the cookies? You're going to have to ferret out how to proceed and try some things. Can you please post your fetch code to a repo or gist? Have you been discussing your issue with your SRE/devops/sysadmin? They may be able to advise you on how to make that request to |
@bnfinet The fetch code is just:
Assuming In which case I get: HTTP 200
I'm not sure how to get dev tools or similar in the google app script code editor, but I can return things like the header as above but can also get blobs, like downloading a pdf or an image and doing stuff with them.
I haven't but do intend to, but I'd be surprised if they really knew much more than following your installation guide etc. |
yes, please put that in a gist or repo so I can link to line numbers and you can revise and update the code instead of cutting and pasting it here a bunch of times.
yes, the URL of the original request as carried in javascript at I didn't appreciate that you were using google app script code editor. I assumed you were writing js at zabbix.yourdomain.com or something similar What domain is this code running at? Is it in
Could you please ask them to chime into this thread with the Nginx config, etc posted to a |
@tahuk there's two problems I see in the fetch code and a few things we could try out as well. As soon as it's in a gist I'll be happy to highlight them :) |
@bnfinet https://gist.github.com/tahuk/7ac8c00ed6c83776dbc7fc8a9af8349e Sorry for the delay! |
comment these out https://gist.github.com/tahuk/7ac8c00ed6c83776dbc7fc8a9af8349e#file-authvouch-gs-L9-L10
If that doesn't work, use |
To answer previous question. The script is running from a Google server, not on the same domain as the VP. I am using the
|
Are you saying that your script is running outside of a VP protected domain? I was assuming that Zabbix was protected by VP and that you were logging into Google via VP and then getting access to Zabbix where your script is running. But I think I'm hearing that that's not what you're attempting, your trying to access Zabbix which is protected by VP without first logging into Zabbix and from a different domain. Do I have that right? That's not going to work. |
@bnfinet Correct. I am authorising the script as myself, using https://developers.google.com/apps-script/reference/script/script-app#getOAuthToken() I would have expected VP to accept this as if the user was typing in their user/pass. |
@tahuk that's not how VP works VP forwards a user to the IdP (google). After the user authenticates with the IdP (with username and password or otherwise) the user is forwaded back to VP at which point VP issues its own token. VP does not ever receive the IdP login credentials (username and password). The VP token is (almost always) carried in a cookie. That cookie is only available within the shared VP protected domain. I'm going to close this though you're welcome to continue the conversation. There has been some talk of developing other access mechanisms for VP but I can't see Google App Script being the right stating point for that effort. |
Hi @bnfinet -- I'll quickly reopen this one to clarify one thing. Are you saying that protected domain such as: https://api.domain.com can't be accessed from anywhere else other than the local apps that are running under the same scope/server (such as: https://app.domain.com, https://www.domain.com, etc), basically the ones that share the VouchCookie? So if I wanted to Authenticate/Authorize using the Bearer token when making a Basically, the protection is only in the scope of the existing cookie which is created when the user manually logs-in. It's not possible to use Bearer token from either Vouch or IDP to access the protected server/api? |
I am trying to programmatically access a vouch domain using Google App Script.
I would normally be able to do something like:
Following the oAuth flow, I am trying to understand how I can access the cookie or state in order to progress. I was hoping I might be able to do something like:
What further do I need to do in order to effectively authenticate using GAS?
The text was updated successfully, but these errors were encountered: