Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow wildcard and multi domain authHost option #190

Merged
merged 2 commits into from
Jul 27, 2017

Conversation

tobiasvielmetter
Copy link
Contributor

@tobiasvielmetter tobiasvielmetter commented Jul 24, 2017

As described in #185 allow for wildcard domain declaration in authHost option (e.g. authHost = '.myapp.com') so one use the laravel-echo-server with a multi tenant/subdomain system. The currently appropriate domain is retrived from the referer and matched with the wildcard domain declaration (if a wildcard is used). @tlaverdure please check. Thanks!

Updated version
See comments below...

As described in tlaverdure#195 allow for wildcard domain declaration in authHost option (e.g. authHost = '.myapp.com') so one use the laravel-echo-server with a multi tenant/subdomain system. The currently appropriate domain is retrived from the referer and matched with the wildcard domain declaration (if a wildcard is used).
@tobiasvielmetter tobiasvielmetter changed the title Update private-channel.ts Allow wildcard authHost option Jul 24, 2017
@barryvdh
Copy link
Contributor

Would it be more flexible if it was regex based? Eg for multiple domains etc

@tobiasvielmetter
Copy link
Contributor Author

tobiasvielmetter commented Jul 24, 2017

@barryvdh Not sure about regex. As far as my research goes: the url class is more capable to actually check the validity of the url, which I think is important when working with the referer (which can potentially be spoofed to send in a socket from another server). I think it would make sense to allow optionally an array for the authHost. So potential configurations could be:

//single domain
"authHost": "http://localhost",

//multiple domains, with or without protocol
"authHost": ["http://localhost", "web.server.app"],

//wildcard
"authHost": ".server.app",

//mixed domain as well as wildcard
"authHost": [".server.app", "https://web.server.app"],

See the updated commit that covers this below at fda40bc. Let me know your thoughts.

As described in tlaverdure#185 as well as tlaverdure#135:
- allow for wildcard domain declaration in authHost option (e.g. authHost = '.myapp.com') so one can use the laravel-echo-server with a multi tenant/subdomain system 
- as well as a multi domain system, where different authentication servers are used. 
The currently appropriate authentication domain is retrived from the referer and matched with the (optional: wildcard) domain declaration from the authHost option as a whitelist (which can be either an array or a string). In case none is matched with the referer, the last one in the array is taken (in case of string, the only one). 
@tlaverdure @barryvdh please check. I have done my best to write this up in TS, but I don't have a compile system for this setup, so I have only tested it in vanilla JS and then afterwards added the TS specific types for this PR.
Thanks!
@tobiasvielmetter tobiasvielmetter changed the title Allow wildcard authHost option Allow wildcard and multi domain authHost option Jul 25, 2017
@tlaverdure
Copy link
Owner

Thanks!

@tlaverdure tlaverdure merged commit 8a2ff3a into tlaverdure:master Jul 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants