Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: forbidden perl script

by davido (Cardinal)
on Jun 30, 2019 at 00:37 UTC ( [id://11102135]=note: print w/replies, xml ) Need Help??


in reply to forbidden perl script

It would be trivial using an under statement in Mojolicious::Lite. Are you still committed to CGI?

use Mojolicious::Lite; # Authenticate based on name parameter under sub { my $c = shift; # Authenticated my $name = $c->param('name') || ''; return 1 if $name eq 'Bender'; # Not authenticated $c->render(template => 'denied'); return undef; }; # Only reached when authenticated get '/' => 'index'; app->start; __DATA__ @@ denied.html.ep You are not Bender, permission denied. @@ index.html.ep Hi Bender.

(Lifted from the Mojolicious docs at https://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Under.)

Of course now that you've got the 'under' hook into which you can inject authentication, you are left with the more meaty problem of what authentication method you want to plug in there.


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102135]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found