Skip to content

Commit 3b5b243

Browse files
authored
Merge pull request #47 from shaarli/ssl-insecure-option
add '--insecure' command line flag, release v0.4.0
2 parents 026f0a2 + f982850 commit 3b5b243

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

docs/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ The format is based on `Keep a Changelog`_ and this project adheres to
99
.. _Keep A Changelog: http://keepachangelog.com/
1010
.. _Semantic Versioning: http://semver.org/
1111

12+
`v0.4.0 <https://github.com/shaarli/python-shaarli-client/releases/tag/v0.3.0>`_ - 2020-01-09
13+
---------------------------------------------------------------------------------------------
14+
15+
**Added:**
16+
17+
* CLI:
18+
19+
* Add support for ``--insecure`` option (bypass SSL certificate verification)
20+
21+
1222
`v0.3.0 <https://github.com/shaarli/python-shaarli-client/releases/tag/v0.3.0>`_ - 2019-02-23
1323
---------------------------------------------------------------------------------------------
1424

docs/user/usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The ``-h`` and ``--help`` flags allow to display help for any command or sub-com
4343
Output formatting
4444
-o --outfile FILENAME
4545
File to save the program output to
46+
--insecure Bypass API SSL/TLS certificate verification
4647
4748
4849
.. code-block:: bash

shaarli_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""shaarli-client"""
22
__title__ = 'shaarli_client'
33
__brief__ = 'CLI to interact with a Shaarli instance'
4-
__version__ = '0.3.0'
4+
__version__ = '0.4.0'
55
__author__ = 'The Shaarli Community'

shaarli_client/client/v1.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _retrieve_http_params(cls, args):
246246

247247
return (endpoint['method'], path, params)
248248

249-
def _request(self, method, endpoint, params):
249+
def _request(self, method, endpoint, params, verify_certs):
250250
"""Send an HTTP request to this instance"""
251251
auth = JWTAuth(self.secret, alg='HS512', header_format='Bearer %s')
252252
auth.add_field('iat', lambda req: calendar.timegm(time.gmtime()))
@@ -258,13 +258,15 @@ def _request(self, method, endpoint, params):
258258
method,
259259
endpoint_uri,
260260
auth=auth,
261-
params=params
261+
params=params,
262+
verify=verify_certs
262263
)
263264
return requests.request(method, endpoint_uri, auth=auth, json=params)
264265

265266
def request(self, args):
266267
"""Send a parameterized request to this instance"""
267-
return self._request(* self._retrieve_http_params(args))
268+
verify_certs = False if args.insecure else True
269+
return self._request(* self._retrieve_http_params(args), verify_certs)
268270

269271
def get_info(self):
270272
"""Get information about this instance"""

shaarli_client/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ def main():
4343
'--outfile',
4444
help="File to save the program output to"
4545
)
46+
parser.add_argument(
47+
'--insecure',
48+
action='store_true',
49+
help="Bypass API SSL/TLS certificate verification"
50+
)
4651

4752
subparsers = parser.add_subparsers(
4853
dest='endpoint_name',

0 commit comments

Comments
 (0)