Revision 301d508e
Modification des applications pour qu'elles utilisent un fichier de configuration séparé pour l'authentification (who.ini).
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@3991 b22e2e97-25c9-44ff-b637-2e5ceca36478
deployment/who.ini | ||
---|---|---|
1 |
[plugin:auth_tkt] |
|
2 |
use = repoze.who.plugins.auth_tkt:make_plugin |
|
3 |
secret = 'vigilo' |
|
4 |
|
|
5 |
[plugin:basicauth] |
|
6 |
use = repoze.who.plugins.basicauth:make_plugin |
|
7 |
realm=Vigilo |
|
8 |
|
|
9 |
[plugin:friendlyform] |
|
10 |
use = repoze.who.plugins.friendlyform:FriendlyFormPlugin |
|
11 |
login_form_url= /login |
|
12 |
login_handler_path = /login_handler |
|
13 |
logout_handler_path = /logout_handler |
|
14 |
rememberer_name = auth_tkt |
|
15 |
post_login_url = /post_login |
|
16 |
post_logout_url = /post_logout |
|
17 |
|
|
18 |
[plugin:sqlauth] |
|
19 |
use = vigilo.turbogears.repoze_plugins:auth_plugin |
|
20 |
|
|
21 |
[general] |
|
22 |
;request_classifier = repoze.who.classifiers:default_request_classifier |
|
23 |
request_classifier = vigilo.turbogears.repoze_plugins:vigilo_api_classifier |
|
24 |
challenge_decider = repoze.who.classifiers:default_challenge_decider |
|
25 |
|
|
26 |
[identifiers] |
|
27 |
plugins = |
|
28 |
friendlyform;browser |
|
29 |
basicauth;vigilo-api |
|
30 |
auth_tkt |
|
31 |
|
|
32 |
[authenticators] |
|
33 |
plugins = |
|
34 |
sqlauth |
|
35 |
|
|
36 |
[challengers] |
|
37 |
plugins = |
|
38 |
friendlyform;browser |
|
39 |
basicauth;vigilo-api |
|
40 |
|
|
41 |
[mdproviders] |
|
42 |
plugins = |
|
43 |
vigilo.turbogears.repoze_plugins:md_plugin |
|
44 |
vigilo.turbogears.repoze_plugins:md_group_plugin |
development.ini | ||
---|---|---|
4 | 4 |
# The %(here)s variable will be replaced with the parent directory of this file |
5 | 5 |
# |
6 | 6 |
# This file is for deployment specific config options -- other configuration |
7 |
# that is always required for the app is done in the config directory,
|
|
8 |
# and generally should not be modified by end users.
|
|
7 |
# that is always required for the app is done in the config directory, |
|
8 |
# and generally should not be modified by end users. |
|
9 | 9 |
|
10 | 10 |
[DEFAULT] |
11 | 11 |
debug = true |
... | ... | |
16 | 16 |
|
17 | 17 |
[server:main] |
18 | 18 |
use = egg:Paste#http |
19 |
host = 0.0.0.0
|
|
19 |
host = 0.0.0.0 |
|
20 | 20 |
port = 8082 |
21 | 21 |
|
22 | 22 |
[app:main] |
... | ... | |
66 | 66 |
# pick the form for your database |
67 | 67 |
# %(here) may include a ':' character on Windows environments; this can |
68 | 68 |
# invalidate the URI when specifying a SQLite db via path name |
69 |
# sqlalchemy.url=postgres://username:password@hostname:port/databasename
|
|
69 |
# sqlalchemy.url=postgres://username:password@hostname:port/databasename |
|
70 | 70 |
# sqlalchemy.url=mysql://username:password@hostname:port/databasename |
71 | 71 |
|
72 | 72 |
|
... | ... | |
107 | 107 |
# execute malicious code after an exception is raised. |
108 | 108 |
#set debug = false |
109 | 109 |
|
110 |
auth.config = %(here)s/who.ini |
|
111 |
#auth.log_file = stdout |
|
112 |
#auth.log_level = debug |
|
113 |
|
|
110 | 114 |
# Logging configuration |
111 | 115 |
# Add additional loggers, handlers, formatters here |
112 | 116 |
# Uses python's logging config file format |
... | ... | |
144 | 148 |
# repoze.who and repoze.what: |
145 | 149 |
[logger_auth] |
146 | 150 |
level = WARN |
147 |
handlers =
|
|
151 |
handlers = |
|
148 | 152 |
qualname = auth |
149 | 153 |
|
150 | 154 |
# If you create additional handlers, add them as a key to [handlers] |
vigigraph/config/app_cfg.py | ||
---|---|---|
8 | 8 |
Please note that **all the argument values are strings**. If you want to |
9 | 9 |
convert them into boolean, for example, you should use the |
10 | 10 |
:func:`paste.deploy.converters.asbool` function, as in:: |
11 |
|
|
11 |
|
|
12 | 12 |
from paste.deploy.converters import asbool |
13 | 13 |
setting = asbool(global_conf.get('the_setting')) |
14 |
|
|
14 |
|
|
15 | 15 |
""" |
16 | 16 |
|
17 | 17 |
import vigigraph |
... | ... | |
20 | 20 |
|
21 | 21 |
base_config = VigiloAppConfig('vigigraph') |
22 | 22 |
base_config.package = vigigraph |
23 |
|
|
24 |
# Configure the authentication backend |
|
25 |
base_config.auth_backend = 'sqlalchemy' |
|
26 |
|
|
27 |
# override this if you would like to provide a different who plugin for |
|
28 |
# managing login and logout of your application |
|
29 |
base_config.sa_auth.form_plugin = None |
|
30 |
|
|
31 |
# You may optionally define a page where you want users to be redirected to |
|
32 |
# on login: |
|
33 |
base_config.sa_auth.post_login_url = '/post_login' |
|
34 |
|
|
35 |
# You may optionally define a page where you want users to be redirected to |
|
36 |
# on logout: |
|
37 |
base_config.sa_auth.post_logout_url = '/post_logout' |
|
38 |
|
|
39 |
|
|
40 |
################################## |
|
41 |
# Settings specific to Vigigraph # |
|
42 |
################################## |
|
43 |
|
vigigraph/config/middleware.py | ||
---|---|---|
8 | 8 |
from pkg_resources import resource_filename |
9 | 9 |
from paste.cascade import Cascade |
10 | 10 |
from paste.urlparser import StaticURLParser |
11 |
from repoze.who.config import make_middleware_with_config \ |
|
12 |
as make_who_with_config |
|
11 | 13 |
|
12 | 14 |
__all__ = ['make_app'] |
13 | 15 |
|
14 |
# Use base_config to setup the necessary PasteDeploy application factory.
|
|
15 |
# make_base_app will wrap the TG2 app with all the middleware it needs.
|
|
16 |
# Use base_config to setup the necessary PasteDeploy application factory. |
|
17 |
# make_base_app will wrap the TG2 app with all the middleware it needs. |
|
16 | 18 |
make_base_app = base_config.setup_tg_wsgi_app(load_environment) |
17 | 19 |
|
18 | 20 |
|
... | ... | |
22 | 24 |
file used. |
23 | 25 |
|
24 | 26 |
This is the PasteDeploy factory for the vigigraph application. |
25 |
|
|
27 |
|
|
26 | 28 |
C{app_conf} contains all the application-specific settings (those defined |
27 | 29 |
under ``[app:main]``). |
28 |
|
|
30 |
|
|
29 | 31 |
@param global_conf: The global settings for vigigraph (those |
30 | 32 |
defined under the ``[DEFAULT]`` section). |
31 | 33 |
@type global_conf: C{dict} |
... | ... | |
35 | 37 |
loaded. |
36 | 38 |
""" |
37 | 39 |
app = make_base_app(global_conf, full_stack=full_stack, **app_conf) |
38 |
|
|
40 |
|
|
39 | 41 |
# On définit 2 middlewares pour fichiers statiques qui cherchent |
40 | 42 |
# les fichiers dans le thème actuellement chargé. |
41 | 43 |
# Le premier va les chercher dans le dossier des fichiers spécifiques |
... | ... | |
48 | 50 |
'vigigraph', 'public')) |
49 | 51 |
app = Cascade([app_static, common_static, local_static, app]) |
50 | 52 |
|
53 |
app = make_who_with_config( |
|
54 |
app, global_conf, |
|
55 |
app_conf.get('auth.config', 'who.ini'), |
|
56 |
app_conf.get('auth.log_file', 'stdout'), |
|
57 |
app_conf.get('auth.log_level', 'debug'), |
|
58 |
) |
|
51 | 59 |
return app |
52 |
|
who.ini | ||
---|---|---|
1 |
[plugin:auth_tkt] |
|
2 |
use = repoze.who.plugins.auth_tkt:make_plugin |
|
3 |
secret = 'vigilo' |
|
4 |
|
|
5 |
[plugin:basicauth] |
|
6 |
use = repoze.who.plugins.basicauth:make_plugin |
|
7 |
realm=Vigilo |
|
8 |
|
|
9 |
[plugin:friendlyform] |
|
10 |
use = repoze.who.plugins.friendlyform:FriendlyFormPlugin |
|
11 |
login_form_url= /login |
|
12 |
login_handler_path = /login_handler |
|
13 |
logout_handler_path = /logout_handler |
|
14 |
rememberer_name = auth_tkt |
|
15 |
post_login_url = /post_login |
|
16 |
post_logout_url = /post_logout |
|
17 |
|
|
18 |
[plugin:sqlauth] |
|
19 |
use = vigilo.turbogears.repoze_plugins:auth_plugin |
|
20 |
|
|
21 |
[general] |
|
22 |
;request_classifier = repoze.who.classifiers:default_request_classifier |
|
23 |
request_classifier = vigilo.turbogears.repoze_plugins:vigilo_api_classifier |
|
24 |
challenge_decider = repoze.who.classifiers:default_challenge_decider |
|
25 |
|
|
26 |
[identifiers] |
|
27 |
plugins = |
|
28 |
friendlyform;browser |
|
29 |
basicauth;vigilo-api |
|
30 |
auth_tkt |
|
31 |
|
|
32 |
[authenticators] |
|
33 |
plugins = |
|
34 |
sqlauth |
|
35 |
|
|
36 |
[challengers] |
|
37 |
plugins = |
|
38 |
friendlyform;browser |
|
39 |
basicauth;vigilo-api |
|
40 |
|
|
41 |
[mdproviders] |
|
42 |
plugins = |
|
43 |
vigilo.turbogears.repoze_plugins:md_plugin |
|
44 |
vigilo.turbogears.repoze_plugins:md_group_plugin |
Also available in: Unified diff