geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
505 stars 392 forks source link

Improve authentication request interceptor #7952

Open offtherailz opened 2 years ago

offtherailz commented 2 years ago

Description

If you use relative paths like "/geoserver/" and "http://test/geoserver/" with the authkey, the current authenticationRules need two different rules:

We have to investigate if we can improve the behavior to recognize somehow the localhost and add a single rule, or a placeholder for localhost requests.

Acceptance criteria

TBD

Other useful information

alexander-fedorenko commented 2 years ago

@offtherailz Would it be sufficient to use combined regex that will be valid for both relative and absolute url?

/(http(s)?\:\/\/gs-stable\.geo-solutions\.it(\:443|\:80)?\/geoserver\/.*)|(^\/geoserver\/.*)/

with "or" condition to check for localhost absolute urls:

/(http(s)?\:\/\/((gs-stable\.geo-solutions\.it)|(localhost))(\:443|\:80)?\/geoserver\/.*)|(^\/geoserver\/.*)/

Example to test: https://regex101.com/r/ZzAiOC/2

offtherailz commented 2 years ago

Yes, I though about it. The problem of this solution is that you have to imagine every possible domain the application is deployed on. This will need rules for test environment, production and so on. And they will be forwarded to the production environment. Using data directory may solve the problem, by setting rules by environment on the server. Anyway, adding a "currentPath" property, alternative to "urlPattern", that is a shortcut to check paths of the current domain/ protocol , may simplify life in several projects, that usually have different deployment in test/pre-prod/prod but same shape for relative paths.