| Well, defsop is on the git now. It is a macro similar to defop, but taking an dditional parameter which is an IP address (or a list of IP addresses) from which the operator can be accessed. From any other address, the message "Permission denied" is returned. for example, (defsop hello req "127.0.0.1" (pr "hello")) displays hello when accessing /hello locally, but displays the error message when accessed remotely. defop's definition is : (mac defsop (name parm auth . body)
(w/uniq test
`(let ,test (if (acons ,auth) [some _ ,auth] (testify ,auth))
(defop ,name ,parm
(if (,test (,parm 'ip))
,@body
(pr "Permission denied"))))))
As a side effect, the additional parameter can also be a unary function whose parameter is the IP address of the caller. This way, you could for example check that the URL is accessed from somebody whose address follows the regex "123.45..". |