Package: pyramid-signed-params
DescriptionThis package provides a method forpyramidapplications to sign parameters
which are passed in query strings (or POST bodies).The initial motivation for this was to be able to pass areturn_urlto a views without turning the app into open redirector.Other use cases include being able to generate URLs (e.g. to be included in
emails) which can be used to bypass the normal authentication/authorization
mechanisms.InstallationPyramid-signed-paramscan be installed fromPyPIusingpiporeasy_install(orbuildout.)  You should probably be installing it in a virtual
environment.ConfigurationYou must configure at least one signing secret in your app settings.
The secret should be a random, unguessable string.  E.g. in your app’s.inifile:pyramid_signed_params.secret = RGWO7nZ6W6AiPIUcXQN2iahJIThwH9BbpyZ7Lc1XfaOkPGt1GYHintYou can specify multiple signing keys (one per line.)  If
you do, the first key will be used for signing, while all keys will
be tried when verifying signatures.  This can be useful when rolling
out a new signing key.Activate the package by including it in your pyramid application.config.include('pyramid-signed-params')This will add two new attributes to pyramid’srequest.request.sign_query(query, max_age=None, kid=None)Used to sign query arguments, e.g.# Pass the current URL as a signed *return_url* parameter to another viewquery={'return_url':request.url}other_url=request.route_url('other',_query=request.sign_query(query))Themax_ageparameter can be used to generate signatures which expire after a certain
amount of time.Passingkid="csrf"will create signatures which will be
invalidated whenever the session’s CSRF token is changed.request.signed_paramsThisreifiedproperty will contain a multidict populated with all
parameters passed to the request which were signed with a valid
signature.Basic Usage ExampleConstruct a URL which could be e-mailed out to allow changing the
password of a given user:# Construct a URL with some signed parameters
params = {'userid': 'fred', 'action': 'change-pw'}
signed_params = request.sign_query(params, max_age=3600)
url = request.route_url('change-pw', _query=signed_params)Then, in the change-pw view:if request.signed_params['action'] != 'change-pw':
    raise HTTPForbidden()
userid = request.signed_params['userid']

# Do whatever needs to be done to change the given users passwordNote that because we passedmax_age=3600tosign_query, the
URL will only work for an hour.CautionThis package provides no inherent protection against replay attacks.
If an attacker has access to a set of signed parameters, he may pass
those signed parameters, unmodified, to any URL within the app (or
other apps sharing the same signing secret.)AuthorsJeff DairikiChangesRelease 1.0.0 (2021-12-21)Add support for Pyramid 2.0.Mark this as a stable release.TestsFix test forPyJWT>=2Test under pythons 3.7 – 3.10. Stop testing under 3.4 and 3.5.Test under PyJWT 1 (as well as latest PyJWT).  Stop testing under PyJWT 1.5.Release 0.1b5 (2018-03-08)Use the new inPyJWT1.6 more specificInvalidSignatureErrorin favor of the genericDecodeErrorto detect invalid signatures
(when available.)TestsTest under bothPyJWT1.6 and 1.5.3.Fix for changes in default log level inpytest3.4.As ofpytest3.3,pytest-catchloghas been rolled into the pytest core.Release 0.1b4 (2017-12-18)PackagingDrop CPython 3.3 classifierRelease 0.1b3 (2017-12-18)CompatibilityDrop support for python 3.3.PackagingInclude LICENSE.txt and pytest.ini in sdist.Release 0.1b2 (2017-11-16)Change thesigned_paramsreified request method so that it
catchesUnicodeDecodeErrors when accessingrequest.params,
and returns an empty dict.  (If the parameters are not properly
encoded, there are no valid signed parameters.)Release 0.1b1 (2017-11-16)Drop support for python 2.6.  Test under python 3.6.SecurityExplicitly specify allowed algorithms when decoding JWTs.Release 0.1a5 (2016-11-13)Remove the (broken) config-time warning issued if no service is
registered forISignedParamsService.  (Whenautocommitwas
off, this warning was always being issued.)Release 0.1a4 (2016-11-02)The setting for configuring the JWT signing secret(s) has been
renamed topyramid_signed_param.secretfrompyramid_signed_param.secrets.  Basic usage involve only a single
secret. (Two allow for rotation of secrets, any configured secrets are
accepted when verifying signatures, but only the first is used for
creating new signatures.)Pyramid_signed_params.includenow issues a warning if theISignedParamsServiceis not configured.JWTSecretProviderFactorynow raises aConfigurationErrorif no secrets are found in the appsettings.Release 0.1a3 (2016-11-02)Initial release.