PrivateBin icon indicating copy to clipboard operation
PrivateBin copied to clipboard

[fix] Do not create .htaccess with Nginx

Open magikcypress opened this issue 7 years ago • 9 comments

I use editorConfig but I'm not sure for indentation ?


added by @rugk:

replaces PR https://github.com/PrivateBin/PrivateBin/pull/223 fixes https://github.com/PrivateBin/PrivateBin/issues/222

magikcypress avatar Apr 28 '17 15:04 magikcypress

It should do that automatically. That's the whole purpose of this tool.

rugk avatar Apr 28 '17 18:04 rugk

Thanks for the fixes. Still TODO:

  • [ ] detect server version https://github.com/PrivateBin/PrivateBin/pull/226#discussion_r114010427 (if you want)
  • [ ] autodetection of server https://github.com/PrivateBin/PrivateBin/pull/226#discussion_r114009918

rugk avatar Apr 30 '17 20:04 rugk

Thanks for working on this!

The logic of the WebServer class looks quite clean, with my only suggestion being to maybe change the fixed version regex compare to the version_compare one, so it works with future apache versions, too.

Note that .htaccess files may need to be created in various places, not just in the web root, so there should be a mechanism to pass the absolute path into the $file in canHtaccess().

The name canHtaccess() is also a bit misleading. The "can" prefix would indicate that it is a test and returns a boolean, while it actually just writes a file, if needed. How about a name that more clearly describes its function? In the end it abstracts a mechanism to restrict access across various webserver types, so something like restrictAccessTo($path) would semantically make more sense.

That aside, I can write the unit tests for this before merging it, if you want.

elrido avatar May 22 '17 19:05 elrido

Yes, is a good idea for change name for this function. restrictAccessTo() is a good name for me.

I also think that I have written badly name of my WebServer function. Would it be more logical to write it ServerWeb as for ServerSalt? if that's okay, I'll rename the file too.

I would like to write the tests, but I can't get them to work properly. I want you to write them;)

magikcypress avatar May 22 '17 19:05 magikcypress

Okaydoky on the tests, WebServer as class name is fine by me, as we usually do call these objects "web servers". ;-)

PS: I am now starting to reconsider renaming ServerSalt to simply Salt, since that class is now used to generate the paste salts, too, and not only for the instance wide salt.

elrido avatar May 22 '17 20:05 elrido

i will add $path for a restrictAccessTo() function, but for the moment, i don't know how to added neatly into lib/Model/Paste.php

magikcypress avatar May 22 '17 21:05 magikcypress

@magikcypress Any chance you can have a look at finishing the PR?

rugk avatar Aug 10 '17 20:08 rugk

I don't know, i haven't a lot anytime for patch this PR, sorry.

In fact, i don't know how get a variable $_path in my code for to be used a WebServer class anywhere ?

magikcypress avatar Aug 15 '17 16:08 magikcypress

@magikcypress Are you still interested in completing this? If not, that's no problem, just add a notice, so I know what the current status of this PR is.

rugk avatar Jul 29 '22 09:07 rugk