##// END OF EJS Templates
caches: fixed auth plugin usage of cached settings....
super-admin -
r4836:0d20aaca default
parent child Browse files
Show More
@@ -150,7 +150,6 b' class RhodeCodeAuthPluginBase(object):'
150
150
151 def __init__(self, plugin_id):
151 def __init__(self, plugin_id):
152 self._plugin_id = plugin_id
152 self._plugin_id = plugin_id
153 self._settings = {}
154
153
155 def __str__(self):
154 def __str__(self):
156 return self.get_id()
155 return self.get_id()
@@ -239,14 +238,11 b' class RhodeCodeAuthPluginBase(object):'
239 """
238 """
240 Returns the plugin settings as dictionary.
239 Returns the plugin settings as dictionary.
241 """
240 """
242 if self._settings != {} and use_cache:
243 return self._settings
244
241
245 raw_settings = SettingsModel().get_all_settings()
242 raw_settings = SettingsModel().get_all_settings(cache=use_cache)
246 settings = self._propagate_settings(raw_settings)
243 settings = self._propagate_settings(raw_settings)
247
244
248 self._settings = settings
245 return settings
249 return self._settings
250
246
251 def get_setting_by_name(self, name, default=None, plugin_cached_settings=None):
247 def get_setting_by_name(self, name, default=None, plugin_cached_settings=None):
252 """
248 """
@@ -83,7 +83,7 b' class AuthenticationPluginRegistry(objec'
83 # Add all enabled and active plugins to the list. We iterate over the
83 # Add all enabled and active plugins to the list. We iterate over the
84 # auth_plugins setting from DB because it also represents the ordering.
84 # auth_plugins setting from DB because it also represents the ordering.
85 enabled_plugins = SettingsModel().get_auth_plugins()
85 enabled_plugins = SettingsModel().get_auth_plugins()
86 raw_settings = SettingsModel().get_all_settings()
86 raw_settings = SettingsModel().get_all_settings(cache=True)
87 for plugin_id in enabled_plugins:
87 for plugin_id in enabled_plugins:
88 plugin = self.get_plugin(plugin_id)
88 plugin = self.get_plugin(plugin_id)
89 if plugin is not None and plugin.is_active(
89 if plugin is not None and plugin.is_active(
@@ -135,19 +135,21 b' class Fixture(object):'
135 """
135 """
136
136
137 class context(object):
137 class context(object):
138 def _get_pluing(self):
138 def _get_plugin(self):
139 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
139 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
140 plugin = RhodeCodeAuthPlugin(plugin_id)
140 plugin = RhodeCodeAuthPlugin(plugin_id)
141 return plugin
141 return plugin
142
142
143 def __enter__(self):
143 def __enter__(self):
144 plugin = self._get_pluing()
144
145 plugin = self._get_plugin()
145 plugin.create_or_update_setting('auth_restriction', auth_restriction)
146 plugin.create_or_update_setting('auth_restriction', auth_restriction)
146 Session().commit()
147 Session().commit()
147 SettingsModel().invalidate_settings_cache()
148 SettingsModel().invalidate_settings_cache()
148
149
149 def __exit__(self, exc_type, exc_val, exc_tb):
150 def __exit__(self, exc_type, exc_val, exc_tb):
150 plugin = self._get_pluing()
151
152 plugin = self._get_plugin()
151 plugin.create_or_update_setting(
153 plugin.create_or_update_setting(
152 'auth_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_NONE)
154 'auth_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_NONE)
153 Session().commit()
155 Session().commit()
@@ -167,19 +169,19 b' class Fixture(object):'
167 """
169 """
168
170
169 class context(object):
171 class context(object):
170 def _get_pluing(self):
172 def _get_plugin(self):
171 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
173 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
172 plugin = RhodeCodeAuthPlugin(plugin_id)
174 plugin = RhodeCodeAuthPlugin(plugin_id)
173 return plugin
175 return plugin
174
176
175 def __enter__(self):
177 def __enter__(self):
176 plugin = self._get_pluing()
178 plugin = self._get_plugin()
177 plugin.create_or_update_setting('scope_restriction', scope_restriction)
179 plugin.create_or_update_setting('scope_restriction', scope_restriction)
178 Session().commit()
180 Session().commit()
179 SettingsModel().invalidate_settings_cache()
181 SettingsModel().invalidate_settings_cache()
180
182
181 def __exit__(self, exc_type, exc_val, exc_tb):
183 def __exit__(self, exc_type, exc_val, exc_tb):
182 plugin = self._get_pluing()
184 plugin = self._get_plugin()
183 plugin.create_or_update_setting(
185 plugin.create_or_update_setting(
184 'scope_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_SCOPE_ALL)
186 'scope_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_SCOPE_ALL)
185 Session().commit()
187 Session().commit()
@@ -40,41 +40,68 b' port = 5000'
40 ; Module to use, this setting shouldn't be changed
40 ; Module to use, this setting shouldn't be changed
41 use = egg:gunicorn#main
41 use = egg:gunicorn#main
42
42
43 ## Sets the number of process workers. You must set `instance_id = *`
43 ; Sets the number of process workers. More workers means more concurrent connections
44 ## when this option is set to more than one worker, recommended
44 ; RhodeCode can handle at the same time. Each additional worker also it increases
45 ## value is (2 * NUMBER_OF_CPUS + 1), eg 2CPU = 5 workers
45 ; memory usage as each has it's own set of caches.
46 ## The `instance_id = *` must be set in the [app:main] section below
46 ; Recommended value is (2 * NUMBER_OF_CPUS + 1), eg 2CPU = 5 workers, but no more
47 ; than 8-10 unless for really big deployments .e.g 700-1000 users.
48 ; `instance_id = *` must be set in the [app:main] section below (which is the default)
49 ; when using more than 1 worker.
47 #workers = 2
50 #workers = 2
48 ## number of threads for each of the worker, must be set to 1 for gevent
51
49 ## generally recommened to be at 1
52 ; Gunicorn access log level
50 #threads = 1
53 #loglevel = info
51 ## process name
54
55 ; Process name visible in process list
52 #proc_name = rhodecode
56 #proc_name = rhodecode
53 ## type of worker class, one of sync, gevent
57
54 ## recommended for bigger setup is using of of other than sync one
58 ; Type of worker class, one of `sync`, `gevent`
55 #worker_class = sync
59 ; Recommended type is `gevent`
56 ## The maximum number of simultaneous clients. Valid only for Gevent
60 #worker_class = gevent
61
62 ; The maximum number of simultaneous clients per worker. Valid only for gevent
57 #worker_connections = 10
63 #worker_connections = 10
58 ## max number of requests that worker will handle before being gracefully
64
59 ## restarted, could prevent memory leaks
65 ; Max number of requests that worker will handle before being gracefully restarted.
66 ; Prevents memory leaks, jitter adds variability so not all workers are restarted at once.
60 #max_requests = 1000
67 #max_requests = 1000
61 #max_requests_jitter = 30
68 #max_requests_jitter = 30
62 ## amount of time a worker can spend with handling a request before it
69
63 ## gets killed and restarted. Set to 6hrs
70 ; Amount of time a worker can spend with handling a request before it
71 ; gets killed and restarted. By default set to 21600 (6hrs)
72 ; Examples: 1800 (30min), 3600 (1hr), 7200 (2hr), 43200 (12h)
64 #timeout = 21600
73 #timeout = 21600
65
74
66 ## prefix middleware for RhodeCode.
75 ; The maximum size of HTTP request line in bytes.
67 ## recommended when using proxy setup.
76 ; 0 for unlimited
68 ## allows to set RhodeCode under a prefix in server.
77 #limit_request_line = 0
69 ## eg https://server.com/custom_prefix. Enable `filter-with =` option below as well.
78
70 ## And set your prefix like: `prefix = /custom_prefix`
79
71 ## be sure to also set beaker.session.cookie_path = /custom_prefix if you need
80 ; Prefix middleware for RhodeCode.
72 ## to make your cookies only work on prefix url
81 ; recommended when using proxy setup.
82 ; allows to set RhodeCode under a prefix in server.
83 ; eg https://server.com/custom_prefix. Enable `filter-with =` option below as well.
84 ; And set your prefix like: `prefix = /custom_prefix`
85 ; be sure to also set beaker.session.cookie_path = /custom_prefix if you need
86 ; to make your cookies only work on prefix url
73 [filter:proxy-prefix]
87 [filter:proxy-prefix]
74 use = egg:PasteDeploy#prefix
88 use = egg:PasteDeploy#prefix
75 prefix = /
89 prefix = /
76
90
77 [app:main]
91 [app:main]
92 ; The %(here)s variable will be replaced with the absolute path of parent directory
93 ; of this file
94 ; Each option in the app:main can be override by an environmental variable
95 ;
96 ;To override an option:
97 ;
98 ;RC_<KeyName>
99 ;Everything should be uppercase, . and - should be replaced by _.
100 ;For example, if you have these configuration settings:
101 ;rc_cache.repo_object.backend = foo
102 ;can be overridden by
103 ;export RC_CACHE_REPO_OBJECT_BACKEND=foo
104
78 is_test = True
105 is_test = True
79 use = egg:rhodecode-enterprise-ce
106 use = egg:rhodecode-enterprise-ce
80
107
@@ -115,8 +142,8 b' generate_js_files = false'
115 ; All available languages: en (default), be, de, es, fr, it, ja, pl, pt, ru, zh
142 ; All available languages: en (default), be, de, es, fr, it, ja, pl, pt, ru, zh
116 lang = en
143 lang = en
117
144
118 ## perform a full repository scan on each server start, this should be
145 ; Perform a full repository scan and import on each server start.
119 ## set to false after first startup, to allow faster server restarts.
146 ; Settings this to true could lead to very long startup time.
120 startup.import_repos = true
147 startup.import_repos = true
121
148
122 ; Uncomment and set this path to use archive download cache.
149 ; Uncomment and set this path to use archive download cache.
@@ -161,18 +188,17 b' rss_include_diff = false'
161 ; RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/{gistid}
188 ; RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/{gistid}
162 gist_alias_url =
189 gist_alias_url =
163
190
164 ## List of views (using glob pattern syntax) that AUTH TOKENS could be
191 ; List of views (using glob pattern syntax) that AUTH TOKENS could be
165 ## used for access.
192 ; used for access.
166 ## Adding ?auth_token=TOKEN_HASH to the url authenticates this request as if it
193 ; Adding ?auth_token=TOKEN_HASH to the url authenticates this request as if it
167 ## came from the the logged in user who own this authentication token.
194 ; came from the the logged in user who own this authentication token.
168 ## Additionally @TOKEN syntaxt can be used to bound the view to specific
195 ; Additionally @TOKEN syntax can be used to bound the view to specific
169 ## authentication token. Such view would be only accessible when used together
196 ; authentication token. Such view would be only accessible when used together
170 ## with this authentication token
197 ; with this authentication token
171 ##
198 ; list of all views can be found under `/_admin/permissions/auth_token_access`
172 ## list of all views can be found under `/_admin/permissions/auth_token_access`
199 ; The list should be "," separated and on a single line.
173 ## The list should be "," separated and on a single line.
200 ; Most common views to enable:
174 ##
201
175 ## Most common views to enable:
176 # RepoCommitsView:repo_commit_download
202 # RepoCommitsView:repo_commit_download
177 # RepoCommitsView:repo_commit_patch
203 # RepoCommitsView:repo_commit_patch
178 # RepoCommitsView:repo_commit_raw
204 # RepoCommitsView:repo_commit_raw
@@ -218,19 +244,19 b' auth_plugin.import_legacy_plugins = true'
218 ; This will be served instead of default 401 on bad authentication
244 ; This will be served instead of default 401 on bad authentication
219 auth_ret_code =
245 auth_ret_code =
220
246
221 ## use special detection method when serving auth_ret_code, instead of serving
247 ; use special detection method when serving auth_ret_code, instead of serving
222 ## ret_code directly, use 401 initially (Which triggers credentials prompt)
248 ; ret_code directly, use 401 initially (Which triggers credentials prompt)
223 ## and then serve auth_ret_code to clients
249 ; and then serve auth_ret_code to clients
224 auth_ret_code_detection = false
250 auth_ret_code_detection = false
225
251
226 ## locking return code. When repository is locked return this HTTP code. 2XX
252 ; locking return code. When repository is locked return this HTTP code. 2XX
227 ## codes don't break the transactions while 4XX codes do
253 ; codes don't break the transactions while 4XX codes do
228 lock_ret_code = 423
254 lock_ret_code = 423
229
255
230 ## allows to change the repository location in settings page
256 ; allows to change the repository location in settings page
231 allow_repo_location_change = true
257 allow_repo_location_change = true
232
258
233 ## allows to setup custom hooks in settings page
259 ; allows to setup custom hooks in settings page
234 allow_custom_hooks_settings = true
260 allow_custom_hooks_settings = true
235
261
236 ## generated license token, goto license page in RhodeCode settings to obtain
262 ## generated license token, goto license page in RhodeCode settings to obtain
@@ -245,6 +271,31 b' supervisor.group_id = dev'
245 ## Display extended labs settings
271 ## Display extended labs settings
246 labs_settings_active = true
272 labs_settings_active = true
247
273
274 ; Custom exception store path, defaults to TMPDIR
275 ; This is used to store exception from RhodeCode in shared directory
276 #exception_tracker.store_path =
277
278 ; Send email with exception details when it happens
279 #exception_tracker.send_email = false
280
281 ; Comma separated list of recipients for exception emails,
282 ; e.g admin@rhodecode.com,devops@rhodecode.com
283 ; Can be left empty, then emails will be sent to ALL super-admins
284 #exception_tracker.send_email_recipients =
285
286 ; optional prefix to Add to email Subject
287 #exception_tracker.email_prefix = [RHODECODE ERROR]
288
289 ; File store configuration. This is used to store and serve uploaded files
290 file_store.enabled = true
291
292 ; Storage backend, available options are: local
293 file_store.backend = local
294
295 ; path to store the uploaded binaries
296 file_store.storage_path = %(here)s/data/file_store
297
298
248 ; #############
299 ; #############
249 ; CELERY CONFIG
300 ; CELERY CONFIG
250 ; #############
301 ; #############
@@ -348,16 +399,19 b' beaker.session.secure = false'
348 ## auto save the session to not to use .save()
399 ## auto save the session to not to use .save()
349 beaker.session.auto = false
400 beaker.session.auto = false
350
401
351 ## default cookie expiration time in seconds, set to `true` to set expire
402 ; default cookie expiration time in seconds, set to `true` to set expire
352 ## at browser close
403 ; at browser close
353 #beaker.session.cookie_expires = 3600
404 #beaker.session.cookie_expires = 3600
354
405
355 ; #############################
406 ; #############################
356 ; SEARCH INDEXING CONFIGURATION
407 ; SEARCH INDEXING CONFIGURATION
357 ; #############################
408 ; #############################
358
409
359 ## WHOOSH Backend, doesn't require additional services to run
410 ; Full text search indexer is available in rhodecode-tools under
360 ## it works good with few dozen repos
411 ; `rhodecode-tools index` command
412
413 ; WHOOSH Backend, doesn't require additional services to run
414 ; it works good with few dozen repos
361 search.module = rhodecode.lib.index.whoosh
415 search.module = rhodecode.lib.index.whoosh
362 search.location = %(here)s/data/index
416 search.location = %(here)s/data/index
363
417
@@ -543,9 +597,12 b' ssh.enable_ui_key_generator = true'
543 #statsd.statsd_prefix =
597 #statsd.statsd_prefix =
544 #statsd.statsd_ipv6 = false
598 #statsd.statsd_ipv6 = false
545
599
546
547 ; configure logging automatically at server startup set to false
600 ; configure logging automatically at server startup set to false
548 ; to use the below custom logging config.
601 ; to use the below custom logging config.
602 ; RC_LOGGING_FORMATTER
603 ; RC_LOGGING_LEVEL
604 ; env variables can control the settings for logging in case of autoconfigure
605
549 logging.autoconfigure = false
606 logging.autoconfigure = false
550
607
551 ; specify your own custom logging config file to configure logging
608 ; specify your own custom logging config file to configure logging
@@ -559,14 +616,15 b' custom.conf = 1'
559 ; #####################
616 ; #####################
560 ; LOGGING CONFIGURATION
617 ; LOGGING CONFIGURATION
561 ; #####################
618 ; #####################
619
562 [loggers]
620 [loggers]
563 keys = root, sqlalchemy, beaker, rhodecode, ssh_wrapper
621 keys = root, sqlalchemy, beaker, celery, rhodecode, ssh_wrapper
564
622
565 [handlers]
623 [handlers]
566 keys = console, console_sql
624 keys = console, console_sql
567
625
568 [formatters]
626 [formatters]
569 keys = generic, color_formatter, color_formatter_sql
627 keys = generic, json, color_formatter, color_formatter_sql
570
628
571 ; #######
629 ; #######
572 ; LOGGERS
630 ; LOGGERS
@@ -620,10 +678,9 b' qualname = celery'
620 class = StreamHandler
678 class = StreamHandler
621 args = (sys.stderr, )
679 args = (sys.stderr, )
622 level = DEBUG
680 level = DEBUG
681 ; To enable JSON formatted logs replace 'generic/color_formatter' with 'json'
682 ; This allows sending properly formatted logs to grafana loki or elasticsearch
623 formatter = generic
683 formatter = generic
624 ; To enable JSON formatted logs replace generic with json
625 ; This allows sending properly formatted logs to grafana loki or elasticsearch
626 #formatter = json
627
684
628 [handler_console_sql]
685 [handler_console_sql]
629 ; "level = DEBUG" logs SQL queries and results.
686 ; "level = DEBUG" logs SQL queries and results.
@@ -632,6 +689,8 b' formatter = generic'
632 class = StreamHandler
689 class = StreamHandler
633 args = (sys.stderr, )
690 args = (sys.stderr, )
634 level = WARN
691 level = WARN
692 ; To enable JSON formatted logs replace 'generic/color_formatter_sql' with 'json'
693 ; This allows sending properly formatted logs to grafana loki or elasticsearch
635 formatter = generic
694 formatter = generic
636
695
637 ; ##########
696 ; ##########
@@ -654,5 +713,5 b' format = %(asctime)s.%(msecs)03d [%(proc'
654 datefmt = %Y-%m-%d %H:%M:%S
713 datefmt = %Y-%m-%d %H:%M:%S
655
714
656 [formatter_json]
715 [formatter_json]
657 format = %(message)s
716 format = %(timestamp)s %(levelname)s %(name)s %(message)s %(req_id)s
658 class = rhodecode.lib._vendor.jsonlogger.JsonFormatter No newline at end of file
717 class = rhodecode.lib._vendor.jsonlogger.JsonFormatter
General Comments 0
You need to be logged in to leave comments. Login now