mapbox / mapbox-studio-classic

https://www.mapbox.com/mapbox-studio/
BSD 3-Clause "New" or "Revised" License
1.14k stars 229 forks source link

OAuth proxy #860

Open behboud opened 10 years ago

behboud commented 10 years ago

We have a coporate proxy. Trying to run mapbox studio we get following error:

Mapbox Studio @ http://localhost:3000/
Error: Access denied
    at Object.app.use.passport.authenticate.session [as handle] (/home/q/dev/mapbox/mapbox-studio/lib/oauth.js:66:14)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:165:78)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:165:78)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:165:78)
    at Object.initialize [as handle] (/home/q/dev/mapbox/mapbox-studio/node_modules/passport/lib/middleware/initialize.js:62:5)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.expressInit [as handle] (/home/q/dev/mapbox/mapbox-studio/node_modules/express/lib/middleware.js:31:5)
    at next (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.query [as handle] (/home/q/dev/mapbox/mapbox-studio/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)
{ [InternalOAuthError: Failed to obtain access token]
  name: 'InternalOAuthError',
  message: 'Failed to obtain access token',
  oauthError: { [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' } }

I think this is because of the oauth not using http_proxy environment variable. Is there a workaround?

petzlux commented 10 years ago

I have the same problem, but have built from source, and set the npm proxy config parameters:

npm config set proxy http://proxy.company.com:8080 npm config set https-proxy http://proxy.company.com:8080

Still no luck !

stev-0 commented 10 years ago

I also have this issue on the prebuild 0.1.5 Windows binary and get the error message 500 'GET' '/oauth/mapbox?error=access_denied' 'Err... which I assume is the same as the error above but with the less detailed error message.

thhomas commented 10 years ago

Same issue on 0.1.5 Mac OS X version Mapbox Studio @ http://localhost:3000/ 500 'GET' '/oauth/mapbox?error=access_denied' 'Error: Access denied'

petzlux commented 10 years ago

Okay, one month later no progress on this :-(

thhomas commented 9 years ago

Error on 0.2.0 Mac OS X version: Mapbox Studio @ http://localhost:3000/ 500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'

guzmanlopez commented 9 years ago

On Linux Mint Debian Edition (LMDE):

Same error:

500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'

wilhelmberg commented 9 years ago

@bebud @petzlux @stev-0 @thhomas @guzmanlopez

Could you try this version and let me know, if it works for you:

Windows: https://mapbox.s3.amazonaws.com/mapbox-studio/mapbox-studio-win32-x64-proxy-enabled.exe

Ubuntu 14.04: https://mapbox.s3.amazonaws.com/mapbox-studio/mapbox-studio-linux-x64-proxy-enabled.zip

OS X: https://mapbox.s3.amazonaws.com/mapbox-studio/mapbox-studio-darwin-x64-proxy-enabled.zip

You have to set your proxy information into environment variables before you start Mapbox Studio.

Windows:

SET HTTP_PROXY=http://YOUR-PROXY-SERVER:PORT
SET HTTPS_PROXY=https://YOUR-PROXY-SERVER:PORT
cd C:\Program Files\mapbox-studio
mapbox-studio.exe

Linux;

export HTTP_PROXY=http://YOUR-PROXY-SERVER:PORT
export HTTPS_PROXY=https://YOUR-PROXY-SERVER:PORT
cd into the directory you extracted the zip to
./atom
thhomas commented 9 years ago

Some changes but still an error:

[7134:1204/113046:INFO:CONSOLE(0)] "The page at 'https://www.mapbox.com/authorize/?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth%2Fmapbox&client_id=d8e0abd43fdbafe43c4fdc6059039595bd95518c4982050662d94c134c5538ea' was loaded over HTTPS, but displayed insecure content from 'http://cotads.adscale.de/ads/pixel/1by1.png': this content should also be loaded over HTTPS. ", source: https://www.mapbox.com/authorize/?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth%2Fmapbox&client_id=d8e0abd43fdbafe43c4fdc6059039595bd95518c4982050662d94c134c5538ea (0) api.mapbox.com 443 https://api.mapbox.com/oauth/access_token POST using proxy parsedUrl { protocol: 'https:', slashes: true, auth: null, host: 'api.mapbox.com', port: 443, hostname: 'api.mapbox.com', hash: null, search: '', query: {}, pathname: '/oauth/access_token', path: '/oauth/access_token', href: 'https://api.mapbox.com/oauth/access_token' } parsedproxy { protocol: 'http:', slashes: true, auth: null, host: 'myproxy:myport', port: 'myport', hostname: 'myproxy', hash: null, search: null, query: null, pathname: '/', path: '/', href: 'http://myproxy:myport/' } have parsedproxy using http options { host: 'myproxy', port: 'myport', path: 'https://api.mapbox.com/oauth/access_token', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', Host: 'api.mapbox.com', 'User-Agent': 'Node-oauth', 'Content-Length': 486 } } post_body grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth%2Fmapbox&client_id=d8e0abd43fdbafe43c4fdc6059039595bd95518c4982050662d94c134c5538ea&client_secret=aa13e1d37afdd2889a237386f2ee3c06e68c19f5b219a7477acd462c10f36af8&code=WrgSpfsuwTryzYndvWRwSA.6Uki5lshvEkqZuyl0F_9kWbyWZnN4AvtClmL-N6ad2M2Qa5hLCn_rK-i0qCvKDJLwye2KEZaNi4TF2OUKJgo3XrxCYd7h2rkoj-nN0I_hCR060grGt3qRjqQD5dp8do4aBglDFs2YhdrWngqKxf6gA.1417689047238.60000.cNKY9sLUbWEH588erHN0lS4NSsVPXdQlZPCuddWBXYY { [InternalOAuthError: Failed to obtain access token] name: 'InternalOAuthError', message: 'Failed to obtain access token', oauthError: { statusCode: 501, data: '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>ERREUR: L\'URL demandée n\'a pu être chargée</title> <style type="text/css"><!-- %l body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; float: right; } --></style> </head><body> <div id="titles"> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> </div> <hr> <div id="content"> <p>L\'erreur suivante a été rencontrée en essayant d\'accéder à l\'URL : <a href="https://api.mapbox.com/oauth/access_token">https://api.mapbox.com/oauth/access_token</a></p> <blockquote id="error"> <p><b>Combinaison de méthode et de protocole non gérée</b></p> </blockquote> <p>Squid ne permet pas toutes les méthodes de requêtes pour tous les protocoles. Vous ne pouvez par exemple pas utiliser le protocole POST dans une requête Gopher.</p> <p>Votre administrateur de cache est <a href="mailto:postmaster@myhost.fr">postmaster@myhost.fr</a>.</p> <br> </div> <hr> <div id="footer"> <p>Générée le Thu, 04 Dec 2014 10:30:47 GMT par proxy (squid/2.7.STABLE9)</p> <!-- ERR_UNSUP_REQ --> </div> </body></html> ' } }

petzlux commented 9 years ago

Also still doesnt work for me. Where can I see the detailed logs ?

behboud commented 9 years ago

tried on Windows. Got Authorization failed.

guzmanlopez commented 9 years ago

Thanks BergWerkGIS, but I tried on LMDE and it didn't work.The GUI freezes.

guzman@dinara5058:~/Downloads/mapbox-studio-linux-x64-proxy-enabled$ ./atom

[5317:1204/094424:ERROR:browser_main_loop.cc(162)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on. [5317:1204/094424:WARNING:proxy_config_service_linux.cc(83)] Proxy authentication parameters ignored, see bug 16709 [5348:1204/094424:INFO:renderer_main.cc(204)] Renderer process started Mapbox Studio @ http://localhost:3000/ [5371:1204/094425:INFO:renderer_main.cc(204)] Renderer process started [5317:1204/094425:WARNING:file_descriptor_set_posix.cc(22)] FileDescriptorSet destroyed with unconsumed descriptors [5385:1204/094427:INFO:renderer_main.cc(204)] Renderer process started

Test Proxy:

guzman@dinara5058:~$ env | grep -i proxy

http_proxy=http://xxxxx:xxxxx@10.5.1.5:8080 ftp_proxy=http://xxxxx:xxxxx@10.5.1.5:8080 https_proxy=https://xxxxx:xxxxx@10.5.1.5:8080 no_proxy=localhost,127.0.0.0/8,::1

wilhelmberg commented 9 years ago

@petzlux in ~/.mapbox-studio/app.log or C:\Users\<YOUR-USER-NAME>\.mapbox-studio\app.log, depending on your OS.

@bebud are you sure, you used correct credentials?

@thhomas looking at the log it seems that you are using http://myproxy:myport/, could you replace those with real settings?

@guzmanlopez thanks, I'll have another look to check if the proxy authentication parameters get passed along correctly.

wilhelmberg commented 9 years ago

New version, same procedure (console and env vars) and links as above.

Please try and let me know. Sorry, no proxy authentication yet.

petzlux commented 9 years ago

Nope :-(

gcc538@mac-mini:~$ tail .mapbox-studio/app.log 
Mapbox Studio @ http://localhost:3000/
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
Mapbox Studio @ http://localhost:3000/
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
Mapbox Studio @ http://localhost:3001/
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
gcc538@mac-mini:~$ wget https://a.tiles.mapbox.com
--2014-12-05 09:02:32--  https://a.tiles.mapbox.com/
Resolving cie-vproxy2.cie.etat.lu... 148.110.130.35
Connecting to cie-vproxy2.cie.etat.lu|148.110.130.35|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 16 [application/json]
Saving to: 'index.html.3'
100%[===================================================================================>] 16          --.-K/s   in 0s      
2014-12-05 09:02:32 (1.27 MB/s) - 'index.html.3' saved [16/16]
gcc538@mac-mini:~$ 
thhomas commented 9 years ago

I replaced in log my company info by fake one that is why you saw http://myproxy:myport/.

I tried the new version, now I can access the pages. But when I choose a style, I get a 500 error: 500 'GET' '/new/style?id=tmpstyle:///Volumes/Vol-Users/Users/ttilak/Downloads/mapbox-studio-darwin-x64-proxy-enabled%202/Mapbox%20Studio.app/Contents/Resources/app/node_modules/mapbox-studio-wheatpaste' 'Error: Timed out after 5000ms' 500 'GET' '/new/style?id=tmpstyle:///Volumes/Vol-Users/Users/ttilak/Downloads/mapbox-studio-darwin-x64-proxy-enabled%202/Mapbox%20Studio.app/Contents/Resources/app/node_modules/mapbox-studio-comic' 'Error: Timed out after 5000ms'

guzmanlopez commented 9 years ago

I couldn't:

guzman@dinara5058:~/Descargas/mapbox-studio-linux-x64-proxy-enabled$ ./atom [6482:1205/144950:ERROR:browser_main_loop.cc(162)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on. [6482:1205/144950:WARNING:proxy_config_service_linux.cc(83)] Proxy authentication parameters ignored, see bug 16709 [6482:1205/144950:WARNING:proxy_config_service_linux.cc(83)] Proxy authentication parameters ignored, see bug 16709 [6513:1205/144950:INFO:renderer_main.cc(204)] Renderer process started Mapbox Studio @ http://localhost:3000/ [6536:1205/144951:INFO:renderer_main.cc(204)] Renderer process started [6552:1205/144953:INFO:renderer_main.cc(204)] Renderer process started 500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'

But I can connect to "Report on GitHub". I mean, I have internet access through Mapbox Studio.

wilhelmberg commented 9 years ago

Could you try the new version of today and let me know, how it goes? Same links and procedure as described above.

thhomas commented 9 years ago

Seems to be working for me now.

guzmanlopez commented 9 years ago

It didn't work for me on LMDE:

guzman@dinara5058:~/Descargas/mapbox-studio-linux-x64-proxy-enabled$ ./atom

[4938:1208/112522:ERROR:browser_main_loop.cc(162)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on. [4938:1208/112522:WARNING:proxy_config_service_linux.cc(83)] Proxy authentication parameters ignored, see bug 16709 [4938:1208/112522:WARNING:proxy_config_service_linux.cc(83)] Proxy authentication parameters ignored, see bug 16709 [4968:1208/112522:INFO:renderer_main.cc(204)] Renderer process started Mapbox Studio @ http://localhost:3000/ [4993:1208/112523:INFO:renderer_main.cc(204)] Renderer process started

wilhelmberg commented 9 years ago

@thhomas great!

@guzmanlopez

That seems to be an upstream issue that has been unresolved since 2009.

Could you try:

export <your-proxy-settings>

cd <extracted-studio-directory>/resources/app
./vendor/node index

and then use your browser of choise to visit localhost:3000

guzmanlopez commented 9 years ago

@BergWerkGIS

It seems it's working now! Thanks a lot!

wilhelmberg commented 9 years ago

@guzmanlopez great! Now that you are authenticated, could you try running ./atom again and see if this works.

guzmanlopez commented 9 years ago

@BergWerkGIS

Perfect, now it works with atom!!!

petzlux commented 9 years ago

Nope :-(

gcc538@mac-mini:~/.mapbox-studio$ env | grep proxy
http_proxy=http://cie-vproxy2.cie.etat.lu:8080
https_proxy=http://cie-vproxy2.cie.etat.lu:8080
HTTPS_PROXY=http://cie-vproxy2.cie.etat.lu:8080
HTTP_PROXY=http://cie-vproxy2.cie.etat.lu:8080
gcc538@mac-mini:~/.mapbox-studio$ tail app.log 
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
500 'GET' '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' 'Error: Cannot find Mapbox API at https://a.tiles.mapbox.com'
behboud commented 9 years ago

@BergWerkGIS works on windows :)

wilhelmberg commented 9 years ago

@bebud great to hear.

@petzlux could you tell me a bit more about your proxy? Like what software are you using or are you aware of other special settings?

petzlux commented 9 years ago

@BergWerkGIS

Unfortunately, the proxy is not under my control, nor even under our departments control. We have had difficulty with other software to make it work. Under Python, the problem was that some versions of urllib do not send a proper User-Agent, and our proxy needs a https request to have a proper user agent to let it through. Same with NPM, where it only works with NPM v2 or higher.

Hope these explanations help .

wilhelmberg commented 9 years ago

@petzlux thanks for the information. Unfortunately there are still some questions left to replicate your proxy in our environment.

It should be easy to connect as I'm located in Austria and we are on the same time zone.

petzlux commented 9 years ago

@BergWerkGIS

Here are some answers:

DerekOverlock commented 9 years ago

Can someone build a new proxy-enabled version that matches what's on mapbox.com? It seems that they are different versions (besides one allowing for proxies).

springmeyer commented 9 years ago

@DerekOverlock - I just updated the branch we are using to to test things. If things look good them I'll build another package that will be available perhaps later today at the same links at above (https://github.com/mapbox/mapbox-studio/issues/860#issuecomment-65508867).

springmeyer commented 9 years ago

@DerekOverlock tests passed so I pushed a new build. So https://mapbox.s3.amazonaws.com/mapbox-studio/mapbox-studio-win32-x64-proxy-enabled.exe should be updated in about 30 minutes. Download it then to try again.

DerekOverlock commented 9 years ago

@springmeyer, kudos for response time. Works great. Thanks!

springmeyer commented 9 years ago

\o/

cjgage commented 9 years ago

Hi, I'm getting this problem when trying to start up Mapbox Studio:

image

Tried following the comments above but not techy enough (or authorised) to start playing around with proxy settings. @springmeyer I installed your link but same outcome.

Are there any other solutions?

Thanks

wilhelmberg commented 9 years ago

@cjgage

Have you set the environment variables and started Studio from the command prompt? Like this https://github.com/mapbox/mapbox-studio/issues/860#issuecomment-65508867

cjgage commented 9 years ago

Thanks @BergWerkGIS - where do I enter this code?

wilhelmberg commented 9 years ago

@cjgage On the command prompt.

image

cjgage commented 9 years ago

@BergWerkGIS getting this result: image

wilhelmberg commented 9 years ago

@cjgage did you also see Cannot find Mapbox API error or did Studio exit immediately?

cjgage commented 9 years ago

@BergWerkGIS immediate exit

wilhelmberg commented 9 years ago

@cjgage any additional information in %USERPROFILE%\.mapbox-studio\app.log (except Mapbox Studio @ http://localhost:3000/)?

cjgage commented 9 years ago

@BergWerkGIS <Mon, 09 Feb 2015 10:11:25 GMT> Mapbox Studio @ http://localhost:3000/ <Mon, 09 Feb 2015 10:11:32 GMT> error 500 { [Error: Cannot find Mapbox API at https://a.tiles.mapbox.com] method: 'GET', url: '/oauth/config?MapboxAPITile=https%3A%2F%2Fa.tiles.mapbox.com' }

wilhelmberg commented 9 years ago

@cjgage

Could you open a command prompt like before and enter:

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"

What's the output? Are these the same settings you used for SET HTTP_PROXY= and SET HTTPS_PROXY=?

wilhelmberg commented 9 years ago

@cjgage When you enter netsh winhttp show proxy, what does that give you?

cjgage commented 9 years ago

@BergWerkGIS "Direct access (no proxy server)."

wilhelmberg commented 9 years ago

@cjgage And what's the output of

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"
cjgage commented 9 years ago

@BergWerkGIS nothing just blank prompt

wilhelmberg commented 9 years ago

@cjgage Then you probably don't have a proxy?!

2 things to try:

1. Again on the command prompt, what does ping a.tiles.mapbox.com give you?

2.a. go into Internet Explorer -> click on gear icon on top right (Tools) -> Internet options -> Connections -> LAN settings Post a screenshot of the last dialog.

2.b. If you can click on Advanced on the last dialog, also post a screen shot of the dialog that opens afterwards.

cjgage commented 9 years ago

@BergWerkGIS image