Roberto Philippo has asked for the wisdom of the Perl Monks concerning the following question:

Hi pearl friends, I want to ask a question about authentification trough perl cgi. I have found a week ago tfmail and i use it on my site. Now i am inspired with this script do do some exploring. I like to know if i can use a js script to direct to cgi-bin and check a stored password and username in a non public config-file. I like to make a tfmailform not useble for everyone. If it's no, please tell me why not, and if it can, i will try to make it happen. I hope someone can provide me an answer, not a solution, because i like to try this pearl adverture. Thanks and sorry for the intrusion. Roberto

Replies are listed 'Best First'.
Re: authenticate with perl
by blue_cowdawg (Monsignor) on Feb 19, 2013 at 18:48 UTC
        Hi pearl friends,

    Picking nits: It's Perl. pearl is something that occurs in shellfish as a result of a grain of sand or other foreign object. Just sayin....

    There's a couple of approaches to doing authentication with Perl and JS. My favorite way is to implement something like a RESTful service which returns JSON back to the JS call.

    Take a look at such topics as DOJO and JQuery which are JS frameworks and in particular their wrappers for Ajax. Using one or the other (I have learned to prefer JQuery) can simplify your work for you.

    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: authenticate with perl
by 7stud (Deacon) on Feb 19, 2013 at 18:30 UTC
    A js script executing in a browser can send a request to the server for a cgi script. The server will then execute the cgi script and send the results back to the browser. A cgi script can read or write non-public files and even store and retrieve information from a database.
Re: authenticate with perl
by aitap (Curate) on Feb 19, 2013 at 20:11 UTC
    Sometimes it's easier and safer not to write your own password checking solution, but to set up your web server, for example.
    Sorry if my advice was wrong.
Re: authenticate with perl
by Roberto Philippo (Initiate) on Feb 19, 2013 at 20:30 UTC
    Thanks for your feedback, i appreciate the tips. And i understood that it is possible with perl. I know manny way's how it works in asp and with databases. But i wanted to know if it could be done with perl, i want to learn about that, so i give i a try and see if i can work it out. Again thanks for your comments.
      Any server side language can respond to a js request from a browser. perl is a server side language as well as a general purpose language. Ruby, python, java, etc. are also general purpose languages that are used as server side languages. php and asp are popular server side language but they are not considered general purpose languages.

        php and asp are popular server side language but they are not considered general purpose languages.

        Nonetheless, php is a general purpose language

Re: authenticate with perl
by sundialsvc4 (Abbot) on Feb 19, 2013 at 19:47 UTC

    If this happens to be an intra-net application, then by far (IMHO) the best approach is to use LDAP authentication at an Apache (or other server) level, which will centralize both the authentication and the authorization controls for this and for all other applications in one convenient spot that your company will already be using.   You can wall-off access to the site or to a portion of it without having to write special code at all.   You can query the identity of the connecting user and his privileges, group memberships and so on very easily.