def test_intercept(): # XXX Note, these tests don't test when the inclusion of a username and only test form # should also test all the other methods too for correct behaviour def sample_app(environ, start_response): if environ.get("PATH_INFO") == "/403": start_response("403 Forbidden", [("Content-type", "text/plain")]) return ["Access denied"] elif environ.get("PATH_INFO") == "/401": start_response("401 Unauth", [("Content-type", "text/plain")]) return ["Not Authed"] elif environ.get("PATH_INFO") == "/702": start_response("702 Doesnt exist", [("Content-type", "text/plain")]) return ["Access denied"] elif environ.get("PATH_INFO") == "/500": start_response("500 Error", [("Content-type", "text/plain")]) return ["Error"] app = middleware( sample_app, setup_method="digest", digest_realm="test", digest_authenticate_user_data=""" Username1:password1 username2:password2 """, cookie_signoutpath="/signout", setup_intercept="403, 702", ) res = TestApp(app).get("/403", status=401) assertEqual(res.header("content-type"), "text/plain; charset=utf8") # XXX Should this keep the original status code or not? assertEqual(res.full_status, "401 Unauthorized") assert "This server could not verify that you are authorized" in res res = TestApp(app).get("/702", status=401) assertEqual(res.header("content-type"), "text/plain; charset=utf8") # XXX Should this keep the original status code or not? assertEqual(res.full_status, "401 Unauthorized") assert "This server could not verify that you are authorized" in res res = TestApp(app).get("/500", status=500) assertEqual(res.header("content-type"), "text/plain") assertEqual(res.full_status, "500 Error") assert "Error" in res res = TestApp(app).get("/401", status=401) assertEqual(res.header("content-type"), "text/plain") assertEqual(res.full_status, "401 Unauth") assert "Not Authed" in res
def test_intercept(): # XXX Note, these tests don't test when the inclusion of a username and only test form # should also test all the other methods too for correct behaviour def sample_app(environ, start_response): if environ.get('PATH_INFO') == '/403': start_response('403 Forbidden', [('Content-type', 'text/plain')]) return ['Access denied'] elif environ.get('PATH_INFO') == '/401': start_response('401 Unauth', [('Content-type', 'text/plain')]) return ['Not Authed'] elif environ.get('PATH_INFO') == '/702': start_response('702 Doesnt exist', [('Content-type', 'text/plain')]) return ['Access denied'] elif environ.get('PATH_INFO') == '/500': start_response('500 Error', [('Content-type', 'text/plain')]) return ['Error'] app = middleware( sample_app, setup_method='digest', digest_realm='test', digest_authenticate_user_data = """ Username1:password1 username2:password2 """, cookie_signoutpath = '/signout', setup_intercept = "403, 702", ) res = TestApp(app).get('/403', status=401) assertEqual(res.header('content-type'), 'text/plain; charset=utf8') # XXX Should this keep the original status code or not? assertEqual(res.full_status, '401 Unauthorized') assert 'This server could not verify that you are authorized' in res res = TestApp(app).get('/702', status=401) assertEqual(res.header('content-type'), 'text/plain; charset=utf8') # XXX Should this keep the original status code or not? assertEqual(res.full_status, '401 Unauthorized') assert 'This server could not verify that you are authorized' in res res = TestApp(app).get('/500', status=500) assertEqual(res.header('content-type'), 'text/plain') assertEqual(res.full_status, '500 Error') assert 'Error' in res res = TestApp(app).get('/401', status=401) assertEqual(res.header('content-type'), 'text/plain') assertEqual(res.full_status, '401 Unauth') assert 'Not Authed' in res
def test_intercept(): # XXX Note, these tests don't test when the inclusion of a username and only test form # should also test all the other methods too for correct behaviour def sample_app(environ, start_response): if environ.get('PATH_INFO') == '/403': start_response('403 Forbidden', [('Content-type', 'text/plain')]) return ['Access denied'] elif environ.get('PATH_INFO') == '/401': start_response('401 Unauth', [('Content-type', 'text/plain')]) return ['Not Authed'] elif environ.get('PATH_INFO') == '/702': start_response('702 Doesnt exist', [('Content-type', 'text/plain')]) return ['Access denied'] elif environ.get('PATH_INFO') == '/500': start_response('500 Error', [('Content-type', 'text/plain')]) return ['Error'] app = middleware( sample_app, setup_method='digest', digest_realm='test', digest_authenticate_user_data = """ Username1:password1 username2:password2 """, cookie_signoutpath = '/signout', setup_intercept = "403, 702", ) res = TestApp(app).get('/403', status=401) assertEqual(res.header('content-type'), 'text/plain') # XXX Should this keep the original status code or not? assertEqual(res.full_status, '401 Unauthorized') assert 'This server could not verify that you are authorized' in res res = TestApp(app).get('/702', status=401) assertEqual(res.header('content-type'), 'text/plain') # XXX Should this keep the original status code or not? assertEqual(res.full_status, '401 Unauthorized') assert 'This server could not verify that you are authorized' in res res = TestApp(app).get('/500', status=500) assertEqual(res.header('content-type'), 'text/plain') assertEqual(res.full_status, '500 Error') assert 'Error' in res res = TestApp(app).get('/401', status=401) assertEqual(res.header('content-type'), 'text/plain') assertEqual(res.full_status, '401 Unauth') assert 'Not Authed' in res
def filter_app(app): app = middleware( AfpyAuth(app), setup_method='openid,cookie', openid_path_signedin='/%smembres/signedin' % prefix, openid_path_verify='/verify', openid_path_process='/process', openid_store_type='file', openid_store_config='', openid_baseurl='http://www.afpy.org', openid_urltouser=urltouser, openid_template_obj='afpy.wsgi.auth:make_template', cookie_secret='secret encryption string', cookie_signoutpath='/signout', ) return SessionMiddleware( app, key='authkit_openid', secret='asdasd', )
params = {} for part in environ['QUERY_STRING'].split('&'): params[part.split("=")[0]] = part.split('=')[1] if params['username'] and params['username'] == params['password']: start_response('200 OK', [('Content-type', 'text/html')]) environ['paste.auth_tkt.set_user'](params['username']) return ["Signed in."] else: start_response('200 OK', [('Content-type', 'text/html')]) return [page%'<p>Invalid details</p>'] start_response('200 OK', [('Content-type', 'text/plain')]) result = ['You Have Access To This Page.\n\nHere is the environment...\n\n'] for k,v in environ.items(): result.append('%s: %s\n'%(k,v)) return result app = middleware( sample_app, setup_method='forward,cookie', forward_signinpath = '/signin', cookie_signoutpath = '/signout', cookie_secret = 'somesecret', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
from authkit.authenticate import middleware, sample_app from beaker.middleware import SessionMiddleware app = middleware( sample_app, setup_method='openid, cookie', openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath = '/signout', openid_sreg_required = 'fullname,nickname,dob,country', openid_sreg_optional = 'timezone,email', openid_sreg_policyurl = 'http://localhost:8080', ) app = SessionMiddleware( app, key='authkit.open_id', secret='some secret', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
# -*- coding: utf-8 -*- from authkit.authenticate import middleware, sample_app app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_data = """ الإعلاني:9406649867375c79247713a7fb81edf0 username2:4e64aba9f0305efa50396584cfbee89c """, form_authenticate_user_encrypt = 'authkit.users:md5', form_authenticate_user_encrypt_secret = 'some secret string', form_charset='UTF-8', # For overriding proxied defaults: # form_action = 'http://localhost/forms/private', cookie_signoutpath = '/signout', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
if __name__ == '__main__': from paste.httpserver import serve from authkit.authenticate import middleware def valid(environ, username, password): """ Sample, very insecure validation function """ return username == password app = httpexceptions.make_middleware(AuthorizeExampleApp()) app = middleware( app, setup_enable=False, setup_method='basic', basic_realm='Test Realm', basic_authenticate_function=valid ) print """ Clear the HTTP authentication first by closing your browser if you have been testing other basic authentication examples on the same port. You will be able to sign in as any user as long as the password is the same as the username, but all users apart from `james' will be denied access to the resources. """ serve(app, host='0.0.0.0', port=8080)
def basic_authenticate(environ, username, password): return username == password app = middleware( sample_app, middleware=make_multi_middleware, openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath='/signout', openid_sreg_required='fullname,nickname,city,country', openid_sreg_optional='timezone,email', openid_sreg_policyurl='http://localhost:5000', form_authenticate_user_data=""" username2:password2 """, form_charset='UTF-8', digest_realm='Test Realm', digest_authenticate_function=digest_authenticate, basic_realm='Test Realm', basic_authenticate_function=basic_authenticate, ) # XXX No Session variables in the config now. if __name__ == '__main__': from paste.httpserver import serve
# -*- coding: utf-8 -*- """ Simple form example which uses a custom validation function to authenticate users. The username is ``test`` the password is ``password``. """ from authkit.authenticate import middleware, sample_app def valid(environ, username, password): return username == 'test' and password == 'password' app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_function=valid, form_charset='UTF-8', cookie_signoutpath='/signout', form_method='get', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
attribute_test.permission = UserIn(users=['james']) if __name__ == '__main__': from paste.httpserver import serve from authkit.authenticate import middleware def valid(environ, username, password): """ Sample, very insecure validation function """ return username == password app = httpexceptions.make_middleware(AuthorizeExampleApp()) app = middleware(app, setup_method='basic', basic_realm='Test Realm', basic_authenticate_function=valid) print """ Clear the HTTP authentication first by closing your browser if you have been testing other basic authentication examples on the same port. You will be able to sign in as any user as long as the password is the same as the username, but all users apart from `james' will be denied access to the resources. """ serve(app, host='0.0.0.0', port=8080)
def make_app(global_conf, full_stack=True, static_files=True, **app_conf): """Create a Pylons WSGI application and return it ``global_conf`` The inherited configuration for this application. Normally from the [DEFAULT] section of the Paste ini file. ``full_stack`` Whether this application provides a full WSGI stack (by default, meaning it handles its own exceptions and errors). Disable full_stack when this application is "managed" by another WSGI middleware. ``static_files`` Whether this application serves its own static files; disable when another web server is responsible for serving them. ``app_conf`` The application's local configuration. Normally specified in the [app:<name>] section of the Paste ini file (where <name> defaults to main). """ # Configure the Pylons environment load_environment(global_conf, app_conf) # The Pylons WSGI app app = PylonsApp() # Routing/Session/Cache Middleware app = RoutesMiddleware(app, config['routes.map']) app = SessionMiddleware(app, config) app = CacheMiddleware(app, config) # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) app = middleware( app, app_conf = app_conf, global_conf = global_conf, ) app = SessionMiddleware( app, key = 'authkit.open_id', secret = 'secret', ) if asbool(full_stack): # Handle Python exceptions app = ErrorHandler(app, global_conf, **config['pylons.errorware']) # Display error documents for 401, 403, 404 status codes (and # 500 when debug is disabled) if asbool(config['debug']): app = StatusCodeRedirect(app) else: app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) # Establish the Registry for this application app = RegistryManager(app) if asbool(static_files): # Serve static files static_app = StaticURLParser(config['pylons.paths']['static_files']) app = Cascade([static_app, app]) return app
from authkit.authenticate import middleware, sample_app from beaker.middleware import SessionMiddleware app = middleware( sample_app, setup_method='openid, cookie', openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath = '/signout', ) app = SessionMiddleware( app, key='authkit.open_id', secret='some secret', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
return digest_password(realm, username, password) def basic_authenticate(environ, username, password): return username == password app = middleware( sample_app, middleware = make_multi_middleware, openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath = '/signout', openid_sreg_required = 'fullname,nickname,city,country', openid_sreg_optional = 'timezone,email', openid_sreg_policyurl = 'http://localhost:5000', form_authenticate_user_data = """ username2:password2 """, form_charset='UTF-8', digest_realm='Test Realm', digest_authenticate_function=digest_authenticate, basic_realm='Test Realm', basic_authenticate_function=basic_authenticate, ) # XXX No Session variables in the config now. if __name__ == '__main__': from paste.httpserver import serve
filename.replace("..", ".") # bottle.static_file parece no funcionar en esta version de bottle return open(os.path.join("static", *filename.split("/"))) if __name__ == '__main__': """Ejecutar con el server de debug de bottle""" bottle.debug(True) app = bottle.default_app() # Mostrar excepciones mientras desarrollamos app.catchall = False app = middleware(app, enable=True, setup_method='openid', openid_store_type='file', openid_template_file=os.path.join(os.getcwd(), 'views', 'invitado.tpl'), openid_store_config=os.getcwd(), openid_path_signedin='/') app = AuthTKTMiddleware(SessionMiddleware(app), 'some auth ticket secret') # Inicializar DB Atajo.init_db() # Ejecutar aplicación bottle.run(app, host="0.0.0.0", port=80)
from authkit.authenticate import middleware, sample_app from beaker.middleware import SessionMiddleware app = middleware( sample_app, setup_method='openid, cookie', openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath='/signout', openid_sreg_required='fullname,nickname,dob,country', openid_sreg_optional='timezone,email', openid_sreg_policyurl='http://localhost:8080', ) app = SessionMiddleware( app, key='authkit.open_id', secret='some secret', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
return gw(environ, start_response) if __name__ == '__main__': from paste.httpserver import serve from authkit.authenticate import middleware service = AuthService() # Configure the remoting services services = { 'auth.echo': service.echo } gw = WSGIGateway(services, logger=logging) app = httpexceptions.make_middleware(AuthorizeExampleApp()) app = middleware( app, setup_method='basic', basic_realm=host_info[2], basic_authenticate_function=service.valid ) print """ Clear the HTTP authentication first by closing your browser if you have been testing other basic authentication examples on the same port. All users apart from `nick' (with password 'nick') will be denied access to the resources. """ serve(app, host=host_info[0], port=host_info[1])
return res else: raise StopIteration def generator(environ, start_response): start_response("200 OK", [("Content-type", "text/html")]) pos = 0 data = [1, 2, 3, 4, 5] while pos < len(data): time.sleep(1) yield str(data[pos]) pos += 1 app = AppClass # app = generator # app = sample_app def valid(environ, username, password): return username == password app = middleware(app, setup_method="basic", basic_realm="Test Realm", basic_authenticate_function=valid) if __name__ == "__main__": from paste.httpserver import serve serve(app, host="0.0.0.0", port=8080)
@bottle.route('/static/:filename') def static_file(filename): """Archivos estáticos (CSS etc)""" bottle.send_file(filename, root='./static/') if __name__ == '__main__': """Ejecutar con el server de debug de bottle""" bottle.debug(True) app = bottle.default_app() # Mostrar excepciones mientras desarrollamos app.catchall = False app = middleware(app, enable=True, setup_method='openid', openid_store_type='file', openid_template_file=os.path.join(os.getcwd(), 'views', 'invitado.tpl'), openid_store_config=os.getcwd(), openid_path_signedin='/') app = AuthTKTMiddleware(SessionMiddleware(app), 'some auth ticket secret') # Inicializar DB Atajo.init_db() # Ejecutar aplicación bottle.run(app)
from authkit.authenticate import middleware, sample_app from authkit.authenticate.digest import digest_password def digest(environ, realm, username): password = username return digest_password(realm, username, password) config = { 'authkit.setup.method':'digest', 'authkit.digest.realm':'Test Realm', 'authkit.digest.authenticate.function':digest, 'authkit.setup.enable':'True', } app = middleware( sample_app, app_conf = config ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
return username == 'bob' and password == 'secret' def app_factory(global_config, **local_conf): return InfoApp() # To start the Site A Attribute Authority run # $ paster serve attribute-service.ini or run this file as a script # $ ./siteAServerApp.py [port #] if __name__ == '__main__': import sys if len(sys.argv) > 1: port = int(sys.argv[1]) else: port = 40000 cfgFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test.ini') from paste.httpserver import serve from paste.deploy import loadapp from authkit.authenticate import middleware appCfg = loadapp('config:%s' % cfgFilePath) app = middleware(appCfg, setup_method='basic', basic_realm='Test Realm', basic_authenticate_function=InfoApp.valid) serve(app, host='0.0.0.0', port=port)
def group(self, environ, start_response): return self._access_granted(start_response, "You are in the <tt>pylons</tt> group.") from sqlalchemymanager import SQLAlchemyManager import authkit.users.sqlalchemy_04_driver import os # os.remove('test.db') app = SampleApp() app = middleware( app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_type= "authkit.users.sqlalchemy_04_driver:UsersFromDatabase", cookie_signoutpath='/signout', setup_intercept="401, 403", ) app = SQLAlchemyManager(app, {'sqlalchemy.url': 'sqlite:///test.db'}, [authkit.users.sqlalchemy_04_driver.setup_model]) app.create_all() connection = app.engine.connect() session = app.session_maker(bind=connection) try: environ = {} environ['sqlalchemy.session'] = session environ['sqlalchemy.model'] = app.model users = authkit.users.sqlalchemy_04_driver.UsersFromDatabase(environ) users.group_create("pylons")
# -*- coding: utf-8 -*- """ Simple form example which uses a custom validation function to authenticate users. The username is ``test`` the password is ``password``. """ from authkit.authenticate import middleware, sample_app def valid(environ, username, password): return username == 'test' and password == 'password' app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_function = valid, form_charset='UTF-8', cookie_signoutpath = '/signout', form_method='get', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
from authkit.authenticate import middleware, sample_app def valid(environ, username, password): return username == password app = middleware( sample_app, setup_method='basic', basic_realm='Test Realm', basic_authenticate_function=valid ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
from authkit.authenticate import middleware, sample_app from authkit.authenticate.digest import digest_password def digest(environ, realm, username): password = username return digest_password(realm, username, password) app = middleware(sample_app, setup_method='digest', digest_realm='Test Realm', digest_authenticate_function=digest) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
thisDir = os.path.abspath(os.path.dirname(__file__)) openIDStoreConfigDir = os.path.join(thisDir, 'data', 'openid') app = middleware(app, setup_method='openid, cookie', cookie_secret='secret string', cookie_signoutpath = '/signout', openid_store_type='file', openid_store_config=openIDStoreConfigDir, openid_session_key='authkit_openid_session_key', openid_session_secret='authkit_openid_session_secret', openid_path_signedin='/', openid_baseurl='http://localhost:8081', openid_ax_typeuri_firstname='http://openid.net/schema/namePerson/first', openid_ax_alias_firstname='firstname', openid_ax_required_firstname=True, openid_ax_typeuri_lastname='http://openid.net/schema/namePerson/last', openid_ax_required_lastname=True, openid_ax_alias_lastname='lastname', openid_ax_typeuri_email='http://openid.net/schema/contact/internet/email', openid_ax_required_email=True, openid_ax_alias_email='email', openid_ax_typeuri_organization='http://openid.net/schema/company/name', openid_ax_alias_organization='organization', # openid_ax_typeuri_city='http://openid.net/schema/contact/city/home', # openid_ax_alias_city='city', # openid_ax_typeuri_state='http://openid.net/schema/contact/state/home', # openid_ax_alias_state='state', # openid_ax_typeuri_country='http://openid.net/schema/contact/country/home', ) app = SessionMiddleware(
# -*- coding: utf-8 -*- from authkit.authenticate import middleware, sample_app app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_data = """ الإعلاني:9406649867375c79247713a7fb81edf0 username2:4e64aba9f0305efa50396584cfbee89c """, form_authenticate_user_encrypt = 'authkit.users:md5', form_authenticate_user_encrypt_secret = 'some secret string', form_charset='UTF-8', cookie_signoutpath = '/signout', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
# -*- coding: utf-8 -*- from authkit.authenticate import middleware, sample_app def user_data(state): return 'User data string' app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_data=""" الإعلاني:9406649867375c79247713a7fb81edf0 username2:4e64aba9f0305efa50396584cfbee89c """, form_authenticate_user_encrypt='authkit.users:md5', form_authenticate_user_encrypt_secret='some secret string', form_charset='UTF-8', # For overriding proxied defaults: # form_action = 'http://localhost/forms/private', cookie_signoutpath='/signout', form_userdata=user_data, ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
from authkit.authenticate import middleware, sample_app from beaker.middleware import SessionMiddleware app = middleware( sample_app, setup_method='openid, cookie', openid_path_signedin='/private', openid_store_type='file', openid_store_config='', openid_charset='UTF-8', cookie_secret='secret encryption string', cookie_signoutpath='/signout', ) app = SessionMiddleware( app, key='authkit.open_id', secret='some secret', ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
@bottle.route('/static/:filename#.*#') @bottle.route('/:filename#favicon.*#') def static_file(filename): """Archivos estáticos (CSS etc)""" # No permitir volver para atras filename.replace("..",".") # bottle.static_file parece no funcionar en esta version de bottle return open(os.path.join("static", *filename.split("/"))) if __name__=='__main__': """Ejecutar con el server de debug de bottle""" bottle.debug(True) app = bottle.default_app() # Mostrar excepciones mientras desarrollamos app.catchall = False app = middleware(app, enable=True, setup_method='openid', openid_store_type='file', openid_store_config=os.getcwd(), openid_path_signedin='/') app = AuthTKTMiddleware(SessionMiddleware(app), 'some auth ticket secret'); # Ejecutar aplicación bottle.run(app)
def static_file(filename): """Archivos estáticos (CSS etc)""" bottle.send_file(filename, root="./static/") if __name__ == "__main__": """Ejecutar con el server de debug de bottle""" bottle.debug(True) app = bottle.default_app() # Mostrar excepciones mientras desarrollamos app.catchall = False app = middleware( app, enable=True, setup_method="openid", openid_store_type="file", openid_template_file=os.path.join(os.getcwd(), "views", "invitado.tpl"), openid_store_config=os.getcwd(), openid_path_signedin="/", ) app = AuthTKTMiddleware(SessionMiddleware(app), "some auth ticket secret") # Inicializar DB Atajo.init_db() # Ejecutar aplicación bottle.run(app)
return self._access_granted(start_response, "You have the <tt>admin</tt> role.") @authorize(HasAuthKitGroup(["pylons"])) def group(self, environ, start_response): return self._access_granted(start_response, "You are in the <tt>pylons</tt> group.") from sqlalchemymanager import SQLAlchemyManager import authkit.users.sqlalchemy_04_driver import os # os.remove('test.db') app = SampleApp() app = middleware( app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_type = "authkit.users.sqlalchemy_04_driver:UsersFromDatabase", cookie_signoutpath = '/signout', setup_intercept = "401, 403", ) app = SQLAlchemyManager(app, {'sqlalchemy.url':'sqlite:///test.db'}, [authkit.users.sqlalchemy_04_driver.setup_model]) app.create_all() connection = app.engine.connect() session = app.session_maker(bind=connection) try: environ = {} environ['sqlalchemy.session'] = session environ['sqlalchemy.model'] = app.model users = authkit.users.sqlalchemy_04_driver.UsersFromDatabase(environ) users.group_create("pylons") users.role_create("admin") users.user_create("james", password="******", group="pylons")
respectively. """ from authkit.authenticate import middleware, sample_app from beaker.middleware import SessionMiddleware def user_data(state): return 'User data string' app = middleware( sample_app, setup_method='form,cookie', cookie_secret='secret encryption string', form_authenticate_user_data=""" الإعلاني:9406649867375c79247713a7fb81edf0 username2:4e64aba9f0305efa50396584cfbee89c """, form_authenticate_user_encrypt='authkit.users:md5', form_authenticate_user_encrypt_secret='some secret string', form_charset='UTF-8', cookie_signoutpath='/signout', cookie_nouserincookie=True, form_userdata=user_data, ) app = SessionMiddleware(app, key='authkit.session', secret="some secret") if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)
from authkit.authenticate import middleware, sample_app app = middleware( sample_app, setup_method='redirect,cookie', redirect_url='http://3aims.com', cookie_secret='asdasd' ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080)