Skip to content

Commit

Permalink
[#1941] Move middleware auth_tkt code to lib.
Browse files Browse the repository at this point in the history
This puts the auth_tkt related code in the same place.
  • Loading branch information
brew committed Nov 14, 2014
1 parent 53e76cb commit a08cda8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 0 additions & 6 deletions ckan/config/middleware.py
Expand Up @@ -23,7 +23,6 @@
from ckan.plugins import PluginImplementations
from ckan.plugins.interfaces import IMiddleware
from ckan.lib.i18n import get_locales_from_config
from ckan.lib.auth_tkt import make_plugin as auth_tkt_make_plugin
import ckan.lib.uploader as uploader

from ckan.config.environment import load_environment
Expand Down Expand Up @@ -192,11 +191,6 @@ def make_app(conf, full_stack=True, static_files=True, **app_conf):

return app

def ckan_auth_tkt_make_app(**kw):
if not len(kw.get('secret', '')) or kw.get('secret') == 'somesecret':
kw['secret'] = config['beaker.session.secret']
return auth_tkt_make_plugin(**kw)


class I18nMiddleware(object):
"""I18n Middleware selects the language based on the url
Expand Down
2 changes: 1 addition & 1 deletion ckan/config/who.ini
@@ -1,5 +1,5 @@
[plugin:auth_tkt]
use = ckan.config.middleware:ckan_auth_tkt_make_app
use = ckan.lib.auth_tkt:make_plugin
# If no secret key is defined here, beaker.session.secret will be used
#secret = somesecret

Expand Down
7 changes: 7 additions & 0 deletions ckan/lib/auth_tkt.py
@@ -1,5 +1,6 @@
import os

from pylons import config
from repoze.who.plugins import auth_tkt as repoze_auth_tkt

_bool = repoze_auth_tkt._bool
Expand Down Expand Up @@ -69,6 +70,12 @@ def make_plugin(httponly=True,
reissue_time=None,
userid_checker=None):
from repoze.who.utils import resolveDotted

# ckan specific: get secret from beaker setting if necessary
if secret is None or secret == 'somesecret':
secret = config['beaker.session.secret']

# back to repoze boilerplate
if (secret is None and secretfile is None):
raise ValueError("One of 'secret' or 'secretfile' must not be None.")
if (secret is not None and secretfile is not None):
Expand Down

0 comments on commit a08cda8

Please sign in to comment.