当前位置: 首页>>代码示例>>Python>>正文


Python Configurator.set_authentication_policy方法代码示例

本文整理汇总了Python中pyramid.config.Configurator.set_authentication_policy方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.set_authentication_policy方法的具体用法?Python Configurator.set_authentication_policy怎么用?Python Configurator.set_authentication_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.config.Configurator的用法示例。


在下文中一共展示了Configurator.set_authentication_policy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    authn_policy = AuthTktAuthenticationPolicy("sosecret", callback=groupfinder, hashalg="sha512")
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, root_factory="webapp.models.RootFactory")
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.registry["mailer"] = Mailer.from_settings(settings)
    config.add_static_view("static", "static", cache_max_age=3600)
    config.add_route("index", "/")
    config.add_route("login", "/login")
    config.add_route("logout", "/logout")
    config.add_route("registration", "/registration")
    # config.add_route('end_reg', '/activate/{a_code}')
    config.add_route("verify", "/verify/{code}")
    # config.add_route('confirm', '/confirm')
    config.add_route("content", "/content/{id}")
    config.add_route("about", "/about")
    config.add_route("pay", "/pay")
    config.add_route("preview", "/preview")
    config.add_route("bundle_preview", "/bundle_preview")
    config.add_route("b_content", "/bonus/{id}")
    config.add_route("bundle", "/bundle/{id}")
    config.add_route("account", "/account/{parameters}")
    config.scan()

    return config.make_wsgi_app()
开发者ID:PashaShulga,项目名称:webapp,代码行数:33,代码来源:__init__.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    global globalsettings
    globalsettings = settings

    engine = engine_from_config(settings, 'sqlalchemy.', pool_recycle=1800)
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    config = Configurator(settings=settings)

    from tap.security import groupfinder, get_user, get_user_id

    # attach shortcut property
    config.add_request_method(get_user, 'user', reify=True)
    config.add_request_method(get_user_id, 'userid', reify=True)

    # template
    config.include('pyramid_mako')
    config.add_mako_renderer('.html')

    # Security policies
    authn_policy = AuthTktAuthenticationPolicy(
        settings['tap.secret'], callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    add_route(config)
    add_srv_route(config)

    config.scan()
    return config.make_wsgi_app()
开发者ID:vincentwyshan,项目名称:tap,代码行数:36,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    #authn_policy = AuthTktAuthenticationPolicy(
    #    'sosecret', callback=groupfinder, hashalg='sha512')
    #authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings, root_factory='webnews.models.mymodel.Accesses')
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)    

    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    	
    config.include('ps_alchemy')

    config.include(sacrud_settings)
    settings = config.registry.settings

    
    config.scan()
    return config.make_wsgi_app()
开发者ID:sarafanovde,项目名称:WebNews,代码行数:30,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(root_factory=getAppRoot, settings=settings)
    config.add_static_view('static', 'static', cache_max_age=3600)

#    authnPolicy = BasicAuthAuthenticationPolicy(check=checkAuthentication,
#                                                realm='Djosr Login') #, debug=True)
    authnPolicy = AuthTktAuthenticationPolicy(secret='not telling',
                                              callback=getGroups)#, debug=True)
    authzPolicy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authnPolicy)
    config.set_authorization_policy(authzPolicy)

    sessFactory = UnencryptedCookieSessionFactoryConfig('not telling')
    config.set_session_factory(sessFactory)
    config.add_request_method(getUser, 'user', reify=True)
    config.scan()

    # this saves having to do a GET to catch simple bugs
    # TODO remove later when code is bug-free ;-)
    from pyramid.testing import DummyRequest
    dummy = DummyRequest()
    dummy.registry = config.registry
    getAppRoot(dummy)

    return config.make_wsgi_app()
开发者ID:linuxsoftware,项目名称:djoser,代码行数:29,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application. """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings, session_factory=session_factory)
    config.set_authentication_policy(AuthTktAuthenticationPolicy(
            settings['authtkt.secret']))
    config.set_authorization_policy(ACLAuthorizationPolicy())
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('submit', '/submit')
    config.add_route('details', '/details')
    config.add_route('admin', '/admin')
    config.add_route('csv', '/csv')
    config.add_route('approve', '/approve')
    config.add_route('accept', '/accept')
    config.add_route('save_address', '/save_address')
    config.include('pyramid_mailer')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_view('fedorasummerofhardware.views.login_view',
                    renderer='fedorasummerofhardware:templates/login.mak',
                    context=Forbidden)
    config.scan()
    return config.make_wsgi_app()
开发者ID:fedora-infra,项目名称:fedora-openhw2012,代码行数:29,代码来源:__init__.py

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
	""" This function returns a Pyramid WSGI application.
	"""
	engine = engine_from_config(settings, 'sqlalchemy.')
	DBSession.configure(bind=engine)
	Base.metadata.bind = engine
	config = Configurator(settings=settings, session_factory=sessionfactory)
	config.include('pyramid_mako')
	config.set_authentication_policy(authn_policy)
	config.set_authorization_policy(authz_policy)
	config.add_static_view('static', 'static', cache_max_age=3600)
	config.add_route('home', '/discuss')
	config.add_route('home_slash', '/discuss/')
	config.add_route('home:page', '/discuss/{page:\d+}')
	config.add_route('login', '/login')
	config.add_route('edit', '/edit/{pub:\w+}/{id:\d+}')
	config.add_route('newarticle', '/newarticle')
	config.add_route('article', '/article/{url:\w+}')
	config.add_route('remove', '/remove/{pub:\w+}/{id:\d+}')
	config.add_route('newpost', '/newpost')
	config.add_route('logout', '/logout')
	config.add_route('upload', '/upload')
	config.add_route('main', '/')
	config.scan()
	return config.make_wsgi_app()
开发者ID:annndrey,项目名称:caas,代码行数:27,代码来源:__init__.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """Aquesta funcióó retorna una aplicació WSGI Pyramid"""
    import os
    
    here = os.path.dirname(os.path.abspath(__file__))
    settings['mako.directories'] = os.path.join(here, 'templates')
    
    # afegit del auth module
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(root_factory='.models.RootFactory', settings=settings)
    #config = Configurator(settings=settings)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    
    # static view setup
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/') #arrel
    config.add_route('productes', '/MyProject') #botiga (requadre on podrem veure quins productes tenim, quants i quin es el seu preu, etc)
    config.add_route('index', '/index') #index
    config.add_route('comandes', '/comandes')  #comandes
    config.add_route('comandaNova', '/comandaNova') #afegir una nova comanda
    config.add_route('login', '/login') #login
    config.add_route('logout', '/logout') #logout
    config.scan()
    return config.make_wsgi_app()
开发者ID:cristianbustos,项目名称:botiga2,代码行数:29,代码来源:__init__.py

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """Return a Pyramid WSGI application."""
    database_url = os.environ.get('DATABASE_URL', None)
    if database_url is not None:
        settings['sqlalchemy.url'] = database_url

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    # Security config
    authn_policy = AuthTktAuthenticationPolicy(
        'secret_string', callback=groupfinder, hashalg='sha512')

    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, root_factory="LearningJournal.models.RootFactory")
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    config.include('pyramid_jinja2')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('single_entry', '/entries/{id}')
    config.add_route('add_entry', '/add_entry')
    config.add_route('edit_entry', '/edit_entry/{id}')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.scan()
    return config.make_wsgi_app()
开发者ID:flegald,项目名称:LearningJournal,代码行数:30,代码来源:__init__.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include("solute.epfl")

    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.add_static_view(name='static',
                           path='epfl_pyramid_barebone:static',
                           cache_max_age=3600)

    authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    temp_data_provider = epfltempdata.LocalMemoryProvider(config)
    config.set_tempdata_provider(temp_data_provider)

    nodeglobal_data_provider = epfltempdata.LocalMemoryProvider(config)
    config.set_nodeglobaldata_provider(nodeglobal_data_provider)

    config.scan()
    return config.make_wsgi_app()
开发者ID:JustusW,项目名称:pyramid_epfl,代码行数:28,代码来源:__init__.py

示例10: create_api

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def create_api(global_config, **settings):
    settings = get_settings(global_config, **settings)

    config = Configurator(settings=settings)

    config.set_authentication_policy(remote_authn)
    config.set_authorization_policy(acl_authz)
    config.set_root_factory('h.api.resources.create_root')

    config.add_renderer('json', JSON(indent=4))
    config.add_subscriber('h.api.subscribers.set_user_from_oauth',
                          'pyramid.events.ContextFound')
    config.add_tween('h.api.tweens.auth_token')

    config.include('h.features')

    config.include('h.auth')
    config.include('h.api.db')
    config.include('h.api.views')

    if config.registry.feature('queue'):
        config.include('h.queue')
        config.include('h.api.queue')

    app = config.make_wsgi_app()
    app = permit_cors(app,
                      allow_headers=('Authorization',
                                     'X-Annotator-Auth-Token'),
                      allow_methods=('HEAD', 'GET', 'POST', 'PUT', 'DELETE'))

    return app
开发者ID:juli-so,项目名称:h,代码行数:33,代码来源:app.py

示例11: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    if settings.get("heroku"):
        settings = heroku_settings(settings)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings, root_factory=Root)
    config.include("pyramid_persona")
    authn_policy = AuthTktAuthenticationPolicy(
        settings["persona.secret"], hashalg="sha512", max_age=60 * 60 * 24 * 30
    )  # 1 month
    config.set_authentication_policy(authn_policy)
    session_factory = UnencryptedCookieSessionFactoryConfig(settings["persona.secret"], timeout=60 * 60 * 24)
    config.set_session_factory(session_factory)

    utils.cache.configure_from_config(settings, "cache.")

    config.include("augias.utils.flash")
    config.add_request_method(get_user, "user", reify=True)
    config.add_subscriber(add_global, BeforeRender)

    config.set_default_permission("access")

    config.add_static_view("static", "static", cache_max_age=3600)
    config.scan(".views")
    return config.make_wsgi_app()
开发者ID:madjar,项目名称:augias-old,代码行数:30,代码来源:__init__.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = UnencryptedCookieSessionFactoryConfig('lphfwnviqzivz')
    authn_policy = AuthTktAuthenticationPolicy('afnv9nafcn6q2',
                                                        hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    Base.metadata.bind = engine
    config = Configurator(settings=settings, session_factory=session_factory)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('story_list', '/')
    config.add_route('add_story', '/new/story')
    config.add_route('view_story', '/story/{story_id}')
    config.add_route('edit_story', '/story/{story_id}/edit')
    config.add_route('view_task', '/story/{story_id}/task/{task_id}')
    config.add_route('edit_task', '/story/{story_id}/task/{task_id}/edit')
    config.add_route('stats', '/stats')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.scan()
    return config.make_wsgi_app()
开发者ID:strazdas,项目名称:task_tracker,代码行数:27,代码来源:__init__.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    auth_secret = os.environ.get('LJ_AUTH')
    authentication_policy = AuthTktAuthenticationPolicy(
        secret=auth_secret,
        hashalg='sha512',
    )
    authorization_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=MyRoot,
        )

    config.set_authentication_policy(authentication_policy)
    config.set_authorization_policy(authorization_policy)

    config.include('pyramid_jinja2')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('login', '/login')
    config.add_route('list', '/')
    config.add_route('detail', '/entry/{id:\d+}')
    config.add_route('add_entry', '/entry/add')
    config.add_route('edit_entry', '/entry/{id}/edit')
    config.add_route('logout', '/logout')
    config.scan()
    return config.make_wsgi_app()
开发者ID:jmcclena94,项目名称:learning-journal-1,代码行数:34,代码来源:__init__.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    LogSession.configure(bind=engine)
    Base.metadata.bind = engine
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    
    my_session_factory = session_factory_from_settings(settings)
    config = Configurator(settings=settings,
                          root_factory='loginproject.models.RootFactory',
                          #session_factory=my_session_factory
                          )
    config.include('pyramid_beaker')
    config.set_session_factory(my_session_factory)

    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    config.add_request_method(models.get_user, 'user', reify=True)
    
    config.add_static_view('static', 'static', cache_max_age=3600)
    
    config.add_route('home', '/')
    config.add_route('protected', '/protected')

    config.add_route('login', '/login/{provider}')
    config.add_route('logout', '/logout')
    
    config.scan()
    return config.make_wsgi_app()
开发者ID:petertirrell,项目名称:LoginProject,代码行数:36,代码来源:__init__.py

示例15: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_authentication_policy [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    authn_policy = AuthTktAuthenticationPolicy(
        settings.get('authn_secret'), callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    config = Configurator(settings=settings,
                          root_factory='stockpot.security.RootFactory')

    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.set_request_property(get_user, 'user', reify=True)

    config.add_static_view('static', 'static', cache_max_age=3600)

    config.include(default_routes)
    config.include(user_routes, route_prefix='user')

    config.include('pyramid_beaker')

    config.include('velruse.providers.facebook')
    config.setup_facebook_login_from_settings(prefix='facebook.')

    config.scan()
    return config.make_wsgi_app()
开发者ID:wwitzel3,项目名称:stockpot,代码行数:32,代码来源:__init__.py


注:本文中的pyramid.config.Configurator.set_authentication_policy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。