Skip to content
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/build
.coverage
/htmlcov
.vscode/
.vscode/
.idea/
168 changes: 168 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
master
------

Breaking Changes:
~~~~~~~~~~~~~~~~~

- `#79 <https://github.com/castle/castle-python/pull/79/files>`__ drop the configuration ``host``, ``port``, ``url_prefix`` options in favor of ``base_url``

4.0.0 (2020-07-06)
------------------

Features:
~~~~~~~~~

- `#69 <https://github.com/castle/castle-python/pull/69/files>`__ added
impersonator to properties

Breaking Changes:
~~~~~~~~~~~~~~~~~

- `#70 <https://github.com/castle/castle-python/pull/70>`__ dropped
blacklist and whitelist support, in favour of denylist and allowlist

3.3.0 (2020-05-22)
------------------

- `#67 <https://github.com/castle/castle-python/pull/67>`__ add
``trusted_proxy_depth`` and ``trust_proxy_chain`` configuration
options

3.2.0 (2020-02-31)
------------------

- `#64 <https://github.com/castle/castle-python/pull/64>`__ dropped
X-Client-Id from calculation of ip, drop appending default ip headers
to the ip\_header list config when config is provided (in that case
default headers have to explicitly provided)

3.1.0 (2020-02-27)
------------------

- `#61 <https://github.com/castle/castle-python/pull/61>`__ improve
headers and ip extractions, improve ip\_headers config, add trusted
proxies config, added more events to events list
- `#62 <https://github.com/castle/castle-python/pull/62>`__ move
request,response, session to apis namespace, add config check before
doing request

3.0.0 (2020-02-13)
------------------

- `#59 <https://github.com/castle/castle-python/pull/59>`__ drop
requests min version in ci
- `#56 <https://github.com/castle/castle-python/pull/56>`__ drop
special ip header behavior
- `#58 <https://github.com/castle/castle-python/pull/58>`__ Adds
``ip_header`` configuration option

Breaking Changes:
~~~~~~~~~~~~~~~~~

- `#57 <https://github.com/castle/castle-python/pull/57>`__ dropped
support for python 2

2.4.0 (2019-11-20)
------------------

- `#53 <https://github.com/castle/castle-python/pull/53>`__ update
whitelisting and blacklisting behavior

2.3.1 (2019-04-05)
------------------

- `#50 <https://github.com/castle/castle-python/pull/50>`__ generate
new default timestamps for each call

2.3.0 (2019-01-16)
------------------

- `#48 <https://github.com/castle/castle-python/pull/48>`__ add
connection pooling
- `#47 <https://github.com/castle/castle-python/pull/47>`__ add event
constants
- `#40 <https://github.com/castle/castle-python/pull/40>`__ remove
requirement for ``user_id``

2.2.1 (2018-09-04)
------------------

- `#41 <https://github.com/castle/castle-python/pull/41>`__ add python
2.6, python 3.7

2.2.0 (2018-04-18)
------------------

Breaking Changes:
~~~~~~~~~~~~~~~~~

- `#35 <https://github.com/castle/castle-python/pull/35>`__ usage of
``traits`` key is deprecated, use ``user_traits`` instead
- `#38 <https://github.com/castle/castle-python/pull/38>`__ make api
related errors inherit from ``ApiError``
- `#38 <https://github.com/castle/castle-python/pull/38>`__ rename
``FailoverStrategyValueError`` to ``ConfigurationError``

Enhancements:
~~~~~~~~~~~~~

- `#37 <https://github.com/castle/castle-python/pull/37>`__
``X-Castle-Client-Id`` takes precedence over ``cid`` from ``cookies``
- `#36 <https://github.com/castle/castle-python/pull/36>`__ raise
``ImpersonationFailed`` when impersonation request failed

2.1.1 (2018-02-26)
------------------

Features:
~~~~~~~~~

- add reset option to impersonation

2.1.0 (2018-02-09)
------------------

Features:
~~~~~~~~~

- add support for impersonation

Breaking Changes:
~~~~~~~~~~~~~~~~~

- switched configuration request\_timeout from seconds to milliseconds

2.0.0 (2018-02-09)
------------------

Features:
~~~~~~~~~

- code reorganization
- added ``Client.to_context`` method which allows to generate context
object from the request
- additional timestamp and sent\_at time values are automatically added
to the requests
- when data is sent in batches you may want to wrap data options with
``Client.to_options`` method before you send it to the worker (see
README) to include proper timestamp in the query
- added X-Forwarded-For and CF\_CONNECTING\_IP to whitelisted headers
- fetch IP from CF\_CONNECTING\_IP if possible

Breaking Changes:
~~~~~~~~~~~~~~~~~

- Client does not build context object anymore to use previous
functionality use ``Client.from_request``
- code reorganization

1.0.1 (2017-12-08)
------------------

- Handle cookies from Django request

1.0.0 (2017-10-16)
------------------

- Initial release

97 changes: 0 additions & 97 deletions HISTORY.md

This file was deleted.

3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import and configure the library with your Castle API secret.
# Castle::RequestError is raised when timing out in milliseconds (default: 500 milliseconds)
configuration.request_timeout = 1000

# Base Castle API url
# configuration.base_url = "https://api.castle.io/v1"

# Allowlisted and Denylisted headers are case insensitive
# and allow to use _ and - as a separator, http prefixes are removed
# By default all headers are passed, but some are automatically scrubbed.
Expand Down
25 changes: 0 additions & 25 deletions RELEASING.md

This file was deleted.

26 changes: 26 additions & 0 deletions RELEASING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Releasing
=========

#. Create release branch ``X.Y.Z`` from ``develop``.
#. Update ``VERSION`` in ``castle/version.py`` to the new version
#. Update the ``CHANGELOG.rst`` for the impending release
#. ``git commit -am "release X.Y.Z"`` (where X.Y.Z is the new version)
#. Push to Github, make PR to the develop branch, and when approved, merge.
#. Pull latest ``develop``, merge it to ``master``, and push it.
#. Make a release on Github from the ``master`` branch, specify tag as ``vX.Y.Z`` to create a tag.
#. ``git checkout master && git pull``
#. ``rm -rf dist``
#. ``python3 setup.py sdist bdist_wheel``
#. ``twine upload dist/*``

When you change something in the README.rst make sure it is in the
correct format, as pypi will ignore the file if it is not valid.

``pip3 install collective.checkdocs``

``pip3 install pygments``

``python3 setup.py checkdocs``

To upload to testpypi
``twine upload --repository-url https://test.pypi.org/legacy/ dist/*``
14 changes: 3 additions & 11 deletions castle/apis/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from castle.configuration import configuration
from castle.apis.session import ApisSession

HTTPS_SCHEME = 'https'

class ApisRequest(object):
def __init__(self, headers=None):
Expand All @@ -25,17 +26,8 @@ def build_url(self, path):

@staticmethod
def build_base_url():
template = 'http://{host}:{port}/{prefix}'

if configuration.port == 443:
template = 'https://{host}/{prefix}'

return template.format(
host=configuration.host.strip('/'),
port=configuration.port,
prefix=configuration.url_prefix.strip('/')
)
return configuration.base_url.geturl()

@staticmethod
def verify():
return configuration.port == 443
return configuration.base_url.scheme == HTTPS_SCHEME
Loading