Question

I can't get Pyramid's basic authentication mechanism to work for me. Am I doing it wrong?

To debug, I ran this block of code inside one of my views:

print '$$$1', pyramid.security.remember(request, 12)
print '$$$2', pyramid.security.unauthenticated_userid(request)
print '$$$3', pyramid.security.authenticated_userid(request)

Here is the output I got:

$$$1 [('Set-Cookie', 'auth_tkt="45a66a6e860356b991cc8fc8acf9bf7f4d8b3d2212!userid_type:int"; Path=/'), ('Set-Cookie', 'auth_tkt="45a66a6e860356b991cc8fc8acf9bf7f4d8b3d2212!userid_type:int"; Path=/; Domain=127.0.0.1:6543'), ('Set-Cookie', 'auth_tkt="45a66a6e860356b991cc8fc8acf9bf7f4d8b3d2212!userid_type:int"; Path=/; Domain=.127.0.0.1:6543')]

$$$2 None

$$$3 None

I do have request.session working for me, so I'm guessing the problem isn't with the cookies.

Here's the code I use in my __init__ to config Pyramid:

authn_policy = AuthTktAuthenticationPolicy( 'secret', callback=lambda x:[])
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
my_session_factory = UnencryptedCookieSessionFactoryConfig('anothersecret')
config = Configurator(settings=settings, session_factory=my_session_factory,
                      authentication_policy=authn_policy,
        )

Please help!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top