[pmwiki-users] Quick/easy way to check if page is passwd protected?

christian.ridderstrom at gmail.com christian.ridderstrom at gmail.com
Sun Feb 12 09:28:57 CST 2006


On Sat, 11 Feb 2006, Ben Wilson wrote:

> To be more clear with what I seek:
> 
> I have a script that allows me to edit PmWiki pages without using a web
> browser. However, since some pages may be read or edit protected. Right
> now, every time I go to a site, I send the authentication information,
> even if it is not needed, because I have no way to determine if
> authentication is needed.

Going on a tangent here, I wonder if it'd make sense for me to adapt
pmwiki-mode in Emacs to use the same script. The advantage would be to
have a single mechanism to access a page rather than both of us
implementing the same thing twice. In addition, this script then of course
works with arbitrary editors.

As for accessing the source, *after* I'd implemented pmwiki-mode I still
considered using a separate script - mainly because I wanted it to be able
to upload/download attachements as well. At the time I looked around and
found the program 'curl' which I thought would be very useful. IIRC, it
had all the features needed (being able to handle cookies etc).
	
	http://curl.haxx.se/

> I need a way that the script can GET the protection status of a page
> (e.g. ?action=protections). That way, the script can GET the status and
> send the authentication information only when needed--rather than all
> the time.

That does indeed sound like a good way. However, I'm still not sure it is
in general a good idea to just acknowledge the existance of a page...  To
see how it works today, I created a group and made it password protected
(using 'quick' as the password):

	http://pmwiki.org/wiki/TestGroupWithPassword/TestGroupWithPassword
	http://pmwiki.org/wiki/TestGroupWithPassword/ThisPageDoesNotExist

There is no apparent difference in going to either of the two links today, 
which I think is a good thing. Using e.g.

	curl http://pmwiki.org/wiki/TestGroupWithPassword/SomePage

the result is a web page asking for a password. Perhaps your script could 
detect this, and then it knows it needs to supply the password?

As an aside, here's how you can retrieve the page submitting a password:

	curl -F authpw=quick  \
	  http://pmwiki.org/wiki/TestGroupWithPassword/TestGroupWithPassword

/Christian

PS. There's also something called 'libCurl' for use with programs.

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr






More information about the pmwiki-users mailing list