laravel-saml2 icon indicating copy to clipboard operation
laravel-saml2 copied to clipboard

Can this work via Valet and ngrok?

Open nspaul opened this issue 5 years ago • 3 comments

I have this package working when it runs on a publicly available server. My next step is to try and get it working in my local dev environment. I am easily able to run valet share and visit my Laravel app via the ngrok URL provided. However, when I use the exact same config from my production site (the one that is currently working and using the laravel-saml2 package successfully), it appears that my metadata does not come out properly. Specifically, the entityID is using http instead of https.

Has anyone gotten this package to work in a local dev environment? I'd love to continue developing locally rather than develop on a publicly accessible server.

nspaul avatar Dec 20 '19 12:12 nspaul

I'm currently using this package for login using valet in a local app, the integration was pretty smooth. You can configure the entityID I believe in saml2_settings to use an env variable

hemorej avatar Dec 20 '19 16:12 hemorej

I think I am close. What's interesting now is that when I visit the /saml2//metadata, using https in the URL, I'm not seeing https in the corresponding URLs.

There are two interesting data points here, that maybe someone can see and know what is going on:

When using Valet locally, and I go to https://.test/saml2//metadata, the URLs listed in the metadata have https prepended. This includes the "entityID" at the top, and the SLS and ACS URLs further down.

When hosting the site out via ngrok and hitting the ngrok URL in a browser, such as https://123abc.ngrok.io/saml2//metadata, it does not have https prepended to those same URLs.

This is the same folder on my machine, I'm just accessing it differently (one locally via Valet using the .test URL, and the other via "valet share" command and then using the ngrok URL given to me.

nspaul avatar Jan 02 '20 14:01 nspaul

If you're serving on port 80 from your web server, Laravel's URL generator doesn't know to generate HTTPS URLs. It has no way of knowing that you're then proxying it through HTTPS later on (ngrok).

Add URL::forceScheme('https') in AppServiceProvider::boot() and that will tell Laravel to always generate https:// URLs.

Actinity avatar May 04 '20 19:05 Actinity