~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to doc/wiki/AuthDatabase.Dict.txt

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Key-value authentication database (v2.1.9+)
 
2
===========================================
 
3
 
 
4
Key-value databases can be used as auth backends. They probably should be used
 
5
only for caching in front of e.g. SQL auth backends, since they don't currently
 
6
support user iteration.
 
7
 
 
8
Auth configuration
 
9
------------------
 
10
 
 
11
'dovecot.conf':
 
12
 
 
13
---%<-------------------------------------------------------------------------
 
14
passdb {
 
15
  driver = dict
 
16
  args = /etc/dovecot/dovecot-dict-auth.conf
 
17
}
 
18
userdb {
 
19
  driver = dict
 
20
  args = /etc/dovecot/dovecot-dict-auth.conf
 
21
}
 
22
---%<-------------------------------------------------------------------------
 
23
 
 
24
Dict configuration
 
25
------------------
 
26
 
 
27
See the 'dovecot-dict-auth.conf.ext' file from example-config for full list of
 
28
configuration options. Basically you need these:
 
29
 
 
30
'/etc/dovecot/dovecot-dict-auth.conf.ext':
 
31
 
 
32
---%<-------------------------------------------------------------------------
 
33
uri = redis:host=127.0.0.1:port=6379
 
34
 
 
35
password_key = dovecot/passdb/%u
 
36
user_key = dovecot/userdb/%u
 
37
iterate_disable = yes
 
38
default_pass_scheme = plain
 
39
---%<-------------------------------------------------------------------------
 
40
 
 
41
Example values
 
42
--------------
 
43
 
 
44
Currently only JSON object values are supported. For example userdb lookup
 
45
should return something like:
 
46
 
 
47
---%<-------------------------------------------------------------------------
 
48
{ "uid": 123, "gid": 123, "home": "/home/username" }
 
49
---%<-------------------------------------------------------------------------
 
50
 
 
51
Complete example for authenticating via a UNIX socket
 
52
-----------------------------------------------------
 
53
 
 
54
The Dict auth backend can be used to query a local UNIX socket for users. This
 
55
can be handy for accessing user databases which would otherwise only be
 
56
accessible via the <CheckPassword> [AuthDatabase.CheckPassword.txt] backend and
 
57
a scripting language.
 
58
 
 
59
When given a <"proxy:"> [Quota.Dict.txt] URL the Dict backend speaks a simple
 
60
protocol over a UNIX socket. The protocol is defined in
 
61
'src/lib-dict/dict-client.h' (Mercurial
 
62
[http://hg.dovecot.org/dovecot-2.2/file/tip/src/lib-dict/dict-client.h]).
 
63
 
 
64
Auth configuration
 
65
------------------
 
66
 
 
67
'dovecot.conf':
 
68
 
 
69
---%<-------------------------------------------------------------------------
 
70
passdb {
 
71
  driver = dict
 
72
  args = /etc/dovecot/dovecot-dict-auth.conf
 
73
}
 
74
userdb {
 
75
  # optional
 
76
  driver = prefetch
 
77
}
 
78
userdb {
 
79
  driver = dict
 
80
  args = /etc/dovecot/dovecot-dict-auth.conf
 
81
}
 
82
---%<-------------------------------------------------------------------------
 
83
 
 
84
Dict configuration
 
85
------------------
 
86
 
 
87
The last "dictionary name" ("somewhere") argument is redundant here.
 
88
 
 
89
'/etc/dovecot/dovecot-dict-auth.conf.ext':
 
90
 
 
91
---%<-------------------------------------------------------------------------
 
92
uri = proxy:/var/run/auth_proxy_dovecot/socket:somewhere
 
93
 
 
94
password_key = passdb/%u
 
95
user_key = userdb/%u
 
96
iterate_disable = yes
 
97
#default_pass_scheme = plain
 
98
---%<-------------------------------------------------------------------------
 
99
 
 
100
Server process for answering Dict lookups
 
101
-----------------------------------------
 
102
 
 
103
The server process listening on '/var/run/lookup_proxy_dovecot/socket' can be
 
104
written in any language.Here's an example in Perl:
 
105
 
 
106
---%<-------------------------------------------------------------------------
 
107
package AuthProxyDovecot;
 
108
use base qw( Net::Server::PreFork );
 
109
 
 
110
use strict;
 
111
use warnings;
 
112
 
 
113
use JSON::XS;
 
114
 
 
115
AuthProxyDovecot->run() or die "Could not initialize";
 
116
 
 
117
sub default_values
 
118
{
 
119
  return {
 
120
    port              => '/var/run/auth_proxy_dovecot/socket|unix',
 
121
 
 
122
    log_level         => 2,
 
123
    log_file          => 'Sys::Syslog',
 
124
    syslog_logsock    => 'unix',
 
125
    syslog_ident      => 'auth_proxy_dovecot',
 
126
    syslog_facility   => 'daemon',
 
127
 
 
128
    background        => 1,
 
129
    setsid            => 1,
 
130
    pid_file          => '/var/run/auth_proxy_dovecot.pid',
 
131
 
 
132
    user              => 'root',
 
133
    group             => 'root',
 
134
 
 
135
    no_client_stdout  => 1,
 
136
    max_spare_servers => 2,
 
137
    min_spare_servers => 1,
 
138
    min_servers       => 2,
 
139
    max_servers       => 10,
 
140
 
 
141
  };
 
142
} ## end sub default_values
 
143
 
 
144
##################################################
 
145
 
 
146
sub process_request {
 
147
    my $self   = shift;
 
148
    my $socket = $self->{server}->{client};
 
149
 
 
150
    my %L_handler = (
 
151
        passdb => sub {
 
152
            my ($arg) = @_;
 
153
            my $ret = {
 
154
                password        => '$1$JrTuEHAY$gZA1y4ElkLHtnsrWNHT/e.',
 
155
                userdb_home     => "/home/username/",
 
156
                userdb_uid      => 1000,
 
157
                userdb_gid      => 1000,
 
158
            };
 
159
            return $ret;
 
160
        },
 
161
        userdb => sub {
 
162
            my ($arg) = @_;
 
163
            my $ret = {
 
164
                home    => "/home/username/",
 
165
                uid     => 1000,
 
166
                gid     => 1000,
 
167
            };
 
168
            return $ret;
 
169
        },
 
170
    );
 
171
 
 
172
    # protocol from src/lib-dict/dict-client.h
 
173
    my $json = JSON::XS->new;
 
174
    eval {
 
175
        while (<$socket>) {
 
176
            $self->log(2, "Got request: $_");
 
177
            chomp;
 
178
            my $cmd = substr($_,0,1);
 
179
            next if $cmd eq 'H'; # "hello"
 
180
            my $ret;
 
181
            if ($cmd eq 'L') {
 
182
                my ($namespace,$type,$arg) = split ('/',substr($_,1),3);
 
183
                $self->log(4,"I:$namespace, $type, $arg");
 
184
                if ($namespace eq 'shared') {
 
185
                    my $f = $L_handler{$type};
 
186
 
 
187
                    if (defined $f && defined $arg) {
 
188
                        $ret = $f->($self->{lookup}, $arg);
 
189
                    }
 
190
                }
 
191
            }
 
192
            if ($ret) {
 
193
                my $json = JSON::XS->new->indent(0)->utf8->encode($ret);
 
194
                $self->log(4,"O:$json");
 
195
                syswrite $socket, "O".$json."\n";
 
196
            }
 
197
            else {
 
198
                syswrite $socket, "F\n" unless $ret;
 
199
            }
 
200
        }
 
201
        1;
 
202
    };
 
203
    if ($@) {
 
204
        $self->log(2, "Invalid request: $@");
 
205
    }
 
206
}
 
207
 
 
208
sub pre_loop_hook {
 
209
    my $self = shift;
 
210
 
 
211
    $self->log(1, 'Starting server');
 
212
}
 
213
 
 
214
sub pre_server_close_hook {
 
215
    my $self = shift;
 
216
 
 
217
    $self->log(1, 'Server is shut down');
 
218
}
 
219
 
 
220
1;
 
221
 
 
222
__END__
 
223
---%<-------------------------------------------------------------------------
 
224
 
 
225
(This file was created from the wiki on 2013-11-24 04:42)