##// 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 151 def __init__(self, plugin_id):
152 152 self._plugin_id = plugin_id
153 self._settings = {}
154 153
155 154 def __str__(self):
156 155 return self.get_id()
@@ -239,14 +238,11 b' class RhodeCodeAuthPluginBase(object):'
239 238 """
240 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 243 settings = self._propagate_settings(raw_settings)
247 244
248 self._settings = settings
249 return self._settings
245 return settings
250 246
251 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 83 # Add all enabled and active plugins to the list. We iterate over the
84 84 # auth_plugins setting from DB because it also represents the ordering.
85 85 enabled_plugins = SettingsModel().get_auth_plugins()
86 raw_settings = SettingsModel().get_all_settings()
86 raw_settings = SettingsModel().get_all_settings(cache=True)
87 87 for plugin_id in enabled_plugins:
88 88 plugin = self.get_plugin(plugin_id)
89 89 if plugin is not None and plugin.is_active(
@@ -135,19 +135,21 b' class Fixture(object):'
135 135 """
136 136
137 137 class context(object):
138 def _get_pluing(self):
138 def _get_plugin(self):
139 139 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
140 140 plugin = RhodeCodeAuthPlugin(plugin_id)
141 141 return plugin
142 142
143 143 def __enter__(self):
144 plugin = self._get_pluing()
144
145 plugin = self._get_plugin()
145 146 plugin.create_or_update_setting('auth_restriction', auth_restriction)
146 147 Session().commit()
147 148 SettingsModel().invalidate_settings_cache()
148 149
149 150 def __exit__(self, exc_type, exc_val, exc_tb):
150 plugin = self._get_pluing()
151
152 plugin = self._get_plugin()
151 153 plugin.create_or_update_setting(
152 154 'auth_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_NONE)
153 155 Session().commit()
@@ -167,19 +169,19 b' class Fixture(object):'
167 169 """
168 170
169 171 class context(object):
170 def _get_pluing(self):
172 def _get_plugin(self):
171 173 plugin_id = 'egg:rhodecode-enterprise-ce#{}'.format(RhodeCodeAuthPlugin.uid)
172 174 plugin = RhodeCodeAuthPlugin(plugin_id)
173 175 return plugin
174 176
175 177 def __enter__(self):
176 plugin = self._get_pluing()
178 plugin = self._get_plugin()
177 179 plugin.create_or_update_setting('scope_restriction', scope_restriction)
178 180 Session().commit()
179 181 SettingsModel().invalidate_settings_cache()
180 182
181 183 def __exit__(self, exc_type, exc_val, exc_tb):
182 plugin = self._get_pluing()
184 plugin = self._get_plugin()
183 185 plugin.create_or_update_setting(
184 186 'scope_restriction', RhodeCodeAuthPlugin.AUTH_RESTRICTION_SCOPE_ALL)
185 187 Session().commit()
@@ -40,41 +40,68 b' port = 5000'
40 40 ; Module to use, this setting shouldn't be changed
41 41 use = egg:gunicorn#main
42 42
43 ## Sets the number of process workers. You must set `instance_id = *`
44 ## when this option is set to more than one worker, recommended
45 ## value is (2 * NUMBER_OF_CPUS + 1), eg 2CPU = 5 workers
46 ## The `instance_id = *` must be set in the [app:main] section below
43 ; Sets the number of process workers. More workers means more concurrent connections
44 ; RhodeCode can handle at the same time. Each additional worker also it increases
45 ; memory usage as each has it's own set of caches.
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 50 #workers = 2
48 ## number of threads for each of the worker, must be set to 1 for gevent
49 ## generally recommened to be at 1
50 #threads = 1
51 ## process name
51
52 ; Gunicorn access log level
53 #loglevel = info
54
55 ; Process name visible in process list
52 56 #proc_name = rhodecode
53 ## type of worker class, one of sync, gevent
54 ## recommended for bigger setup is using of of other than sync one
55 #worker_class = sync
56 ## The maximum number of simultaneous clients. Valid only for Gevent
57
58 ; Type of worker class, one of `sync`, `gevent`
59 ; Recommended type is `gevent`
60 #worker_class = gevent
61
62 ; The maximum number of simultaneous clients per worker. Valid only for gevent
57 63 #worker_connections = 10
58 ## max number of requests that worker will handle before being gracefully
59 ## restarted, could prevent memory leaks
64
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 67 #max_requests = 1000
61 68 #max_requests_jitter = 30
62 ## amount of time a worker can spend with handling a request before it
63 ## gets killed and restarted. Set to 6hrs
69
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 73 #timeout = 21600
65 74
66 ## prefix middleware for RhodeCode.
67 ## recommended when using proxy setup.
68 ## allows to set RhodeCode under a prefix in server.
69 ## eg https://server.com/custom_prefix. Enable `filter-with =` option below as well.
70 ## And set your prefix like: `prefix = /custom_prefix`
71 ## be sure to also set beaker.session.cookie_path = /custom_prefix if you need
72 ## to make your cookies only work on prefix url
75 ; The maximum size of HTTP request line in bytes.
76 ; 0 for unlimited
77 #limit_request_line = 0
78
79
80 ; Prefix middleware for RhodeCode.
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 87 [filter:proxy-prefix]
74 88 use = egg:PasteDeploy#prefix
75 89 prefix = /
76 90
77 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 105 is_test = True
79 106 use = egg:rhodecode-enterprise-ce
80 107
@@ -115,8 +142,8 b' generate_js_files = false'
115 142 ; All available languages: en (default), be, de, es, fr, it, ja, pl, pt, ru, zh
116 143 lang = en
117 144
118 ## perform a full repository scan on each server start, this should be
119 ## set to false after first startup, to allow faster server restarts.
145 ; Perform a full repository scan and import on each server start.
146 ; Settings this to true could lead to very long startup time.
120 147 startup.import_repos = true
121 148
122 149 ; Uncomment and set this path to use archive download cache.
@@ -161,18 +188,17 b' rss_include_diff = false'
161 188 ; RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/{gistid}
162 189 gist_alias_url =
163 190
164 ## List of views (using glob pattern syntax) that AUTH TOKENS could be
165 ## used for access.
166 ## 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.
168 ## Additionally @TOKEN syntaxt can be used to bound the view to specific
169 ## authentication token. Such view would be only accessible when used together
170 ## with this authentication token
171 ##
172 ## list of all views can be found under `/_admin/permissions/auth_token_access`
173 ## The list should be "," separated and on a single line.
174 ##
175 ## Most common views to enable:
191 ; List of views (using glob pattern syntax) that AUTH TOKENS could be
192 ; used for access.
193 ; Adding ?auth_token=TOKEN_HASH to the url authenticates this request as if it
194 ; came from the the logged in user who own this authentication token.
195 ; Additionally @TOKEN syntax can be used to bound the view to specific
196 ; authentication token. Such view would be only accessible when used together
197 ; with this authentication token
198 ; list of all views can be found under `/_admin/permissions/auth_token_access`
199 ; The list should be "," separated and on a single line.
200 ; Most common views to enable:
201
176 202 # RepoCommitsView:repo_commit_download
177 203 # RepoCommitsView:repo_commit_patch
178 204 # RepoCommitsView:repo_commit_raw
@@ -218,19 +244,19 b' auth_plugin.import_legacy_plugins = true'
218 244 ; This will be served instead of default 401 on bad authentication
219 245 auth_ret_code =
220 246
221 ## use special detection method when serving auth_ret_code, instead of serving
222 ## ret_code directly, use 401 initially (Which triggers credentials prompt)
223 ## and then serve auth_ret_code to clients
247 ; use special detection method when serving auth_ret_code, instead of serving
248 ; ret_code directly, use 401 initially (Which triggers credentials prompt)
249 ; and then serve auth_ret_code to clients
224 250 auth_ret_code_detection = false
225 251
226 ## locking return code. When repository is locked return this HTTP code. 2XX
227 ## codes don't break the transactions while 4XX codes do
252 ; locking return code. When repository is locked return this HTTP code. 2XX
253 ; codes don't break the transactions while 4XX codes do
228 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 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 260 allow_custom_hooks_settings = true
235 261
236 262 ## generated license token, goto license page in RhodeCode settings to obtain
@@ -245,6 +271,31 b' supervisor.group_id = dev'
245 271 ## Display extended labs settings
246 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 300 ; CELERY CONFIG
250 301 ; #############
@@ -348,16 +399,19 b' beaker.session.secure = false'
348 399 ## auto save the session to not to use .save()
349 400 beaker.session.auto = false
350 401
351 ## default cookie expiration time in seconds, set to `true` to set expire
352 ## at browser close
402 ; default cookie expiration time in seconds, set to `true` to set expire
403 ; at browser close
353 404 #beaker.session.cookie_expires = 3600
354 405
355 406 ; #############################
356 407 ; SEARCH INDEXING CONFIGURATION
357 408 ; #############################
358 409
359 ## WHOOSH Backend, doesn't require additional services to run
360 ## it works good with few dozen repos
410 ; Full text search indexer is available in rhodecode-tools under
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 415 search.module = rhodecode.lib.index.whoosh
362 416 search.location = %(here)s/data/index
363 417
@@ -543,9 +597,12 b' ssh.enable_ui_key_generator = true'
543 597 #statsd.statsd_prefix =
544 598 #statsd.statsd_ipv6 = false
545 599
546
547 600 ; configure logging automatically at server startup set to false
548 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 606 logging.autoconfigure = false
550 607
551 608 ; specify your own custom logging config file to configure logging
@@ -559,14 +616,15 b' custom.conf = 1'
559 616 ; #####################
560 617 ; LOGGING CONFIGURATION
561 618 ; #####################
619
562 620 [loggers]
563 keys = root, sqlalchemy, beaker, rhodecode, ssh_wrapper
621 keys = root, sqlalchemy, beaker, celery, rhodecode, ssh_wrapper
564 622
565 623 [handlers]
566 624 keys = console, console_sql
567 625
568 626 [formatters]
569 keys = generic, color_formatter, color_formatter_sql
627 keys = generic, json, color_formatter, color_formatter_sql
570 628
571 629 ; #######
572 630 ; LOGGERS
@@ -620,10 +678,9 b' qualname = celery'
620 678 class = StreamHandler
621 679 args = (sys.stderr, )
622 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 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 685 [handler_console_sql]
629 686 ; "level = DEBUG" logs SQL queries and results.
@@ -632,6 +689,8 b' formatter = generic'
632 689 class = StreamHandler
633 690 args = (sys.stderr, )
634 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 694 formatter = generic
636 695
637 696 ; ##########
@@ -654,5 +713,5 b' format = %(asctime)s.%(msecs)03d [%(proc'
654 713 datefmt = %Y-%m-%d %H:%M:%S
655 714
656 715 [formatter_json]
657 format = %(message)s
658 class = rhodecode.lib._vendor.jsonlogger.JsonFormatter No newline at end of file
716 format = %(timestamp)s %(levelname)s %(name)s %(message)s %(req_id)s
717 class = rhodecode.lib._vendor.jsonlogger.JsonFormatter
General Comments 0
You need to be logged in to leave comments. Login now