It'd be great if this module allowed wildcard paths (e.g. protected-area/*) then any access to protected-area/a or protected-area/b, etc. requires that password.
| Comment | File | Size | Author |
|---|---|---|---|
| #66 | 2890122-66.patch | 1.35 KB | mxwright |
| #53 | 2890122-53.patch | 12.41 KB | mrwhittaker |
| #52 | 2890122-52.patch | 12.4 KB | mrwhittaker |
| #39 | 2890122-39.patch | 12.4 KB | mxwright |
| #38 | 2890122-38.patch | 11.05 KB | mxwright |
Issue fork protected_pages-2890122
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
langelhc commentedComment #3
CShark commentedI ported the patch from here for version 8.x-1.0
Comment #4
johnhuang0808 commented@CShark The patch cannot be applied.
Comment #5
kyletaylored commentedI updated the patch to apply to the latest dev, but it still looks like there needs some work on the form validation when saving new protected paths.
In addition, the original patch will throw an undefined variable error for
$where_clause, and it's not referenced anywhere else, so I'm not entirely sure what it represents.Comment #6
useernamee commentedHi, I've dig into this issue a bit. I have applied patch #5 and worked from there on.
I have added the option for wildcard * at the end of the path. I have removed path validation for this kinds of protected paths (@todo validation). I also did not bother with coding standards and best practices because they are parts of other issues (there will be rerolling to do either way).
Might also be good idea to use
path.matcherservice instead of making all these gymnastics with db querrying. What do you think? Something like getting all protected paths from db and than foreaching through themComment #7
g_miric commentedHi,
I updated patch from comment #6 and added validation for the edit form too.
Comment #8
g_miric commentedComment #11
justcaldwellGreat work so far. My concern with the current approach is that it doesn't support paths that extend past one level deep. For example,
/foo/*protects/foo/bar, but not/foo/bar/baz.I think @useernamee's suggestion in #6 to try the
path.matcherservice is on the right track. Attaching a patch that explores that approach.Comment #12
justcaldwellComment #13
richardp commentedI added the patch from #11 (had to manually add certain lines), and also changed code very slightly so that the path /protected-page itself doesn't find itself "protected", which will cause an infinite number of redirects.
I also added verbiage when adding a path that you can use /* to protect every page on the site, which is now true because of the above edit.
I did not have time to figure out how to make this into a pretty patch file, so apologies please-- but I am just going to attach the entire module zip file I ended up with. To maintainer, please feel free to create into a patch, and *please* apply to dev or put out a new release!
Comment #14
mxwright commentedI rerolled the patch in #11 for 8.x-1.x-dev and added the tweaks from #13.
Comment #15
mxwright commentedI like this approach. I think it's cleaner than the solution currently being worked on for #3005788: Allow multiple pages with same validation and one page with multiple validations.
However, that solution has the advantage of adding pages unrelated by path to the same authentication. It would be great to see that combined here, preferably in a multivalue field.
Comment #16
mxwright commentedHere's a new version of the patch that I think works with the latest dev
Comment #17
kbrodej commentedReviewed patch in #16, added dependency injection to it and fixed some minor CS issues.
Comment #18
strozx commentedHi, @kbrodej I applied the patch and reviewed the code and everything is OK. I also tested the solution and it works as it should so I will set this to RTBC.
Regards, strozx.
Comment #19
mxwright commentedI second the RTBC. We've been using the patch for months with no issue.
Comment #20
Erno commentedPatch #17 is missing wildcard check for private file paths. This patch fixes it.
Comment #21
jmcpolin commentedIf it helps #20 - this word for me protecting files, and pages
Thanks
Comment #22
mxwright commentedUnfortunately the patch no longer applies to the lastest dev, due to a bunch of new commits. We'll have to create a new patch. I'll take a look if I get an opportunity soon.
Comment #23
mxwright commentedOK here's an attempt at rerolling the patch from #20 for the latest dev version.
Comment #24
nace_fr commentedHi. I was testing this and when applying patch from #23 there was a warning: 2 lines add whitespace errors.
I have just quickly fixed this, so patch applies without warnings.
Also I have tested the functionality and it seems this is working as described. I had no issues and also logs are clear of any warnings.
Comment #25
mxwright commentedAs these updates work, apply cleanly, and contain no substantive changes to the previous patches, I'm setting this back as RTBC.
Comment #26
dwbotsch commentedI just manually applied this to 8.x-1.2 . Seems to work.
thanks.
Comment #27
mrpauldriver commentedBe good to see this wrapped up.
Comment #28
amourow#24 patch works on 8.x-1.4
Comment #29
aaronbaumanThis patch doesn't apply to latest dev
Comment #31
aaronbaumanRe-rolled #24 for MR!2
Comment #33
parisekCleaned this issue and added related task https://www.drupal.org/project/protected_pages/issues/3005788 (which seems more robust, but introduce too much changes at once)
Comment #34
mxwright commentedI don't know the state of this patch currently (we've continued to successfully use #24 on D9.5) and I have my doubts, given the maintenance of this project, that it will make it into production. However, I've discovered a worrisome bug when using the patch.
When you have more than 20 passwords set up, the interface becomes paged, which is normal. However, any wildcard page passwords you have setup that are on the second page are NO LONGER password restricted.
Looking through the code of the patch, one of the first additions is pulling from loadAllProtectedPages:
Unfortunately, the loadAllProtectedPages function contains a pager/limit for 20 items. Fine for listing the pages, bad for checking all of the passwords:
A quick fix for this, and you need one if your pages are now unprotected, is to just up the limit or even drop the pager completely. I ended up duplicating the loadAllProtectedPages function, calling it listAllProtectedPages, and using it where the results are called. I left alone all the references to loadAllProtectedPages in the patch and just removed the pager from that function.
I would add this to the patch, but again, I'm not sure where it stands given the merge request, etc.
Comment #35
mxwright commentedHere's a patch for the latest dev based on #24
Comment #36
mxwright commentedAnd here's a version based on my comment in #34, it adds a new function to the patch in #35 for listing the Protected Pages vs loading them.
Comment #37
mxwright commentedComment #38
mxwright commentedI made some changes based on the test failures in #35, so here's an updated patch for the latest dev based on #24. I'm not familiar with writing tests so you're on your own there.
Comment #39
mxwright commentedThis is an updated version of #36, based on my comment in #34.
Comment #40
nojj commentedI used patch #24 with version 1.4 of this module.
Now I updated the module to 1.6 but the patch can not be applied.
an suggestions ?
Comment #41
nojj commentedit seems to work with wildcards e.g. * and version 1.6, but the description hints from patch #24 are missing.
Please enter the relative path and its corresponding password. When user opens this url, they will asked to enter password to view this page. For example, "/node/5", "/new-events" etc.I thought, that indicates that patch did not make it to the release...
Can someone confirm wildcards are supported with V. 1.6 ?
Comment #42
nojj commenteda quick look into the module code, it seems the patch mostly made it to V1.6, only the descriptions for wildcard usage seem to be missing.
can someone confirm this is the case?
edit: seems there was still code from the patch existing in my local installation when looking into it.
Comment #43
mxwright commented@nojj, I haven't looked at V1.6, but I'd be surprised if these changes made it in unannounced. In any case, the latest patches - 38 & 39 - work with the latest dev version only.
Comment #44
nojj commented@mxwright, thanks for your response.
in a local test with V1.6 it seems with wildcard * the protection is not applied.
regarding latest dev and patches: is the security issue fixed in V1.6 included in the latest dev?
Comment #45
mxwright commented@nojj, yes it looks like the security issue is addressed in both 1.6 and the latest dev.
Comment #46
nojj commentedso you are are using the latest dev with patch #39 in your current projects?
and is the security-fix what you describe in #34 or something else?
Comment #47
mxwright commented@nojj, here is the current state of things:
I'm using #39 with the latest dev successfully on my projects
Comment #48
nojj commented@mxwright thank you very much for the detailed explanation!
curious if this makes it into the stable release...
Comment #49
nojj commented@mxwright did another test. coming from V1.4 with patch #24, I could successfully update to V1.6 (stable version) and then apply patch #39. And wildcards seem to work.
that would be nice, because DEV-versions of modules are not listed in Drupal for pending updates.
Comment #50
mxwright commentedComment #51
nojj commentedis eher an option to use the wildcards for a "section global password"
we would like to use one global password for all URL beginning with
/xxx/*
but have different passwords for individual urls with a more specific url like
/xxx/abc
at the moment if the password for /xxx/* is not accepted for urls like
/xxx/abc
if a different password is set to this urls
any ideas to solve this?
Comment #52
mrwhittaker commentedRerolled patch 39 for protected_pages 1.7.0
Comment #53
mrwhittaker commentedRerolled patch 39 for protected_pages 1.7.0 Now with AliasManagerInterface in the constructor
Comment #54
mxwright commentedPatch in 53 appears to work for 1.8.0
Comment #55
nojj commentedalso patch #53 fixes this issue for 1.8.0
https://www.drupal.org/project/protected_pages/issues/3543502
Comment #56
aaronbaumanRerolled MR again.
This has been RTBC for almost 2 years, can we get this committed please?
Comment #58
oksana-c commentedIt's a great addition to the module and I believe it's mostly ready to be merged.
However, it would be nice to see a test that covers this new functionality before merging.
Comment #62
oksana-c commentedAdded tests and merged (has to come back to add credits... forgot on the first pass).
Thank you all!
Comment #65
mxwright commentedThanks for incorporating this feature!
Unfortunately, the issue I reported in #34 still persists. Not sure why, since it was fixed in the patches. This particular change was not committed.
The issue is that if you have more than 20 entries in your protected pages list, the entries that spill over to the second page (21+) are no longer protected. The protection rules only apply to the items on the first page. This is a pretty big problem!
If I recall correctly, the solution is to just remove the limit from this code from /src/ProtectedPagesStorage.php
I may make a new patch just for this, or open a new issue, but in the meantime I'd recommend downgrading to 1.8 and patching with #53
Comment #66
mxwright commentedI haven't opened a new issue yet for what I wrote in #65, but I made a new patch that should add back the missing pieces of the patch in #53 that keeps this wildcard function working when you have more than 20 entries.
Comment #67
mxwright commented#3557159: Wildcard path conditions don't apply after 20 entries