mirror of
https://github.com/caronc/apprise.git
synced 2025-02-26 15:12:11 +01:00
clicksend:// authentication bugfix (#1121)
This commit is contained in:
parent
fcd70ff84c
commit
5fd912f5fe
@ -41,7 +41,6 @@
|
|||||||
#
|
#
|
||||||
import requests
|
import requests
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from base64 import b64encode
|
|
||||||
|
|
||||||
from .base import NotifyBase
|
from .base import NotifyBase
|
||||||
from ..url import PrivacyMode
|
from ..url import PrivacyMode
|
||||||
@ -89,7 +88,7 @@ class NotifyClickSend(NotifyBase):
|
|||||||
|
|
||||||
# Define object templates
|
# Define object templates
|
||||||
templates = (
|
templates = (
|
||||||
'{schema}://{user}:{password}@{targets}',
|
'{schema}://{user}:{apikey}@{targets}',
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define our template tokens
|
# Define our template tokens
|
||||||
@ -99,11 +98,12 @@ class NotifyClickSend(NotifyBase):
|
|||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
'password': {
|
'apikey': {
|
||||||
'name': _('Password'),
|
'name': _('API Key'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'private': True,
|
'private': True,
|
||||||
'required': True,
|
'required': True,
|
||||||
|
'map_to': 'password',
|
||||||
},
|
},
|
||||||
'target_phone': {
|
'target_phone': {
|
||||||
'name': _('Target Phone No'),
|
'name': _('Target Phone No'),
|
||||||
@ -124,6 +124,9 @@ class NotifyClickSend(NotifyBase):
|
|||||||
'to': {
|
'to': {
|
||||||
'alias_of': 'targets',
|
'alias_of': 'targets',
|
||||||
},
|
},
|
||||||
|
'key': {
|
||||||
|
'alias_of': 'apikey',
|
||||||
|
},
|
||||||
'batch': {
|
'batch': {
|
||||||
'name': _('Batch Mode'),
|
'name': _('Batch Mode'),
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
@ -174,9 +177,6 @@ class NotifyClickSend(NotifyBase):
|
|||||||
headers = {
|
headers = {
|
||||||
'User-Agent': self.app_id,
|
'User-Agent': self.app_id,
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
'Authorization': 'Basic {}'.format(
|
|
||||||
b64encode('{}:{}'.format(
|
|
||||||
self.user, self.password).encode('utf-8'))),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# error tracking (used for function return)
|
# error tracking (used for function return)
|
||||||
@ -208,6 +208,7 @@ class NotifyClickSend(NotifyBase):
|
|||||||
r = requests.post(
|
r = requests.post(
|
||||||
self.notify_url,
|
self.notify_url,
|
||||||
data=dumps(payload),
|
data=dumps(payload),
|
||||||
|
auth=(self.user, self.password),
|
||||||
headers=headers,
|
headers=headers,
|
||||||
verify=self.verify_certificate,
|
verify=self.verify_certificate,
|
||||||
timeout=self.request_timeout,
|
timeout=self.request_timeout,
|
||||||
@ -322,6 +323,12 @@ class NotifyClickSend(NotifyBase):
|
|||||||
results['batch'] = \
|
results['batch'] = \
|
||||||
parse_bool(results['qsd'].get('batch', False))
|
parse_bool(results['qsd'].get('batch', False))
|
||||||
|
|
||||||
|
# API Key
|
||||||
|
if 'key' in results['qsd'] and len(results['qsd']['key']):
|
||||||
|
# Extract the API Key from an argument
|
||||||
|
results['password'] = \
|
||||||
|
NotifyClickSend.unquote(results['qsd']['key'])
|
||||||
|
|
||||||
# Support the 'to' variable so that we can support rooms this way too
|
# Support the 'to' variable so that we can support rooms this way too
|
||||||
# The 'to' makes it easier to use yaml configuration
|
# The 'to' makes it easier to use yaml configuration
|
||||||
if 'to' in results['qsd'] and len(results['qsd']['to']):
|
if 'to' in results['qsd'] and len(results['qsd']['to']):
|
||||||
|
@ -62,6 +62,10 @@ apprise_url_tests = (
|
|||||||
# valid number - no batch
|
# valid number - no batch
|
||||||
'instance': NotifyClickSend,
|
'instance': NotifyClickSend,
|
||||||
}),
|
}),
|
||||||
|
('clicksend://user@{}?batch=no&key=abc123'.format('3' * 14), {
|
||||||
|
# valid number - no batch
|
||||||
|
'instance': NotifyClickSend,
|
||||||
|
}),
|
||||||
('clicksend://user:pass@{}'.format('3' * 14), {
|
('clicksend://user:pass@{}'.format('3' * 14), {
|
||||||
'instance': NotifyClickSend,
|
'instance': NotifyClickSend,
|
||||||
# throw a bizzare code forcing us to fail to look it up
|
# throw a bizzare code forcing us to fail to look it up
|
||||||
|
Loading…
Reference in New Issue
Block a user