Merge branch 'next'
[ikiwiki] / IkiWiki / Plugin / httpauth.pm
1 #!/usr/bin/perl
2 # HTTP basic auth plugin.
3 package IkiWiki::Plugin::httpauth;
4
5 use warnings;
6 use strict;
7 use IkiWiki 3.00;
8
9 sub import {
10         hook(type => "getsetup", id => "httpauth", call => \&getsetup);
11         hook(type => "auth", id => "httpauth", call => \&auth);
12 }
13
14 sub getsetup () {
15         return
16                 plugin => {
17                         safe => 1,
18                         rebuild => 0,
19                 },
20 }
21
22 sub auth ($$) {
23         my $cgi=shift;
24         my $session=shift;
25
26         if (defined $cgi->remote_user()) {
27                 $session->param("name", $cgi->remote_user());
28         }
29 }
30
31 1