As an Asterisk administrator, I oftentimes cause got clients requesting the mightiness to cause got users come inward a PIN earlier dialing. This is useful on manufactory floors where users roam betwixt dissimilar phones, but even so ask to last held accountable for their calls. Apart from exactly authenticating the user, the dialplan equally good has to ensure that the trouble concern human relationship code is correctly assigned inward the CDR.
To this cease Asterisk provides the AUTHENTICATE dialplan application.
Authenticate has many dissimilar options that makes it really versatile, but what I cause got constitute well-nigh useful is to utilization the file function. This allows you lot to create a file amongst trouble concern human relationship codes in addition to MD5 password hashes.
The file needs to last structured equally follows:
accountcode:passwordmd5
When using the file mode, the trouble concern human relationship code volition last written into the CDR logs. For example:
vim /etc/asterisk/pins.conf
You may utilization a dissimilar file/location 500:8c8a58fa97c205ff222de3685497742c
501:c460dc0f18fc309ac07306a4a55d2fd6
502:d91caca74114d81fdfc578fca82f8d72
503:c0a271bc0ecb776a094786474322cb82
504:889091ff744069cab08dc605d162a8d3
504:eae31887c8969d1bde123982d3d43cd2
To create the MD5 hashes, you lot tin run the next ascendence 501:c460dc0f18fc309ac07306a4a55d2fd6
502:d91caca74114d81fdfc578fca82f8d72
503:c0a271bc0ecb776a094786474322cb82
504:889091ff744069cab08dc605d162a8d3
504:eae31887c8969d1bde123982d3d43cd2
echo -n 4865 | md5sum
You tin substitute 4865 for whatever pivot of your choosing, this delineate volition output an MD5 hash which you lot tin utilization inward the pins.conf file: d91caca74114d81fdfc578fca82f8d72
Again for illustrative purposes, I volition boot the bucket along the dialplan simple.
[outgoing]
exten => _XXX.,1,NoOp(Going Out)
same => n,NoOp(You cause got to authenticate)
same => n,Authenticate(/etc/asterisk/pins.conf,m,4)
same => n,NoOp(user has been authenticated)
same => n,Dial(SIP/${upstream}/${EXTEN})
same => n,HangUp()
exten => _XXX.,1,NoOp(Going Out)
same => n,NoOp(You cause got to authenticate)
same => n,Authenticate(/etc/asterisk/pins.conf,m,4)
same => n,NoOp(user has been authenticated)
same => n,Dial(SIP/${upstream}/${EXTEN})
same => n,HangUp()
The starting fourth dimension delineate matches all numbers amongst to a greater extent than than 3 digits, in addition to reports to the console "Going Out"
The minute delineate is exactly for debugging
The 3rd delineate is the magic one:
It calls the AUTHENTICATE dialplan application amongst a filename equally the starting fourth dimension argument.
The minute declaration "m", specifies that it should exercise a file lookup.
The final declaration sets the pivot length to four digits, hence the user does non ask to cease input amongst a "#"
That's it, Asterisk takes help of the prompts, lookups in addition to writing the right data into the dialplan.