NetTalk Central

Author Topic: Settings for making web procedures not visible/accessible  (Read 3151 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Settings for making web procedures not visible/accessible
« on: September 27, 2024, 05:45:30 AM »
Hi,

What is a way to make unused web procedures not visible?

My app is full of procedures that are not being used, so I don't want them to be visible.

I have "Login rqd" set to true as well as "Only serve if" = false

anything else to consider?

and I notice that "Login rqd" is available via a global list
anything similar available for "Serve only" ?

thanks

Johan







rjolda

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #1 on: September 29, 2024, 11:41:05 AM »
Johan,
Not sure what you are trying to accomplish.  There is a global setting for user must be logged in as well as at the procedure level. eg You can't have to be logged in in order to Log In. Why don't you delete the procedures that are not used?  I doubt if someone would guess the name of a procedure not being called and be able to call it.  If you don't want to delete procedures and don't want them to be called why don't you give those procedures a Sec Level that WILL NEVER EXIST  - maybe -101? 
Ron

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #2 on: September 30, 2024, 12:38:34 AM »
Hi Ron

Thanks for info and suggestions,
Deleting them not an option,
as some might be work in progress and will be in next release, or some have been taken out of production, but I still want to keep the code in the app.

Yes, chances are that the names won't be guessed, but they can be, especially if they were in production and now have been taken out.

Currently what I am seeing is a blank browser screen, so it looks like a valid URL but with no data.

Ideally would like to display an error msg , "page not found"
So even if the procedure is there, it's invalid and not available




thanks

Johan








JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #3 on: September 30, 2024, 12:45:08 AM »
Hi Ron,

Just to add,

There really are 3 situations,

Login required - Pops the login page
Only serve if true - This procedure or page might be embedded on another procedure/page , so if false, send the blank, however it is a valid procedure, but only if certain conditions are met.
Hide - Send "page not found"

Something I have not looked at,
is to add code to serve "page not found" HTML

regards

Johan


Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #4 on: September 30, 2024, 12:12:24 PM »
Quote
Something I have not looked at,
is to add code to serve "page not found" HTML

Fairly easy to do with a few lines of code in the webhandler.
Maybe something like the attached? 

(Bruce page will serve, Johan and John pages will 404.)
« Last Edit: September 30, 2024, 02:07:14 PM by Jane »

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #5 on: September 30, 2024, 09:27:50 PM »
Hi Jane

thanks!

Unfortunately I'm still on C10, so could not open the example you so kindly created.
It was an idea I had to consider and pursue, and with your suggestion and example it seems like it's a good plan.

Any chance of posting the code and where to pop it in to the webhandler procedure.


thanks

Johan

Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #6 on: October 01, 2024, 09:18:03 AM »
C10?  Guess you like skinny templates ;)
Are you on NT 14, I hope?

Revised example C10/NT14 attached.

My code in the webhandler (line 14288 in p_web.SendFile procedure) looks for both procedure name and page name as specified on the procedure template.  Forced to lower-case a few lines above.

Code in this example is:

        case loc:filename
            of 'johan' orof 'johanpage'
            orof 'john' orof 'johnpage'
                p_web.trace('case triggered')
                p_web.SendError (404,'The page cannot be found', 'The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.')
                return
        end !case   


Seems to work OK.

Cheers,

Jane


JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #7 on: October 03, 2024, 02:47:48 AM »
Hi Jane

Thank you again for your help and effort,

I used the code and all working fine, hope I have it correct and will test.

The new zipped app does not have any embed code in webhandler, perhaps just zipped the wrong app, unless I'm missing something.
My code and embed point I used.

thanks again,

Johan



p_web._SendFile PROCEDURE(string p_FileName,Long p_header=NET:SendHeader)
! Start of "NetTalk Method Data Section"
! [Priority 1500]
loc:parent  string(252)   ! should always be a lower-case string
loc:done        Long
loc:filename    string(252)
! [Priority 6500]
! End of "NetTalk Method Data Section"

  CODE
  ! Start of "NetTalk Method Executable Code Section"
  ! [Priority 1500]
 
    loc:parent = self.PlainText(Lower(self.GetValue('_parentProc_')))
    loc:filename = SELF.GetPageName(Lower(p_FileName))
 
  ! Start of "Before SendFiles in DLLs"
  ! [Priority 5000]

    !############################# 
          block# = false
          case loc:filename
          of 'nwp_wineshop'
             block# = true
          of 'aboutus'
             block# = true
          of 'nwp_aboutus'
             block# = true
          end !case   
          if block# = true
             p_web.trace('case triggered:' & loc:filename)
             p_web.SendError (404,'The page cannot be found', 'The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.')
             return
          end   
    !############################# 

         
 
  ! End of "Before SendFiles in DLLs"
    loc:done = NetWebDLL_avc_b_SendFile(p_web, loc:Filename, loc:Parent)
    If loc:Done then Return.
    loc:done = NetWebDLL_avcfunc_SendFile(p_web, loc:Filename, loc:Parent)
    If loc:Done then Return.
  ! [Priority 3040]
 
    do Remap:tvcweb
    do CaseStart:tvcweb





Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Settings for making web procedures not visible/accessible
« Reply #8 on: October 03, 2024, 06:59:21 AM »
Argh!
Yes, sorry, Johan.  Appears that I zipped it before saving from IDE.
Attached is an updated zip. 
But looks as if you put the code in about the same place as I did.

Jane