Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into update-pyutilib
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Aug 20, 2019
2 parents 8d8efd2 + 9a80e29 commit 3562899
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 49 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -10,6 +10,24 @@ Changelog
v.2.9.0 TBA
==================

* This version requires changes to the ``who.ini`` configuration file. If your
setup doesn't use the one bundled with this repo, you will have to manually
change the following lines::

use = ckan.lib.auth_tkt:make_plugin

to::

use = ckan.lib.repoze_plugins.auth_tkt:make_plugin

And also::

use = repoze.who.plugins.friendlyform:FriendlyFormPlugin

to::

use = ckan.lib.repoze_plugins.friendly_form:FriendlyFormPlugin

* When upgrading from previous CKAN versions, the Activity Stream needs a
migrate_package_activity.py running for displaying the history of dataset
changes. This can be performed while CKAN is running or stopped (whereas the
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/less.py
Expand Up @@ -61,7 +61,7 @@ def less():
directory = output[0].strip()
if not directory:
error_shout(u'Command "{}" returned nothing. Check that npm is '
u'installed.'.format(' '.join(command)))
u'installed.'.format(u' '.join(command)))
less_bin = os.path.join(directory, u'lessc')

public = config.get(u'ckan.base_public_folder')
Expand Down
7 changes: 4 additions & 3 deletions ckan/cli/tracking.py
Expand Up @@ -145,7 +145,8 @@ def update_tracking(engine, summary_date):
sql = u'''UPDATE tracking_summary t
SET package_id = COALESCE(
(SELECT id FROM package p
WHERE p.name = regexp_replace(' ' || t.url, '^[ ]{1}(/\w{2}){0,1}' || %s, ''))
WHERE p.name = regexp_replace
(' ' || t.url, '^[ ]{1}(/\\w{2}){0,1}' || %s, ''))
,'~~not~found~~')
WHERE t.package_id IS NULL
AND tracking_type = 'page';'''
Expand Down Expand Up @@ -202,8 +203,8 @@ def update_tracking_solr(engine, start_date):

total = len(package_ids)
not_found = 0
click.echo('{} package index{} to be rebuilt starting from {}'.format(
total, '' if total < 2 else 'es', start_date)
click.echo(u'{} package index{} to be rebuilt starting from {}'.format(
total, u'' if total < 2 else u'es', start_date)
)

from ckan.lib.search import rebuild
Expand Down
9 changes: 2 additions & 7 deletions ckan/config/who.ini
@@ -1,10 +1,10 @@
[plugin:auth_tkt]
use = ckan.lib.auth_tkt:make_plugin
use = ckan.lib.repoze_plugins.auth_tkt:make_plugin
# If no secret key is defined here, beaker.session.secret will be used
#secret = somesecret

[plugin:friendlyform]
use = repoze.who.plugins.friendlyform:FriendlyFormPlugin
use = ckan.lib.repoze_plugins.friendly_form:FriendlyFormPlugin
login_form_url= /user/login
login_handler_path = /login_generic
logout_handler_path = /user/logout
Expand All @@ -13,10 +13,6 @@ post_login_url = /user/logged_in
post_logout_url = /user/logged_out
charset = utf-8

#[plugin:basicauth]
#use = repoze.who.plugins.basicauth:make_plugin
#realm = 'CKAN'

[general]
request_classifier = repoze.who.classifiers:default_request_classifier
challenge_decider = repoze.who.classifiers:default_challenge_decider
Expand All @@ -34,4 +30,3 @@ plugins =
[challengers]
plugins =
friendlyform;browser
# basicauth
Empty file.
24 changes: 12 additions & 12 deletions ckan/lib/auth_tkt.py → ckan/lib/repoze_plugins/auth_tkt.py
Expand Up @@ -19,7 +19,7 @@ def __init__(self, httponly, *args, **kwargs):
self.httponly = httponly

def _get_cookies(self, *args, **kwargs):
'''
u'''
Override method in superclass to ensure HttpOnly is set appropriately.
'''
super_cookies = super(CkanAuthTktCookiePlugin, self). \
Expand All @@ -46,29 +46,29 @@ def make_plugin(secret=None,

# ckan specifics:
# Get secret from beaker setting if necessary
if secret is None or secret == 'somesecret':
secret = config['beaker.session.secret']
if secret is None or secret == u'somesecret':
secret = config[u'beaker.session.secret']
# Session timeout and reissue time for auth cookie
if timeout is None and config.get('who.timeout'):
timeout = config.get('who.timeout')
if reissue_time is None and config.get('who.reissue_time'):
reissue_time = config.get('who.reissue_time')
if timeout is None and config.get(u'who.timeout'):
timeout = config.get(u'who.timeout')
if reissue_time is None and config.get(u'who.reissue_time'):
reissue_time = config.get(u'who.reissue_time')
if timeout is not None and reissue_time is None:
reissue_time = int(math.ceil(int(timeout) * 0.1))
# Set httponly based on config value. Default is True
httponly = config.get('who.httponly', True)
httponly = config.get(u'who.httponly', True)
# Set secure based on config value. Default is False
secure = config.get('who.secure', False)
secure = config.get(u'who.secure', False)

# back to repoze boilerplate
if (secret is None and secretfile is None):
raise ValueError("One of 'secret' or 'secretfile' must not be None.")
raise ValueError(u"One of 'secret' or 'secretfile' must not be None.")
if (secret is not None and secretfile is not None):
raise ValueError("Specify only one of 'secret' or 'secretfile'.")
raise ValueError(u"Specify only one of 'secret' or 'secretfile'.")
if secretfile:
secretfile = os.path.abspath(os.path.expanduser(secretfile))
if not os.path.exists(secretfile):
raise ValueError("No such 'secretfile': %s" % secretfile)
raise ValueError(u"No such 'secretfile': %s" % secretfile)
secret = open(secretfile).read().strip()
if timeout:
timeout = int(timeout)
Expand Down

0 comments on commit 3562899

Please sign in to comment.