Search code examples
pythonpython-2.7jwtpyramid

Can i config Main App of Pyramid with JWT pyramid-jwt and SessionAuthenticationPolicy


I have a problem when i try to config my app main of pyramid: Before my config is: (I have authentification within session of pyramid)

authn_policy = SessionAuthenticationPolicy()
authz_policy = ACLAuthorizationPolicy()

# configuration de pyramid : on utilise le données renseignées dans le
# fichier de config (settings), les données d'authentification
config = Configurator(
    settings=settings,
    root_factory=RootFactory,
    authentication_policy=authn_policy,
    authorization_policy=authz_policy,
    session_factory=session_factory,
)

then when i try to add JWT configuration it doesn't work because I have already authentication_policy=authn_policy, above :

# New configuration of JWT authentification for Pyramid
# Enable JWT authentication.
config.include('pyramid_jwt')
config.set_jwt_authentication_policy('secret')

I would like to use the both solutions of authentification, SessionAuthentificationPolicy and pyramid-jwt ?

Error: pyramid.exceptions.ConfigurationConflictError: Conflicting configuration actions


Solution

  • To my knowledge, Pyramid does not support multiple authentication policies out of the box. https://github.com/mozilla-services/pyramid_multiauth might help.