Authen::SASL(3) User Contributed Perl Documentation Authen::SASL(3)

Authen::SASL - SASL Authentication framework

version 2.1700

use Authen::SASL;
$sasl = Authen::SASL->new(
  mechanism => 'CRAM-MD5 PLAIN ANONYMOUS',
  callback => {
    pass => \&fetch_password,
    user => $user,
  }
);

SASL is a generic mechanism for authentication used by several network protocols. Authen::SASL provides an implementation framework that all protocols should be able to share.

The framework allows different implementations of the connection class to be plugged in. At the time of writing there were two such plugins.

This module implements several mechanisms and is implemented entirely in Perl.
This module uses the Cyrus SASL C-library (both version 1 and 2 are supported).
This module is the predecessor to Authen::SASL::XS.

Until version 2.16, Authen::SASL::Cyrus was loaded as an alternative to Authen::SASL::XS.

By default Authen::SASL tries to load Authen::SASL::XS first, followed by Authen::SASL::Perl on failure. If you want to change the order or want to specifically use one implementation only simply do

use Authen::SASL qw(Perl);

or if you have another plugin module that supports the Authen::SASL API

use Authen::SASL qw(My::SASL::Plugin);

The constructor may be called with or without arguments. Passing arguments is just a short cut to calling the "mechanism" and "callback" methods.
Set the callbacks. See the callback method for details.
Set the list of mechanisms to choose from. See the mechanism method for details.
Set the debug level bit-value to "VALUE"

Debug output will be sent to "STDERR". The bits of this value are:

1   Show debug messages in the Perl modules for the mechanisms.
    (Currently only used in GSSAPI)
4   With security layers in place show information on packages read.
8   With security layers in place show information on packages written.

The default value is 0.

Returns the current list of mechanisms
Set the list of mechanisms to choose from. "NAMES" should be a space separated string of the names.
Returns the current callback associated with "NAME".
Sets the given callbacks to the given values
Creates and returns a new connection object for a client-side connection.
Creates and returns a new connection object for a server-side connection.
Returns any error from the last connection

server_start begins the authentication using the chosen mechanism. If the mechanism is not supported by the installed SASL it fails. Because for some mechanisms the client has to start the negotiation, you can give the client challenge as a parameter.
server_step performs the next step in the negotiation process. The first parameter you give is the clients challenge/response.
The initial step to be performed. Returns the initial value to pass to the server or an empty list on error.
This method is called when a response from the server requires it. CHALLENGE is the value from the server. Returns the next value to pass to the server or an empty list on error.
Returns true if the selected mechanism requires another step before completion (error or success).
The method will return the value returned from the last call to the callback NAME
Returns the property value associated with "NAME".
Sets the named properties to their associated values.
Returns the service argument that was passed to *_new-methods.
Returns the host argument that was passed to *_new-methods.
Returns the name of the chosen mechanism.
Once need_step() returns false, then you can check if the authentication succeeded by calling this method which returns a boolean value.

There are three different ways in which a callback may be passed

If the value passed is a code reference then, when needed, it will be called and the connection object will be passed as the first argument. In addition some callbacks may be passed additional arguments.
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 connection object passed as the first argument and all other values from the array passed after.
All other values passed will be used directly. ie it is the same as passing an code reference that, when called, returns the value.

Authen::SASL::Perl, Authen::SASL::XS, Authen::SASL::Cyrus

Erik Huelsmann <ehuels@gmail.com>

Graham Barr <gbarr@pobox.com>

Please report any bugs, or any suggestions, in the GitHub project at https://github.com/gbarr/perl-authen-sasl/issues.

Copyright (c) 2023 Erik Huelsmann
Copyright (c) 1998-2005 Graham Barr.

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

2024-09-01 perl v5.40.0