Show More
@@ -117,10 +117,11 b' class NavigationRegistry(object):' | |||
|
117 | 117 | self._registered_entries[entry.key] = entry |
|
118 | 118 | |
|
119 | 119 | def get_navlist(self, request): |
|
120 | navlist = [NavListEntry(i.key, i.get_localized_name(request), | |
|
120 | nav_list = [ | |
|
121 | NavListEntry(i.key, i.get_localized_name(request), | |
|
121 | 122 |
|
|
122 | 123 |
|
|
123 | return navlist | |
|
124 | return nav_list | |
|
124 | 125 | |
|
125 | 126 | |
|
126 | 127 | def navigation_registry(request, registry=None): |
@@ -143,5 +144,5 b' def includeme(config):' | |||
|
143 | 144 | # Create admin navigation registry and add it to the pyramid registry. |
|
144 | 145 | settings = config.get_settings() |
|
145 | 146 | labs_active = str2bool(settings.get('labs_settings_active', False)) |
|
146 | navigation_registry = NavigationRegistry(labs_active=labs_active) | |
|
147 | config.registry.registerUtility(navigation_registry) No newline at end of file | |
|
147 | navigation_registry_instance = NavigationRegistry(labs_active=labs_active) | |
|
148 | config.registry.registerUtility(navigation_registry_instance) |
@@ -18,11 +18,9 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | import os | |
|
22 | 21 | import logging |
|
23 | 22 | import importlib |
|
24 | 23 | |
|
25 | from pkg_resources import iter_entry_points | |
|
26 | 24 | from pyramid.authentication import SessionAuthenticationPolicy |
|
27 | 25 | |
|
28 | 26 | from rhodecode.authentication.registry import AuthenticationPluginRegistry |
@@ -31,39 +29,12 b' from rhodecode.authentication.routes imp' | |||
|
31 | 29 | from rhodecode.apps._base import ADMIN_PREFIX |
|
32 | 30 | from rhodecode.model.settings import SettingsModel |
|
33 | 31 | |
|
34 | ||
|
35 | 32 | log = logging.getLogger(__name__) |
|
36 | 33 | |
|
37 | # Plugin ID prefixes to distinct between normal and legacy plugins. | |
|
38 | plugin_prefix = 'egg:' | |
|
39 | 34 | legacy_plugin_prefix = 'py:' |
|
40 | 35 | plugin_default_auth_ttl = 30 |
|
41 | 36 | |
|
42 | 37 | |
|
43 | # TODO: Currently this is only used to discover the authentication plugins. | |
|
44 | # Later on this may be used in a generic way to look up and include all kinds | |
|
45 | # of supported enterprise plugins. Therefore this has to be moved and | |
|
46 | # refactored to a real 'plugin look up' machinery. | |
|
47 | # TODO: When refactoring this think about splitting it up into distinct | |
|
48 | # discover, load and include phases. | |
|
49 | def _discover_plugins(config, entry_point='enterprise.plugins1'): | |
|
50 | log.debug('authentication: running plugin discovery for entrypoint %s', | |
|
51 | entry_point) | |
|
52 | ||
|
53 | for ep in iter_entry_points(entry_point): | |
|
54 | plugin_id = '{}{}#{}'.format( | |
|
55 | plugin_prefix, ep.dist.project_name, ep.name) | |
|
56 | log.debug('Plugin discovered: "%s"', plugin_id) | |
|
57 | try: | |
|
58 | module = ep.load() | |
|
59 | plugin = module(plugin_id=plugin_id) | |
|
60 | config.include(plugin.includeme) | |
|
61 | except Exception as e: | |
|
62 | log.exception( | |
|
63 | 'Exception while loading authentication plugin ' | |
|
64 | '"{}": {}'.format(plugin_id, e.message)) | |
|
65 | ||
|
66 | ||
|
67 | 38 | def _import_legacy_plugin(plugin_id): |
|
68 | 39 | module_name = plugin_id.split(legacy_plugin_prefix, 1)[-1] |
|
69 | 40 | module = importlib.import_module(module_name) |
@@ -127,11 +98,14 b' def includeme(config):' | |||
|
127 | 98 | route_name='auth_home', |
|
128 | 99 | context=AuthnRootResource) |
|
129 | 100 | |
|
130 | for key in ['RC_CMD_SETUP_RC', 'RC_CMD_UPGRADE_DB', 'RC_CMD_SSH_WRAPPER']: | |
|
131 | if os.environ.get(key): | |
|
132 | # skip this heavy step below on certain CLI commands | |
|
133 | return | |
|
101 | # load CE authentication plugins | |
|
102 | config.include('rhodecode.authentication.plugins.auth_crowd') | |
|
103 | config.include('rhodecode.authentication.plugins.auth_headers') | |
|
104 | config.include('rhodecode.authentication.plugins.auth_jasig_cas') | |
|
105 | config.include('rhodecode.authentication.plugins.auth_ldap') | |
|
106 | config.include('rhodecode.authentication.plugins.auth_pam') | |
|
107 | config.include('rhodecode.authentication.plugins.auth_rhodecode') | |
|
108 | config.include('rhodecode.authentication.plugins.auth_token') | |
|
134 | 109 | |
|
135 | 110 | # Auto discover authentication plugins and include their configuration. |
|
136 | _discover_plugins(config) | |
|
137 | 111 | _discover_legacy_plugins(config) |
@@ -287,3 +287,8 b' class RhodeCodeAuthPlugin(RhodeCodeExter' | |||
|
287 | 287 | log.debug("Final crowd user object: \n%s", formatted_json(user_attrs)) |
|
288 | 288 | log.info('user `%s` authenticated correctly', user_attrs['username']) |
|
289 | 289 | return user_attrs |
|
290 | ||
|
291 | ||
|
292 | def includeme(config): | |
|
293 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('crowd') | |
|
294 | plugin_factory(plugin_id).includeme(config) |
@@ -223,3 +223,8 b' class RhodeCodeAuthPlugin(RhodeCodeExter' | |||
|
223 | 223 | |
|
224 | 224 | log.info('user `%s` authenticated correctly', user_attrs['username']) |
|
225 | 225 | return user_attrs |
|
226 | ||
|
227 | ||
|
228 | def includeme(config): | |
|
229 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('headers') | |
|
230 | plugin_factory(plugin_id).includeme(config) |
@@ -165,3 +165,8 b' class RhodeCodeAuthPlugin(RhodeCodeExter' | |||
|
165 | 165 | |
|
166 | 166 | log.info('user `%s` authenticated correctly', user_attrs['username']) |
|
167 | 167 | return user_attrs |
|
168 | ||
|
169 | ||
|
170 | def includeme(config): | |
|
171 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('jasig_cas') | |
|
172 | plugin_factory(plugin_id).includeme(config) |
@@ -526,3 +526,8 b' class RhodeCodeAuthPlugin(RhodeCodeExter' | |||
|
526 | 526 | except (Exception,): |
|
527 | 527 | log.exception("Other exception") |
|
528 | 528 | return None |
|
529 | ||
|
530 | ||
|
531 | def includeme(config): | |
|
532 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('ldap') | |
|
533 | plugin_factory(plugin_id).includeme(config) |
@@ -163,3 +163,8 b' class RhodeCodeAuthPlugin(RhodeCodeExter' | |||
|
163 | 163 | log.debug("pamuser: %s", user_attrs) |
|
164 | 164 | log.info('user `%s` authenticated correctly', user_attrs['username']) |
|
165 | 165 | return user_attrs |
|
166 | ||
|
167 | ||
|
168 | def includeme(config): | |
|
169 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('pam') | |
|
170 | plugin_factory(plugin_id).includeme(config) |
@@ -141,3 +141,8 b' class RhodeCodeAuthPlugin(RhodeCodeAuthP' | |||
|
141 | 141 | 'user `%s` failed to authenticate via %s, reason: account not ' |
|
142 | 142 | 'active.', username, self.name) |
|
143 | 143 | return None |
|
144 | ||
|
145 | ||
|
146 | def includeme(config): | |
|
147 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('rhodecode') | |
|
148 | plugin_factory(plugin_id).includeme(config) |
@@ -149,3 +149,8 b' class RhodeCodeAuthPlugin(RhodeCodeAuthP' | |||
|
149 | 149 | 'user `%s` failed to authenticate via %s, reason: account not ' |
|
150 | 150 | 'active.', username, self.name) |
|
151 | 151 | return None |
|
152 | ||
|
153 | ||
|
154 | def includeme(config): | |
|
155 | plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format('token') | |
|
156 | plugin_factory(plugin_id).includeme(config) |
@@ -108,7 +108,8 b' def make_pyramid_app(global_config, **se' | |||
|
108 | 108 | # creating the app uses a connection - return it after we are done |
|
109 | 109 | meta.Session.remove() |
|
110 | 110 | total_time = time.time() - start_time |
|
111 |
log.info('Pyramid app %s created and configured in %.2fs', |
|
|
111 | log.info('Pyramid app `%s` created and configured in %.2fs', | |
|
112 | pyramid_app.func_name, total_time) | |
|
112 | 113 | return pyramid_app |
|
113 | 114 | |
|
114 | 115 | |
@@ -237,13 +238,13 b' def includeme(config):' | |||
|
237 | 238 | config.include('pyramid_beaker') |
|
238 | 239 | config.include('rhodecode.lib.rc_cache') |
|
239 | 240 | |
|
240 | config.include('rhodecode.authentication') | |
|
241 | config.include('rhodecode.integrations') | |
|
242 | ||
|
243 | 241 | config.include('rhodecode.apps._base.navigation') |
|
244 | 242 | config.include('rhodecode.apps._base.subscribers') |
|
245 | 243 | config.include('rhodecode.tweens') |
|
246 | 244 | |
|
245 | config.include('rhodecode.integrations') | |
|
246 | config.include('rhodecode.authentication') | |
|
247 | ||
|
247 | 248 | # apps |
|
248 | 249 | config.include('rhodecode.apps._base') |
|
249 | 250 | config.include('rhodecode.apps.ops') |
@@ -266,7 +267,6 b' def includeme(config):' | |||
|
266 | 267 | config.include('rhodecode.api') |
|
267 | 268 | |
|
268 | 269 | config.add_route('rhodecode_support', 'https://rhodecode.com/help/', static=True) |
|
269 | ||
|
270 | 270 | config.add_translation_dirs('rhodecode:i18n/') |
|
271 | 271 | settings['default_locale_name'] = settings.get('lang', 'en') |
|
272 | 272 |
@@ -32,6 +32,6 b' class IntegrationTypeRegistry(collection' | |||
|
32 | 32 | if key in self: |
|
33 | 33 | log.debug( |
|
34 | 34 | 'Overriding existing integration type %s (%s) with %s', |
|
35 | self[key], key, IntegrationType) | |
|
35 | self[key].__class__, key, IntegrationType) | |
|
36 | 36 | |
|
37 | 37 | self[key] = IntegrationType |
@@ -148,15 +148,6 b' setup(' | |||
|
148 | 148 | }, |
|
149 | 149 | paster_plugins=['PasteScript'], |
|
150 | 150 | entry_points={ |
|
151 | 'enterprise.plugins1': [ | |
|
152 | 'crowd=rhodecode.authentication.plugins.auth_crowd:plugin_factory', | |
|
153 | 'headers=rhodecode.authentication.plugins.auth_headers:plugin_factory', | |
|
154 | 'jasig_cas=rhodecode.authentication.plugins.auth_jasig_cas:plugin_factory', | |
|
155 | 'ldap=rhodecode.authentication.plugins.auth_ldap:plugin_factory', | |
|
156 | 'pam=rhodecode.authentication.plugins.auth_pam:plugin_factory', | |
|
157 | 'rhodecode=rhodecode.authentication.plugins.auth_rhodecode:plugin_factory', | |
|
158 | 'token=rhodecode.authentication.plugins.auth_token:plugin_factory', | |
|
159 | ], | |
|
160 | 151 | 'paste.app_factory': [ |
|
161 | 152 | 'main=rhodecode.config.middleware:make_pyramid_app', |
|
162 | 153 | ], |
General Comments 0
You need to be logged in to leave comments.
Login now