B.11. Authenticate()

Requires that the caller enter a password before proceeding to the next priority.
Authenticate(password[,options[,maxDigits]])
Requires that the caller enters the specified password correctly before proceeding to the next priority. Allows three the caller three chances to enter the password correctly before hanging up.
If password begins with "/" (forward-slash), Asterisk will assume it is a filename to a file containing a list of valid passwords (exactly one per line). Passwords may also be stored in the Asterisk database (AstDB); see option d below.
The following options are allowed (also in combination):
a
(accountcode) Sets the CDR accountcode field and the channel variable ACCOUNTCODE to the entered password.
d
(database) Interprets the entered password as a key in the Asterisk database. If a database key is used, the value in the associated record is ignored and can be arbitrary.
r
(remove) Removes the database key after successful password entry (valid only with option d).
j
(jump) In the event of three failed attempts, jump to priority n+101 (if it exists) instead of hanging up.

Important

When using option d, note that Asterisk looks for a key with a name equivalent to the password: as in /passwords/1234. The value in the record itself is irrelevant. A more logical implementation would be to place the password as a value in the record, as in /passwords/type => 1234.
If maxDigits is set, input is ended as soon as the user has entered enough digits; this saves having to enter "#". (Default: 0; no limits on input).
Returns 0 if the user enters the correct password within three attempts, otherwise hangs up the channel and returns -1.
; Passwort 1234 verlangen:
exten => 123,1,Answer()
exten => 123,2,Authenticate(1234,j,4)           ; an exceptional use of priority jumping because we want to tell the caller
                                                ; that she has entered the wrong password
exten => 123,3,Playback(pin-nummer-akzeptiert)
exten => 123,103,Playback(pin-nummer-falsch)

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'Authenticate' =- 

[Synopsis]
Authenticate a user

[Description]
  Authenticate(password[|options[|maxdigits]]): This application asks the caller
to enter a given password in order to continue dialplan execution. If the password
begins with the '/' character, it is interpreted as a file which contains a list of
valid passwords, listed 1 password per line in the file.
  When using a database key, the value associated with the key can be anything.
Users have three attempts to authenticate before the channel is hung up. If the
passsword is invalid, the 'j' option is specified, and priority n+101 exists,
dialplan execution will continnue at this location.
  Options:
     a - Set the channels' account code to the password that is entered
     d - Interpret the given path as database key, not a literal file
     j - Support jumping to n+101 if authentication fails
     m - Interpret the given path as a file which contains a list of account
         codes and password hashes delimited with ':', listed one per line in
         the file. When one of the passwords is matched, the channel will have
         its account code set to the corresponding account code in the file.
     r - Remove the database key upon successful entry (valid with 'd' only)
     maxdigits  - maximum acceptable number of digits. Stops reading after
         maxdigits have been entered (without requiring the user to
         press the '#' key).
         Defaults to 0 - no limit - wait for the user press the '#' key.
diff output to internal help in Asterisk 1.2:
8,10c8,10
<   Authenticate(password[|options[|maxdigits]]): This application asks the caller
< to enter a given password in order to continue dialplan execution. If the password
< begins with the '/' character, it is interpreted as a file which contains a list of
---
>   Authenticate(password[|options]): This application asks the caller to enter a
> given password in order to continue dialplan execution. If the password begins
> with the '/' character, it is interpreted as a file which contains a list of
25,28d24
<      maxdigits  - maximum acceptable number of digits. Stops reading after
<          maxdigits have been entered (without requiring the user to
<          press the '#' key).
<          Defaults to 0 - no limit - wait for the user press the '#' key.