I realized maybe I didn't express my need : I want users to access the 
files from the webpage a-la Apache. So the files and directories have to be 
displayed.




On Thursday, 15 February 2018 13:53:37 UTC-5, Luc Larochelle wrote:
>
> Hi,
>
> I've been working with the plugin 'Directory' to serve files on a given 
> path. This works as expected and is pretty straight forward.
>
> However, I would like to limit access to the ressource with Basic HTTP 
> Authentication dialog from the web browser.  I can render text "OK" if 
> basic_auth meets the desired criterias but can't seem to control the 
> behavior of the plugin
>
>
>
> I tried creating a auth helper and use it with the under directive as 
> shown below (among many other experiments, but this code seems the most 
> logic to me). Still, the plugin would render without asking for 
> authentication before.
>
> Can you please help me achieve this ?
>
>
> use Mojolicious::Lite;
> plugin 'basic_auth_plus';
>
> helper auth => sub {
>   my $self = shift;
>   return 1 if 
>      $self->basic_auth(
>        "Realm Name" => {
>                      username => 'username',
>                      password => 'password'
>                    }
>                 )
> };
>
>
> under sub {
> my $self = shift;
> return 1 if $self->auth;
>
> $self->render(text => 'denied');
> return;
> };
>
>
> get '/' {
>
>    plugin ('Directory', root=>"/my/path")->start;
>
> }
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to