本文整理汇总了Python中pyramid.config.Configurator.add_github_login_from_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.add_github_login_from_settings方法的具体用法?Python Configurator.add_github_login_from_settings怎么用?Python Configurator.add_github_login_from_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.add_github_login_from_settings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet', timeout=86400)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, session_factory=my_session_factory, root_factory=AuthRoot)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.include('pyramid_jinja2')
config.include("cornice")
config.include('velruse.providers.github')
config.add_renderer('.html', factory='pyramid_jinja2.renderer_factory')
config.add_jinja2_search_path("verse:templates")
config.add_static_view('static', 'static', cache_max_age=3600)
config.set_default_permission('view')
config.add_github_login_from_settings(prefix='velruse.github.')
setup_urls(config)
config.scan('verse.views')
config.scan('verse.setup_views')
config.scan('verse.account_views')
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application."""
# velruse requires session support
session_factory = UnencryptedCookieSessionFactoryConfig(
settings['session.secret'],
)
# determine which providers we want to configure
providers = settings.get('login_providers', '')
providers = filter(None, [p.strip()
for line in providers.splitlines()
for p in line.split(', ')])
settings['login_providers'] = providers
if not any(providers):
log.warn('no login providers configured, double check your ini '
'file and add a few')
config = Configurator(settings=settings)
config.set_session_factory(session_factory)
config.add_static_view('static', 'static', cache_max_age=3600)
if 'facebook' in providers:
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='facebook.')
if 'github' in providers:
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='github.')
if 'twitter' in providers:
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='twitter.')
if 'live' in providers:
config.include('velruse.providers.live')
config.add_live_login_from_settings(prefix='live.')
if 'bitbucket' in providers:
config.include('velruse.providers.bitbucket')
config.add_bitbucket_login_from_settings(prefix='bitbucket.')
if 'google' in providers:
config.include('velruse.providers.google')
config.add_google_login(
realm=settings['google.realm'],
consumer_key=settings['google.consumer_key'],
consumer_secret=settings['google.consumer_secret'],
)
if 'yahoo' in providers:
config.include('velruse.providers.yahoo')
config.add_yahoo_login(
realm=settings['yahoo.realm'],
consumer_key=settings['yahoo.consumer_key'],
consumer_secret=settings['yahoo.consumer_secret'],
)
config.scan()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Load secret stuff from secret.ini.
try:
default_path = os.path.abspath("secret.ini")
secret_path = settings.get('secret_config_path', default_path)
# TODO: There is a better way to log this message than print.
print "Reading secrets from %r" % secret_path
parser = ConfigParser.ConfigParser()
parser.read(secret_path)
secret_config = dict(parser.items("github2fedmsg"))
settings.update(secret_config)
except Exception as e:
# TODO: There is a better way to log this message than print.
print 'Failed to load secret.ini. Reason: %r' % str(e)
crappy_session_factory = UnencryptedCookieSessionFactoryConfig(settings['session.secret'])
authn_policy = AuthTktAuthenticationPolicy(secret=settings['authnsecret'], hashalg='sha256')
engine = engine_from_config(settings, 'sqlalchemy.')
github2fedmsg.models.DBSession.configure(bind=engine)
config = Configurator(
settings=settings,
root_factory=github2fedmsg.traversal.make_root,
session_factory=crappy_session_factory,
authentication_policy=authn_policy,
#authorization_policy=authz_policy,
)
# Make it so we can do "request.user" in templates.
config.set_request_property(get_user, 'user', reify=True)
config.include('pyramid_mako')
config.add_mako_renderer('.mak')
config.include('velruse.providers.github')
config.add_github_login_from_settings()
config.include('velruse.providers.openid')
github2fedmsg.custom_openid.add_openid_login(
config,
realm=settings.get('velruse.openid.realm'),
identity_provider=settings.get('velruse.openid.identifier'),
)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('logout', '/logout')
config.add_route('webhook', '/webhook')
config.add_route('forget_github_token', '/forget_github_token')
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
authn_policy = AuthTktAuthenticationPolicy(
settings['auth.secret'],
)
authz_policy = ACLAuthorizationPolicy()
database_url = os.environ.get('DATABASE_URL')
if database_url:
settings['sqlalchemy.url'] = database_url
#settings['session.url'] = database_url
setup_tokens(settings)
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
session_factory = session_factory_from_settings(settings)
config = Configurator(
settings=settings,
authentication_policy=authn_policy,
authorization_policy=authz_policy
)
#config.add_tween('ppl.tweens.exception_tween_factory')
config.set_request_property(get_user, 'user', reify=True)
config.include('pyramid_beaker')
config.include('pyramid_jinja2')
config.include(settings.get('mailer_backend', 'pyramid_mailer.testing'))
config.set_session_factory(session_factory)
config.add_renderer('.html', factory='pyramid_jinja2.renderer_factory')
config.add_jinja2_search_path("ppl:templates")
providers = settings.get('login_providers', '')
providers = filter(None, [p.strip()
for line in providers.splitlines()
for p in line.split(', ')])
settings['login_providers'] = providers
if not any(providers):
log.warn('no login providers configured, double check your ini '
'file and add a few')
for provider in providers:
config.include('velruse.providers.%s' % provider)
config.add_github_login_from_settings(prefix='%s.' % provider)
config.include('ppl.people', route_prefix="/people")
config.include('ppl.companies', route_prefix="/companies")
config.include('ppl.account', route_prefix="/account")
config.include('ppl.groups', route_prefix="/groups")
config.include('ppl.jobs', route_prefix="/jobs")
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_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)
config = Configurator(
settings=settings,
session_factory=crappy_session_factory,
authentication_policy=authn_policy,
#authorization_policy=authz_policy,
)
config.include('velruse.providers.github')
config.add_github_login_from_settings()
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('logout', '/logout')
config.scan()
return config.make_wsgi_app()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a WSGI application.
"""
# velruse requires session support
#session_factory = UnencryptedCookieSessionFactoryConfig(
# settings['session.secret'],
#)
providers = settings.get('login_providers', '')
providers = filter(None, [p.strip()
for line in providers.splitlines()
for p in line.split(', ')])
settings['login_providers'] = providers
#config = Configurator(settings=settings, root_factory=Root)
session_factory = session_factory_from_settings(settings)
config = Configurator(
settings=settings,
session_factory=session_factory
)
#config = Configurator(settings=settings)
# Configure Beaker sessions and caching.
config.include("pyramid_beaker")
# config.add_view('login.views.my_view',
# context='login:resources.Root',
# renderer='login:templates/mytemplate.pt')
#config.set_session_factory(session_factory)
config.add_static_view('static', 'static', cache_max_age=3600)
if 'facebook' in providers:
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='facebook.')
if 'github' in providers:
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='github.')
if 'twitter' in providers:
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='twitter.')
if 'live' in providers:
config.include('velruse.providers.live')
config.add_live_login_from_settings(prefix='live.')
if 'bitbucket' in providers:
config.include('velruse.providers.bitbucket')
config.add_bitbucket_login_from_settings(prefix='bitbucket.')
if 'google' in providers:
config.include('velruse.providers.google')
config.add_google_login(
realm=settings['google.realm'],
consumer_key=settings['google.consumer_key'],
consumer_secret=settings['google.consumer_secret'],
)
if 'yahoo' in providers:
config.include('velruse.providers.yahoo')
config.add_yahoo_login(
realm=settings['yahoo.realm'],
consumer_key=settings['yahoo.consumer_key'],
consumer_secret=settings['yahoo.consumer_secret'],
)
config.add_route('home','/')
config.add_view(index, route_name='home',
renderer="neuron:templates/index.pt")
config.add_route('resume_v','/resume_view')
config.add_view(resume_read,route_name='resume_v',renderer="neuron:templates/resume_display.mako")
config.add_route('friend','/friend')
config.add_view(friend,route_name='friend',renderer="neuron:templates/friend.mako")
config.add_route('resume_en','/resume_entered')
config.add_view(resume_write,route_name='resume_en',renderer="neuron:templates/resume_view.mako")
config.add_route('error','/error')
config.add_view(error,route_name='error',renderer="neuron:templates/error.mako")
config.add_route('social_first','/profile_details')
config.add_view(social,route_name='social_first',renderer="neuron:templates/register.pt")
config.add_route('social','/home')
config.add_view(social,route_name='social',renderer="neuron:templates/home.pt")
config.add_route('resume_ed','/resume_edit')
config.add_view(resume_read,route_name='resume_ed',renderer="neuron:templates/resume_view.mako")
config.add_route('delete_edu','/delete_education')
config.add_view(resume_delete,route_name='delete_edu',renderer="neuron:templates/resume_view.mako")
config.add_route('auth','/auth')
config.add_view(authenticate, route_name='auth',renderer="neuron:templates/home.pt")
config.add_route('sign-up','/signup')
config.add_view(signup, route_name="sign-up", renderer="neuron:templates/sign_up.pt")
config.add_route('register-user','/register')
config.add_view(register_user, route_name="register-user", renderer="neuron:templates/register.pt")
#.........这里部分代码省略.........
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_login_from_settings [as 别名]
def main(global_config, **settings):
"""
Serve Doula.
"""
authentication_policy = SessionAuthenticationPolicy(callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
session_factory = UnencryptedCookieSessionFactoryConfig(settings['doula.session.secret'],
cookie_max_age=2592000)
config = Configurator(settings=settings,
root_factory=Site,
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
session_factory=session_factory)
# GitHub integration
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='github.')
# Security
config.set_default_permission('authenticated')
# Tweens
config.add_tween('doula.views.view_helpers.exception_tween_factory')
# Request
config.set_request_property(User.find_user_for_request, 'user', reify=True)
# Jinja2 config
config.add_renderer('.html', renderer_factory)
config.include('pyramid_jinja2')
config.add_static_view(name='js', path='static/js')
config.add_static_view(name='prodjs', path='static/prodjs')
config.add_static_view(name='css', path='static/css')
config.add_static_view(name='images', path='static/images')
config.add_static_view(name='img', path='static/img')
config.add_static_view(name='videos', path='static/videos')
# routes for doula
config.add_route('favicon', '/favicon.ico')
config.add_route('home', '/')
config.add_route('docs', '/docs')
config.add_route('docs_page', '/docs/{page}')
config.add_route('docs_snippet', '/docs/snippets')
config.add_route('sites', '/sites')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('updatedoula', '/updatedoula')
config.add_route('webhook', '/webhook/callbacks')
config.add_route('site', '/sites/{site_name}')
config.add_route('site_label', '/sites/{site_name}/{service_name}/label')
config.add_route('site_lock', '/sites/{site_name}/lock')
# Services routes
config.add_route('service', '/sites/{site_name}/{service_name}')
config.add_route('service_dashboard', '/sites/{site_name}/{service_name}/dash')
config.add_route('service_diff', '/sites/{site_name}/{service_name}/diff')
config.add_route('service_cycle', '/sites/{site_name}/{service_name}/cycle')
config.add_route('service_release', '/sites/{site_name}/{service_name}/release')
config.add_route('deployed_to_production', '/production/deployed')
config.add_route('queue', '/queue')
config.add_route('settings', '/settings')
# Packages routes
config.add_route('packages', '/packages')
config.add_route('build_new_package_modal', '/packages/build_new_package_modal')
config.add_route('build_new_package', '/packages/build_new_package')
config.add_route('bambino_register', '/bambino/register')
config.add_route('bambino_ips', '/bambino/ip_addresses')
# Scan this directory
config.scan('doula.views')
return config.make_wsgi_app()
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_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()
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_github_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()