/usr/lib/perl5/Authen/SASL/Cyrus.pod is in libauthen-sasl-cyrus-perl 0.13-server-8build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | =head1 NAME
Authen::SASL::Cyrus - XS code to glue Perl SASL to Cyrus SASL
=head1 SYNOPSIS
use Authen::SASL;
my $sasl = Authen::SASL->new(
mechanism => 'NAME',
callback => { NAME => VALUE, NAME => VALUE, ... },
);
my $conn = $sasl->client_new(<service>, <server>, <iplocalport>, <ipremoteport>);
my $conn = $sasl->server_new(<service>, <host>, <iplocalport>, <ipremoteport>);
=head1 DESCRIPTION
SASL is a generic mechanism for authentication used by several
network protocols. B<Authen::SASL::Cyrus> provides an implementation
framework that all protocols should be able to share.
The XS framework makes calls into the existing libsasl.so resp. libsasl2
shared library to perform SASL client connection functionality, including
loading existing shared library mechanisms.
=head1 CONSTRUCTOR
The constructor may be called with or without arguments. Passing arguments is
just a short cut to calling the C<mechanism> and C<callback> methods.
You have to use the C<Authen::SASL> new-constructor to create a SASL object.
The C<Authen::SASL> object then holds all necessary variables and callbacks, which
you gave when creating the object.
C<client_new> and C<server_new> will retrieve needed information from this
object.
=pod
=head1 CALLBACKS
Callbacks are very important. It depends on the mechanism which callbacks
have to be set. It is not a failure to set callbacks even they aren't used.
(e.g. password-callback when using GSSAPI or KERBEROS_V4)
The Cyrus-SASL library uses callbacks when the application
needs some information. Common reasons are getting
usernames and passwords.
Authen::SASL::Cyrus allows Cyrus-SASL to use perl-variables and perl-subs
as callback-targets.
Currently Authen::SASL::Cyrus supports the following Callback types:
(for a more detailed description on what the callback type is used for
see the respective man pages)
B<Remark>: All callbacks, which have to return some values (e.g.: **result in
C<sasl_getsimple_t>) do this by returning the value(s). See example below.
=over 4
=item user (client)
=item auth (client)
=item language (client)
This callbacks represent the C<sasl_getsimple_t> from the library.
Input: none
Output: C<username>, C<authname> or C<language>
=item password (client)
=item pass (client)
This callbacks represent the C<sasl_getsecret_t> from the library.
Input: none
Output: C<password>
=item realm <client>
This callback represents the C<sasl_getrealm_t> from the library.
Input: a list of available realms
Output: the chosen realm
(This has nothing to do with GSSAPI or KERBEROS_V4 realm).
=item checkpass (server, SASL v2 only)
This callback represents the C<sasl_server_userdb_checkpass_t> from the
library.
Input: C<username>, C<password>
Output: true or false
=item getsecret (server, SASL v1 only)
This callback represents the C<sasl_server_getsecret_t> from the library. Sasl
will check if the passwords are matching.
Input: C<mechanism>, C<username>, C<default_realm>
Output: C<secret_phrase (password)>
B<Remark>: Programmers that are using should specify both callbacks (getsecret and checkpass).
Then, depending on you Cyrus SASL library either the one or the other is called. Cyrus SASL v1
ignores checkpass and Cyrus SASL v2 ignores getsecret.
=item putsecret (SASL v1) and setpass (SASL v2)
are currently not supported (and won't be, unless someone needs it).
=item canonuser (server/client in SASL v2, server only in SASL v1)
This callback name represents the C<sasl_canon_user_t> from the library.
Input: C<Type of principal>, C<principal>, C<userrealm> and maximal allowed length of the output.
Output: canonicalised C<principal>
C<Type of principal> is "AUTHID" for Authentication ID or "AUTHZID"
for Authorisation ID.
B<Remark>: This callback is ideal to get the username of the user using your service.
If C<Authen::SASL::Cyrus> is linked to Cyrus SASL v1, which doesn't have a canonuser callback,
it will simulate this callback by using the authorize callback internally. Don't worry, the
authorize callback is available anyway.
=item authorize (server)
This callback represents the C<sasl_authorize_t> from the library.
Input: C<authenticated_username>, C<requested_username>, (C<default_realm> SASL v2 only)
Output: C<canonicalised_username> SASL v1 resp. true or false when using SASL v2 lib
There is something TODO, I think.
=item setpass (server, SASL v2 only)
This callback represents the C<sasl_server_userdb_setpass_t> from the library.
Input: C<username>, C<new_password>, C<flags> (0x01 CREATE, 0x02 DISABLE,
0x04 NOPLAIN)
Out: true or false
=back
=head2 Ways to pass a callback
Authen::SASL::Cyrus supports three different ways to pass a callback
=over 4
=item CODEREF
If the value passed is a code reference then, when needed, it will be called.
=item ARRAYREF
If the value passed is an array reference, the first element in the array
must be a code reference. When the callback is called the code reference
will be called with the value from the array passed after.
=item SCALAR
All other values passed will be returned directly to the SASL library
as the answer to the callback.
=back
=head2 Example of setting callbacks
$sasl = new Authen::SASL (
mechanism => "PLAIN",
callback => {
# Scalar
user => "mannfred",
pass => $password,
language => 1,
# Coderef
auth => sub { return "klaus", }
realm => \&getrealm,
# Arrayref
canonuser => [ \&canon, $self ],
}
);
The last example is ideal for using object methods as callback functions.
Then you can do something like this:
sub canon
{
my ($this,$type,$realm,$maxlen,$user) = @_;
$this->{_username} = $user if ($type eq "AUTHID");
return $user;
}
=head1 Authen::SASL::Cyrus METHODS
=over 4
=item server_new ( SERVICE , HOST = "" , IPLOCALPORT , IPREMOTEPORT )
Constructor for creating server-side sasl contexts.
Creates and returns a new connection object blessed into Authen::SASL::Cyrus.
It is on that returned reference that the following methods are available.
The SERVICE is the name of the service being implemented, which may be used
by the underlying mechanism. An example service therefore is "ldap".
=pod
=item client_new ( SERVICE , HOST , IPLOCALPORT , IPREMOTEPORT )
Constructor for creating server-side sasl contexts.
Creates and returns a new connection object blessed into Authen::SASL::Cyrus.
It is on that returned reference that the following methods are available.
The SERVICE is the name of the service being implemented, which may be used
by the underlying mechanism. An example service is "ldap". The HOST is the
name of the server being contacted, which may also be used
by the underlying mechanism.
See SYNOPSIS for an example.
=back
B<Remark>:
This and the C<server_new> function are called by L<Authen::SASL> when using
its C<*_new> function. Since the user has to use Authen::SASL anyway, normally
it is not necessary to call this function directly.
IPLOCALPORT and IPREMOTEPORT arguments are only available, when ASC is
linked against Cyrus SASL 2.x. This arguments are needed for KERBEROS_V4
and CS 2.x on the server side. Don't know if it necessary for the client
side. Format of this arguments in an IPv4 environment should be: a.b.c.d;port.
See sasl_server_new(3) for details.
=pod
=over 4
=item server_start ( CHALLENGE )
C<server_start> begins the authentication using the chosen mechanism.
If the mechanism is not supported by the installed Cyrus-SASL it fails.
Because for some mechanisms the client has to start the negotiation,
you can give the client challenge as a parameter.
=pod
=item client_start ( )
The initial step to be performed. Returns the initial value to pass to the server.
Client has to start the negotiation always.
=pod
=item server_step ( CHALLENGE )
C<server_step> performs the next step in the negotiation process. The
first parameter you give is the clients challenge/response.
=pod
=item client_step ( CHALLENGE )
=back
B<Remark>:
C<client_start>, C<client_step>, C<server_start> and C<server_step>
will return the respective sasl response or undef. The returned value
says nothing about the current negotiation status. It is absolutely possible
that one of these functions return undef and everything is fine for SASL,
there is only another step needed.
Therefore you have to check C<need_step> and C<code> during negotiation.
See example below.
=pod
=over 4
=item listmech( START , SEPARATOR , END )
C<listmech> returns a string containing all mechanisms allowed for the user
set by C<user>. START is the token which will be put at the beginning of the
string, SEPARATOR is the token which will be used to separate the mechanisms
and END is the token which will be put at the end of returned string.
=pod
=item setpass(user, newpassword, oldpassword, flags)
=item checkpass(user, password)
C<setpass> and C<checkpass> is only available when using Cyrus-SASL 2.x library.
C<setpass> sets a new password (depends on the mechanism if the setpass callback
is called). C<checkpass> checks a password for the user (calls the checkpass
callback).
For both function see the man pages of the Cyrus SASL for a detailed description.
Both functions return true on success, false otherwise.
=pod
=item global_listmech ( )
C<global_listmech> is only available when using Cyrus-SASL 2.x library.
It returns an array with all mechanisms loaded by the library.
=pod
=item encode ( STRING )
=item decode ( STRING )
Cyrus-SASL developers suggest using the C<encode> and C<decode> functions
for every traffic which will run over the network after a successful authentication
C<encode> returns the encrypted string generated from STRING.
C<decode> returns the decrypted string generated from STRING.
It depends on the used mechanism how secure the encryption will be.
=pod
=item error ( )
C<error> returns an array with all known error messages.
Basicly the sasl_errstring function is called with the current error_code.
When using Cyrus-SASL 2.x library also the string returned by sasl_errdetail
is given back. Additionally the special Authen::SASL::Cyrus advise is
returned if set.
After calling the C<error> function, the error code and the special advice
are thrown away.
=pod
=item code ( )
C<code> returns the current Cyrus-SASL error code.
=pod
=item mechanism ( )
C<mechanism> returns the current used authentication mechanism.
=pod
=item need_step ( )
C<need_step> returns true if another step is need by the SASL library. Otherwise
false is returned. You can also use C<code == 1> but it looks smarter I think.
That's why we all using perl, eh?
=pod
=back
=head1 EXAMPLE
=head2 Server-side
# The example uses Cyrus-SASL v2
# Set the SASL_PATH to the location of the SASL-Plugins
# default is /usr/lib/sasl2
$ENV{'SASL_PATH'} = "/opt/products/sasl/2.1.15/lib/sasl2";
#
my $sasl = Authen::SASL->new (
mechanism => "PLAIN",
callback => {
checkpass => \&checkpass,
canonuser => \&canonuser,
}
);
# Creating the Authen::SASL::Cyrus object
my $conn = $sasl->server_new("service","","ip;port local","ip;port remote");
# Clients first string (maybe "", depends on mechanism)
# Client has to start always
sendreply( $conn->server_start( &getreply() ) );
while ($conn->need_step) {
sendreply( $conn->server_step( &getreply() ) );
}
if ($conn->code == 0) {
print "Negotiation succeeded.\n";
} else {
print "Negotiation failed.\n";
}
=head2 Client-side
# The example uses Cyrus-SASL v2
# Set the SASL_PATH to the location of the SASL-Plugins
# default is /usr/lib/sasl2
$ENV{'SASL_PATH'} = "/opt/products/sasl/2.1.15/lib/sasl2";
#
my $sasl = Authen::SASL->new (
mechanism => "PLAIN",
callback => {
user => \&getusername,
pass => \&getpassword,
}
);
# Creating the Authen::SASL::Cyrus object
my $conn = $sasl->client_new("service", "hostname.domain.tld");
# Client begins always
sendreply($conn->client_start());
while ($conn->need_step) {
sendreply($conn->client_step( &getreply() ) );
}
if ($conn->code == 0) {
print STDERR "Negotiation succeeded.\n";
} else {
print STDERR "Negotiation failed.\n";
}
See t/plain.t for working script.
=head1 TESTING
I tested ASC (server and client) with the following mechanisms:
=over 4
=item GSSAPI
Don't forget to create keytab. Non-root keytabs can be specify through $ENV{'KRB5_KTNAME'} (Heimdal >= 0.6, MIT).
=item KERBEROS_V4
Available since 0.10, you have to add IPLOCALPORT and IPREMOTEPORT to *_new functions.
=item PLAIN
=back
=head1 SEE ALSO
L<Authen::SASL>
man pages for sasl_* library functions.
=head1 AUTHOR
Originally written by Mark Adamson <mark@nb.net>
Cyrus-SASL 2.x support by Leif Johansson
Glue for server_* and many other structural improvements by Patrick Boettcher <patrick.boettcher@desy.de>
Please report any bugs, or post any suggestions, to the authors.
=head1 THANKS
- Guillaume Filion for testing the server part and for giving hints about
some bugs (documentation).
- Wolfgang Friebel for bother around with rpm building of test releases.
=head1 COPYRIGHT
Copyright (c) 2003-5 Patrick Boettcher, DESY Zeuthen. All rights reserved.
Copyright (c) 2003 Carnegie Mellon University. All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
|