MapStore2 icon indicating copy to clipboard operation
MapStore2 copied to clipboard

Improve authentication request interceptor

Open offtherailz opened this issue 3 years ago • 2 comments

Description

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

  • one for the relative URL: "urlPattern": "^\\/geoserver\\/.*",
  • one with the absolute url http(s)?\\:\\/\\/test(\\:443|\\:80)?\\/geoserver\\/.*

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

offtherailz avatar Mar 10 '22 14:03 offtherailz

@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

alexander-fedorenko avatar Jun 06 '22 21:06 alexander-fedorenko

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.

offtherailz avatar Jun 07 '22 08:06 offtherailz