package Kwiki::Users::Remote;
use strict;
use warnings;

use Kwiki::Users -Base;

our $VERSION = "0.04";

const class_title => 'Kwiki users from HTTP authentication';
const user_class  => 'Kwiki::User::Remote';

package Kwiki::User::Remote;
use base 'Kwiki::User';

sub name {
    exists $ENV{REMOTE_USER}
        ? $ENV{REMOTE_USER}
        : $self->hub->config->user_default_name;

sub id {
    exists $ENV{REMOTE_USER}
        ? $ENV{REMOTE_USER}
        : $self->hub->config->user_default_name;


=head1 NAME 

Kwiki::Users::Remote - automatically set Kwiki user name from HTTP authentication


 $ cd /path/to/kwiki
 $ echo "users_class: Kwiki::Users::Remote" >> config.yaml

In your Apache configuration:

    <Location /kwiki>
        AuthName     "my kwiki"
        AuthType     Basic
        AuthUserFile /path/to/htpasswd
        Require      valid-user

Optionally, to display the user name:

 $ cd /path/to/kwiki
 $ kwiki -add Kwiki::UserName::Remote


When using HTTP authentication for your Kwiki, use this module to automatically
set the user's name from the username they logged in with. This name will
appear in any Recent Changes listing.

You might also want to use L<Kwiki::UserName::Remote>.


Gerald Richter submitted a patch so that username changes would be recognized
under mod_perl

=head1 AUTHORS

Ian Langworth <> 

=head1 SEE ALSO

L<Kwiki>, L<Kwiki::UserName::Remote>


Copyright (C) 2004, 2005 by Ian Langworth

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.