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


Python Configurator.add_google_oauth2_login_from_settings方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [as 别名]
def main(global_config, **settings):
    authn_policy = AuthTktAuthenticationPolicy(settings.get('pumbaa.secret'), callback=group_finder)
    authz_policy = ACLAuthorizationPolicy()
    pumbaa_session_factory = session_factory_from_settings(settings)
    
    config = Configurator(settings=settings, 
                          root_factory='pumbaa.acl.RootFactory',
                          authentication_policy=authn_policy, 
                          authorization_policy=authz_policy,
                          session_factory = pumbaa_session_factory)

    models.initial(settings)
    
    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='velruse.facebook.')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('velruse.providers.twitter')
    config.add_twitter_login_from_settings(prefix='velruse.twitter.')
    
    add_routes(config)
    config.scan('pumbaa.views')
    
    from .request_factory import RequestWithUserAttribute
    config.set_request_factory(RequestWithUserAttribute)

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

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    NotSoSecret = 'CIeUz0RK8fjRq1wJSrID'
    authn_policy = AuthTktAuthenticationPolicy(NotSoSecret,
                                               callback=groupfinder,
                                               hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    session_factory = SignedCookieSessionFactory(NotSoSecret)

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings, root_factory=Root)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('velruse.providers.google_oauth2')
    config.set_session_factory(session_factory)
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('cornice')
    config.include('pyramid_mako')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('client_agent', 'client_agent', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('tagged', '/tagged/{tags}')
    config.add_route('users', '/users')
    config.add_route('logout', '/logout')
    config.add_route('redirectme', '/go/{uid}')
    config.add_route('provision', '/provision')
    config.add_route('logs', '/logs/{uuid}')
    config.add_route('wall', '/wall/{tags}')
    config.add_request_method(LookupUser, 'user', reify=True)
    config.scan()
    return config.make_wsgi_app()
开发者ID:PeterGrace,项目名称:pi_director,代码行数:36,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [as 别名]
def main(global_config, **settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    session_factory = session_factory_from_settings(settings)
    authn_policy = AuthTktAuthenticationPolicy(settings['auth.secret'],
                                               callback=User.groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        session_factory=session_factory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        root_factory=Root
    )

    config.add_static_view('images', 'duckly:static/images')
    config.add_static_view('js', 'duckly:static/js')
    config.add_static_view('css', 'duckly:static/css')
    config.add_google_oauth2_login_from_settings(prefix='google.')
    config.add_route('logout', '/logout')
    config.add_route('home.unauth', '/', custom_predicates=(unauthorized,))
    config.add_route('home', '/', custom_predicates=(authorized,))
    config.add_route('signup', '/signup')

    config.scan()

    return config.make_wsgi_app()
开发者ID:jaminh,项目名称:duckly-server,代码行数:32,代码来源:__init__.py

示例4: main

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

    config = Configurator(settings=settings,
                          session_factory = my_session_factory)
    
    add_routes(config)
    add_static_resources(config)
    add_subscribers(config)
    register_utilities(config)

    # Configure Velruse
    config.include('oerpub.rhaptoslabs.swordpushweb.google')
    config.add_google_oauth2_login_from_settings()

    config.scan()
    return config.make_wsgi_app()
开发者ID:oerpub,项目名称:oerpub.rhaptoslabs.swordpushweb,代码行数:22,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [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

    settings['mako.directories'] = os.path.join(here,'templates')

    session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config = Configurator(settings=settings,root_factory='.models.RootFactory', session_factory=session_factory)
    
    """Velruse settings
    """
    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='velruse.facebook.')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('velruse.providers.twitter')
    config.add_twitter_login_from_settings(prefix='velruse.twitter.')
    

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

    config.add_static_view('static', 'hallwala:static')
    config.add_static_view('attachment',os.path.join(here, 'static/attachments'))
    config.add_static_view('assets',os.path.join(here, 'static/assets'))
    config.add_static_view('css',os.path.join(here, 'static/css'))
    config.add_static_view('images',os.path.join(here, 'static/images'))
    config.add_static_view('js',os.path.join(here, 'static/js'))
    config.include('pyramid_chameleon')
    
    
    """Routes Here"""
    config.add_route('home', '/')
    
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('loginpage', '/login_page')
    config.add_route('agent', '/agent')
    
    """Static Pages"""
    config.add_route('howItWorks','/how_it_works')
    config.add_route('contact','/contact')
    config.add_route('aboutUs','/about_us')
    config.add_route('termsAndConditions','/terms_and_conditions')
    config.add_route('vision','/vision')
    config.add_route('team','/team')
    
    """Events API"""
    config.add_route('eventAdd','/event_add')
    config.add_route('eventGetAll','/event_get_all')
    config.add_route('eventGetType','/event_get_type/{type}')
    config.add_route('eventGet','/event_get/{event_id}')
    config.add_route('eventDelete','/event_delete/{event_id}')
    
    
    config.scan()
    return config.make_wsgi_app()
开发者ID:m6394g,项目名称:pyramid,代码行数:65,代码来源:__init__.py

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    social_providers = config.registry.settings['allow_auth'].split(',')
    if 'google' in social_providers:
        config.include('velruse.providers.google_oauth2')
        config.add_google_oauth2_login_from_settings()
    if 'github' in social_providers:
        config.include('velruse.providers.github')
        config.add_github_login_from_settings()
    config.add_subscriber(before_render, BeforeRender)

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

    mongo = MongoClient(config.registry.settings['mongo_url'])
    dbmongo = mongo['mydockerhub']
    config.registry.db_mongo = dbmongo

    r = redis.StrictRedis(host=config.registry.settings['redis_host'], port=int(config.registry.settings['redis_port']), db=0)
    config.registry.db_redis = r

    config.registry.admin = config.registry.settings['admin'].split(',')

    config.registry.es = Elasticsearch(config.registry.settings['elastic_host'].split(','))

    config.registry.ldap_server = None
    config.registry.con = None
    if config.registry.settings['use_ldap'] == '1':
        # Check if in ldap
        #import ldap
        from ldap3 import Server, Connection, AUTH_SIMPLE, STRATEGY_SYNC, STRATEGY_ASYNC_THREADED, SEARCH_SCOPE_WHOLE_SUBTREE, GET_ALL_INFO
        try:
            ldap_host = config.registry.settings['ldap.host']
            ldap_port = config.registry.settings['ldap.port']
            config.registry.ldap_server = Server(ldap_host, port=int(ldap_port), get_info=GET_ALL_INFO)
        except Exception as err:
            logging.error(str(err))
            sys.exit(1)


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

    runenv = "dist"
    if "BIOSHADOCK_ENV" in os.environ and os.environ["BIOSHADOCK_ENV"] == "dev":
        runenv = "dev"

    config.add_static_view('app', 'shadock:webapp/'+runenv+'/')
    config.add_route('home', '/')
    config.add_route('config', '/config')
    config.add_route('search', '/search')
    config.add_route('user_is_logged', '/user/logged')
    config.add_route('users', '/user')
    config.add_route('user_logout', '/user/logout')
    config.add_route('user_bind', '/user/bind')
    config.add_route('user', '/user/{id}')
    config.add_route('containers', '/container')
    config.add_route('containers_all', '/container/all')
    config.add_route('containers_latest', '/container/latest')
    config.add_route('containers_search', '/container/search')
    config.add_route('containers_new', '/container/new')
    config.add_route('container_manifest', '/container/manifest/*id')
    config.add_route('container_tags', '/container/tags/*id')
    config.add_route('container_dockerfile', '/container/dockerfile/*id')
    config.add_route('container_git', '/container/git/*id')
    config.add_route('container_tag', '/container/tag/*id')
    config.add_route('container_elixir', '/container/elixir/*id')
    config.add_route('container_metaelixir', '/container/metaelixir/*id')
    config.add_route('container', '/container/*id')
    config.add_route('api_users', '/v1/users/')
    config.add_route('api_library', '/v1/repositories/{image}/')
    config.add_route('api_library_auth', '/v1/repositories/{image}/auth')
    config.add_route('api_library_images', '/v1/repositories/{image}/images')
    config.add_route('api_repositories_images_get', '/v1/repositories/{namespace}/{image}/images')
    config.add_route('api_repositories_images_put', '/v1/repositories/{namespace}/{image}/images')
    config.add_route('api_repositories_images_layer_access', '/v1/repositories/{namespace}/{image}/layer/{id}/access')
    config.add_route('api_repositories', '/v1/repositories/{namespace}/{image}/')
    config.add_route('api_repositories_auth', '/v1/repositories/{namespace}/{image}/auth')
    config.add_route('api_ping', '/v1/_ping')
    config.add_route('api2_ping', '/v2/_ping')
    config.add_route('api2_token', '/v2/token/')
    config.add_route('api2_other', '/v2/*api')
    config.add_route('api_other', '/v1/*api')
    config.scan()

    json_renderer = JSON()
    def pymongo_adapter(obj, request):
        return json_util.default(obj)
    json_renderer.add_adapter(ObjectId, pymongo_adapter)
    json_renderer.add_adapter(datetime.datetime, pymongo_adapter)

    config.add_renderer('json', json_renderer)
    return config.make_wsgi_app()
开发者ID:fjrmoreews,项目名称:bioshadock_server,代码行数:97,代码来源:__init__.py

示例7: main

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

    # Ensure we're not using production.ini verbatim
    for key in (
            'site.store',
            'session.secret',
            'login.google.consumer_key',
            'login.google.consumer_secret',
            'login.facebook.consumer_key',
            'login.facebook.consumer_secret',
            'login.twitter.consumer_key',
            'login.twitter.consumer_secret',
            'login.github.consumer_key',
            'login.github.consumer_secret',
            ):
        if settings.get(key) == 'CHANGEME':
            raise ValueError('You must specify a new value for %s' % key)

    # Ensure path is configured appropriately
    files_dir = os.path.normpath(os.path.expanduser(settings['site.files']))
    licenses_dir = os.path.normpath(os.path.expanduser(settings['licenses.cache_dir']))
    check_path(settings['site.files'])
    check_path(settings['licenses.cache_dir'])

    session_factory = session_factory_from_settings(settings)
    mailer_factory = mailer_factory_from_settings(settings)
    licenses_factory = licenses_factory_from_settings(settings)
    engine = engine_from_config(settings, 'sqlalchemy.')

    # Configure the database session; the session is deliberately separated
    # from the model to enable us to bind it to an engine before importing
    # the model which will then use the bound engine to reflect the database
    from .db_session import DBSession
    DBSession.configure(bind=engine, info={'site.files': files_dir})

    from .security import RequestWithUser, group_finder
    config = Configurator(
            settings=settings,
            session_factory=session_factory,
            request_factory=RequestWithUser,
            )
    if settings.get('login.google.consumer_key'):
        config.include('velruse.providers.google_oauth2')
        config.add_google_oauth2_login_from_settings(prefix='login.google.')
    if settings.get('login.facebook.consumer_key'):
        config.include('velruse.providers.facebook')
        config.add_facebook_login_from_settings(prefix='login.facebook.')
    if settings.get('login.twitter.consumer_key'):
        config.include('velruse.providers.twitter')
        config.add_twitter_login_from_settings(prefix='login.twitter.')
    if settings.get('login.github.consumer_key'):
        config.include('velruse.providers.github')
        config.add_github_login_from_settings(prefix='login.github.')
    config.include('pyramid_chameleon')
    # XXX Need some way of grabbing the authentication secret from config
    authn_policy = AuthTktAuthenticationPolicy(
        'secret', hashalg='sha512', callback=group_finder)
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.registry['mailer'] = mailer_factory
    config.registry['licenses'] = licenses_factory
    config.add_static_view('static', 'static', cache_max_age=3600)

    from .views.comics import routes as comic_routes
    from .views.admin import routes as admin_routes
    from .security import (
        RootContextFactory,
        ComicContextFactory,
        IssueContextFactory,
        PageContextFactory,
        )
    for name, pattern in comic_routes() + admin_routes():
        if '{page' in pattern:
            factory = PageContextFactory
        elif '{issue' in pattern:
            factory = IssueContextFactory
        elif '{comic' in pattern:
            factory = ComicContextFactory
        else:
            factory = RootContextFactory
        config.add_route(name, pattern, factory=factory)
    config.scan()

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

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [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

    session_factory = session_factory_from_settings(settings)
    from szcz.security import groupfinder
    authentication_policy = SessionAuthenticationPolicy(callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings)
    config.set_authentication_policy(authentication_policy)
    config.set_authorization_policy(authorization_policy)
    config.set_request_property('szcz.security.get_user', name='user', reify=True)
    config.add_request_method('szcz.security.has_permission')

    config.include('pyramid_fanstatic')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='google.')
    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='facebook.')
    config.include('velruse.providers.twitter')
    config.add_twitter_login_from_settings(prefix='twitter.')
    config.include('pyramid_beaker')
    config.include('deform_bootstrap')
    config.include('js.deform_bootstrap')

    config.include('pyramid_mailer')
    config.include('pyramid_deform')
    config.include('pyramid_zcml')

    deform_templates = resource_filename('deform', 'templates')
    deform_bootstrap_templates = resource_filename('deform_bootstrap', 'templates')
    deform_szcz_templates = resource_filename('szcz', 'templates')
    search_path = (deform_szcz_templates, deform_bootstrap_templates, deform_templates)

    def translator(term):
        return get_localizer(get_current_request()).translate(term)
    Form.set_zpt_renderer(search_path, translator=translator)

    config.add_route('favicon', '/favicon.ico')
    config.add_route('home', '/')
    config.add_route('proxyerror', '/proxyerror')
    config.add_route('logout', '/logout')
    config.add_route('userprofile', '/profile')

    config.add_route('view_book', '/books/{id:\d+}')
    config.add_route('my_books', '/books/only_mine')
    config.add_route('list_books', '/books')

    config.add_route('list_canons', '/canons')
    config.add_route('view_canon', '/canons/{id:\d+}')

    config.add_route('my_groups', '/groups/only_mine')
    config.add_route('list_groups', '/groups')
    config.add_route('add_group', '/groups/+')
    config.add_route('join_group', '/groups/{id:\d+}/join', factory='szcz.groups.GroupContext')
    config.add_route('logo_group', '/groups/{id:\d+}/logo_view', factory='szcz.groups.GroupContext')
    config.add_route('wf_group', '/groups/{id:\d+}/change_state', factory='szcz.groups.GroupContext')
    config.add_route('wf_groupmembership', '/groups/{id:\d+}/member/{email}/change_state', factory='szcz.groups.GroupContext')
    config.add_route('view_group', '/groups/{id:\d+}', factory='szcz.groups.GroupContext')
    config.add_route('edit_group', '/groups/{id:\d+}/edit', factory='szcz.groups.GroupContext')
    config.add_route('add_book', '/groups/{id:\d+}/add_book', factory='szcz.groups.GroupContext')
    config.add_route('print_activation_group', '/groups/{id:\d+}/print_activation', factory='szcz.groups.GroupContext')
    config.add_route('manage_group_members', '/groups/{id:\d+}/manage_group_members', factory='szcz.groups.GroupContext')

    config.add_static_view('deform_static', 'deform:static')
    config.scan()
    config.set_root_factory('szcz.views.Context')
    config.set_session_factory(session_factory)

    config.add_translation_dirs('deform:locale')
    config.add_translation_dirs('colander:locale')
    config.load_zcml('workflow.zcml')

    return config.make_wsgi_app()
开发者ID:SzkolaCzytania,项目名称:szcz.app,代码行数:80,代码来源:__init__.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_google_oauth2_login_from_settings [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

    settings['mako.directories'] = os.path.join(here,'templates')

    session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config = Configurator(settings=settings,root_factory='.models.RootFactory', session_factory=session_factory)
    
    """Velruse settings
    """
    config.include('velruse.providers.facebook')
    config.add_facebook_login_from_settings(prefix='velruse.facebook.')
    config.include('velruse.providers.google_oauth2')
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    

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

    config.add_static_view('static', 'static')
    config.add_static_view('attachment',os.path.join(here, 'static/attachments'))
    config.add_static_view('css',os.path.join(here, 'static/css'))
    config.add_static_view('js',os.path.join(here, 'static/js'))
    config.include('pyramid_chameleon')


    """ Routes Here """
    config.add_route('home', '/')
    config.add_route('profile', '/profile')
    config.add_route('about', '/about')
    config.add_route('contact', '/contact')
    config.add_route('terms', '/terms')
    config.add_route('team', '/team')
    
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    
    config.add_route('postAdd', '/post_add')
    config.add_route('postTagAdd', '/post_tag_add/{post_id}')
    config.add_route('postTagDelete', '/post_tag_delete/{post_id}/{tag_id}')
    config.add_route('postGet', '/post_get/{post_id}')
    config.add_route('postLike', '/post_like/{post_id}')
    config.add_route('postDislike', '/post_dislike/{post_id}')
    config.add_route('postDelete', '/post_delete/{post_id}')
    
    
    config.add_route('topicAdd', '/topic_add')
    config.add_route('topicGet', '/topic_get/{topic_id}')
    config.add_route('topicFollow', '/topic_follow/{topic_id}')
    config.add_route('topicUnfollow', '/topic_unfollow/{topic_id}')
    config.add_route('topicDelete', '/topic_delete/{topic_id}')
    
    config.add_route('topicFeed', '/topic_feed')
    config.add_route('newsFeed', '/news_feed/{offset}')
    
    config.add_route('search', '/search')
    
    
    config.scan()
    return config.make_wsgi_app()
开发者ID:cs-shadow,项目名称:social-search,代码行数:70,代码来源:__init__.py


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