commit | author | age
|
1ad1db
|
1 |
from webob import Response |
feceff
|
2 |
from pyramid.security import NO_PERMISSION_REQUIRED |
197f0c
|
3 |
from pyramid.view import view_config |
1ad1db
|
4 |
|
0c29cf
|
5 |
|
197f0c
|
6 |
@view_config(name='x') |
0c29cf
|
7 |
def x_view(request): # pragma: no cover |
MM |
8 |
return Response('this is private!') |
|
9 |
|
1ad1db
|
10 |
|
197f0c
|
11 |
@view_config(name='y', permission='private2') |
0c29cf
|
12 |
def y_view(request): # pragma: no cover |
MM |
13 |
return Response('this is private too!') |
|
14 |
|
|
15 |
|
feceff
|
16 |
@view_config(name='z', permission=NO_PERMISSION_REQUIRED) |
1ad1db
|
17 |
def z_view(request): |
0c29cf
|
18 |
return Response('this is public') |
MM |
19 |
|
c1eb0c
|
20 |
|
CM |
21 |
def includeme(config): |
0c29cf
|
22 |
from pyramid.authorization import ACLAuthorizationPolicy |
MM |
23 |
from pyramid.authentication import AuthTktAuthenticationPolicy |
|
24 |
|
|
25 |
authn_policy = AuthTktAuthenticationPolicy('seekt1t', hashalg='sha512') |
|
26 |
authz_policy = ACLAuthorizationPolicy() |
|
27 |
config.scan('tests.pkgs.defpermbugapp') |
|
28 |
config._set_authentication_policy(authn_policy) |
|
29 |
config._set_authorization_policy(authz_policy) |
|
30 |
config.set_default_permission('private') |