|
|
4 місяців тому | |
|---|---|---|
| .. | ||
| README.md | 4 місяців тому | |
| booking_sms.sh | 4 місяців тому | |
| booking_sms.sieve | 4 місяців тому | |
Extracts a Booking.com Extranet challenge code from an incoming email and
POSTs it to the room-cal /sms/code API so the service can complete
two-factor authentication automatically.
| File | Purpose |
|---|---|
sms_code.sieve |
Sieve rule — matches the message body and pipes to the shell script |
sms_code_filter.sh |
Pipe target — extracts the code and POSTs it to the API |
"Extranet code:", the message is piped (:copy, so
it still lands in the inbox) to sms_code_filter.sh.Extranet code: \K[0-9]{6} and POSTs
{"code": "<digits>"} to ${SMS_API_URL}/sms/code with an
X-SMS-Secret header.GET /sms/code long-poll.apt install dovecot-sieve # Debian/Ubuntu — sieve_extprograms is bundled
/etc/dovecot/conf.d/90-sieve.conf)plugin {
sieve_plugins = sieve_extprograms
sieve_pipe_bin_dir = /etc/dovecot/sieve-pipe
}
cp scripts/sieve/sms_code_filter.sh /etc/dovecot/sieve-pipe/
chmod +x /etc/dovecot/sieve-pipe/sms_code_filter.sh
chown root:dovecot /etc/dovecot/sieve-pipe/sms_code_filter.sh
Edit the top of sms_code_filter.sh (or export from Dovecot's environment):
SMS_API_URL=https://your-room-cal-host # base URL, no trailing slash
SMS_GATEWAY_SECRET=your-secret-here # matches SMS_GATEWAY_SECRET in the API
Per-user — copy or symlink to the user's active script:
cp scripts/sieve/sms_code.sieve /home/zib/sieve/sms_code.sieve
# then reference it from ~/.dovecot.sieve or include it in the active script
Global (applies to all users) — add to sieve_global_path or
sieve_before in 90-sieve.conf:
plugin {
sieve_before = /etc/dovecot/sieve/sms_code.sieve
}
doveadm reload
Send a test message with body Extranet code: 123456 (don't share) and check
that the API receives it:
curl -s -H "X-SMS-Secret: $SMS_GATEWAY_SECRET" \
"${SMS_API_URL}/sms/code?timeout=5"
# → {"code": "123456"}
Check Dovecot logs (/var/log/mail.log) for pipe errors if nothing arrives.